Code Monkey home page Code Monkey logo

unitychromakey's Introduction

UnityChromakey

A simple, yet powerful chromakey / greenscreen solution for Unity. Designed to be used with virtual production.

Usage

This shader is designed for HDRP, but you can easily convert it to URP

Once you've got the files in your project: Assign the chromakey shader to a material of your choice and attach that material to a quad / plane. Provide an image to the material or use a VideoPlayer to feed an image in.

Why this approach? It is the most verstile. Screenspace effects are complicated, clunky and difficult to modify. Screenspace effects also cannot be placed in worldspace easily. This shader is simple, only a few hundred lines and is a single pass. It is excellent for quickly blocking out greenscreen footage or even final composites. This repository is not an entire project, as that annoys me endlessly. You don't need all my project cruft yuck. This is simply a few files you can toss into your project and actually use.

Features

  • Standard Chromakeying: (green screen only). Modification would be required to work with a bluescreen (Would require Despill algorithm changes)
  • Simple edge feathering: This is a single-pixel blur approach, but enough for 99% of shots (when do you actually need a crazy 15 pixel deep blur?!?). I will probably expand the kernel to a larger box blur in the future.
  • Simple edge sharpening: (Sharpen up blurred edges to give a more anti-aliased feeling as opposed to just blur)
  • Despill correction: Getting rid of that pesky green light bleed
  • Simple usage, only a single shader and a single-pass
  • Example presets you can load onto the material (for the existing examples)

Examples

Note: Have mercy on the GIF compression and the fact that this footage was downloaded from YouTube, so it already has compression artifacts within it. It would look considerably better with nice clean source footage.

Note: This is an example of Despill correction being toggled. Watch the edges for green.

Note: This is reflective armor. Reflective. The nightmare for greenscreen. Looks pretty good to me!

Here are the controls used to tune for the following images:

Note: This is me controlling the strength of the Despill correction.

Modification

You are free to modify and improve on this simple approach. I would suggest contributing the changes to an open source community of some kind, it's better that we all have good tools.

Primary sources in the creation of this tool

http://gc-films.com/chromakey.html

https://benmcewan.com/blog/2018/05/20/understanding-despill-algorithms/

Disclaimers

Example images are random and off the internet. They are not mine and I don't pretend they are.

This shader hasn't been heavily optimized yet, but appears to perform quite well. It is untested on mobile platforms, but theoretically should work.

unitychromakey's People

Contributors

otdavies avatar tanzle-odavies avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.