Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Help needed: HDRP Chroma key shader

Discussion in 'Shaders' started by Dirrogate, Apr 25, 2020.

  1. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121
    Hi All,
    I've previously been using Unity's older default pipeline, and could thus import "live talent" filmed on greenscreen and have Unity's lighting etc, interact perfectly with the Qaud/plane that the greenscreened video was projected on. ( I used to use the assetstore EasyMovieTexture).

    Now, switching to HDRP, I see there's no chroma keyer that can do the same (interact with lighting within the scene) as seen in the images below. The cube video uses hdrp shader and interacts with lights/shadows but there is no chroma keyer that I know of, that works for it.

    I'd be grateful if anyone can help with an HDRP chroma key shader that will allow Unity Video player content to interact with in-engine lights/effects.

    Kind Regards
    Chroma_keyHDRP_interact.JPG Chroma_keyHDRP.JPG
     
  2. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121
    Any info to point me in the right direction please?
     
  3. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,103
    I think the best way would be to "write" that shader with shader graph at the moment. There's still no documentation on how to write custom HDRP shader, although Keijiro and maybe some others might have a few code snippets that point to the correct direction.
     
  4. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121
    I'd reached out to @Keijiro-UTJ via twitter just yesterday.
    Seeing the Unity roadmap, I see "Chromakey" buried down around slide 78: https://www.slideshare.net/unity3d/...imation-with-unity-2020-unite-copenhagen-2019 chromakey.JPG

    So I'm sure it's way out of my league as a coding handicapped filmmaker.
     
  5. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121


    Took me about two days - but got a workable ShaderGraph going from scratch.
    Quite pleased with the results. This now interacts with DoF , Fog and lighting.

    I'm still hoping someone with better skills writes one, or Unity itself - to accelerate Virtual Cinematography use of the Engine.
     
    Olmi likes this.
  6. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,103
    Looking quite ok - I've made similar although I didn't remember there's that color mask node which does the distance calculation etc. Saves a lot of nodes. I'm not an compositing expert for sure but I've dabbled with that stuff in the past... Anyway; some sources suggest it's possible to get better masking if you use LAB color space, or some other but that would mean that those color space conversions would need to be written in shader graph, which doesn't sound like fun... Anyway it would be probably quite doable to convert some existing one to shader graph.
     
    Dirrogate likes this.
  7. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121
    Thanks!
    For now yeah, this serves the purpose.
    Hopefully Unity release an advanced shadergraph chromakeyer that allows "final pixel" output right out of the engine.


     
  8. sebastien-barry

    sebastien-barry

    Joined:
    Dec 18, 2013
    Posts:
    53
    Where can I find the Unity advanced shadergraph chromakeyer ? Is it already release ?
     
  9. Dirrogate

    Dirrogate

    Joined:
    Feb 18, 2014
    Posts:
    121
    There is none (yet) from Unity. I'm still waiting for them to release one.

    Meanwhile, here's what I cobbled up, for HDRP. It's very basic and I'm hoping others can improve on it.
    https://github.com/dirrogate/HDRP-Unity-Chromakey
     
    Khashaneh and sebastien-barry like this.
unityunity