Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Helping to Make an Awesome Lighting Shader...

Discussion in 'Shaders' started by OliverJackman, Aug 2, 2019.

  1. OliverJackman

    OliverJackman

    Joined:
    Aug 2, 2019
    Posts:
    4
    Hey guys! Sup?
    I'm Oliver and it's my first post here (Why newbies always says that?? xD )
    Anyway...

    I'm dealing with a concept to use best rendering apps out there to light our unity scene up and I need your help and experiences to make it happen.
    Stay on line ...

    Background
    I'm dealing with this concept for 3-4 years , Back in unity 4 I had shadow masking idea since I saw the method was used in Remember Me video game.
    I asked on some places and people answered it's not possible on unity and well , Unity added shadow masking in unity 5.

    In remember me which made by Unreal Engine 3 , they baked every light static shadows in a separate texture and they used it to blend dynamic shadows with static shadows without any overlapping , which explains how a game like Remember Me had a amazing graphic in its time.


    Unity Shadow Mask
    After I found out unity added shadow masking I felt so happy and good about it but it didn't take long.
    Limitation of 4 light because of 4 channel (RGBA) and mixing GI Bounces through dynamic lighting ?
    What if we can bake everything in scene via a amazing render engine with high accuracy like (V-Ray) and just use dynamic lights on dynamic objects and mix their shadows on static objects ?



    Per-Light Shadow Mask Method
    Okay here we go , it's pretty simple!
    If there was a way to get shadows from specific and pre-defined lights on shader and use it as a mask , it could solve all problems with this concept :)

    Here's a simple scene with 6 baked maps from V-Ray :



    Channels [Baked Maps] :
    • Light A Direct
    • Light B Direct
    • Light A Indirect
    • Light B Indirect
    • Light A Shadowmask
    • Light B Shadowmask
    Okay , now if we have two more surface shader channel as ...
    • Light A Shadow Channel On Surface Shader
    • Light B Shadow Channel On Surface Shader
    We could use this processing to build Light A and Light B beauty channels :

    A ) Multiply Dynamic Shadow Map A on Direct Light A then Add Indirect A and Here is Result :




    B ) Multiply Dynamic Shadow Map B on Direct Light B then Add Indirect B and Here is Result :



    C ) In final step , We just use Screen Blend on all light layers to mix them together :



    And here we go, Final Result :


    About this footage :
    Made by 3dsmax and aftereffects with same channels and methods explained above.
    Whole scene and shadows are baked only exploded sphere and its shadows are dynamic.


    I know unity shadow system is fully customizable using 'UnityShadowLibrary.cginc' and I know unity
    uses HLSL so this link can be helpful ( Tutorial 41: Multiple Light Shadow Mapping )

    I don't know much about shader writing , can you guys tell me is this possible and if yes help me to make it happen ? I know unity lighting system is pretty good enough right now but guess what you can do with power of a renderer like V-Ray...


    Is it possible to get shadow map of specific lights in shader as a texture 2D or anything to mask emission ?

    Here's a starter-kit for people like challenges :
    Download Unity 2019 ShadowBlend Starter-Kit [ Tiny Upload ]
    Download Unity 2019 ShadowBlend Starter-Kit [ Unity Server ]


    I already did a masking with Light Attenuation but it sucks ( Fact : I Suck ) :[

    ShadowBlend Vs Light Attenuation :



    Any help would be appreciated! Thank you ^^
     

    Attached Files:

    Last edited: Aug 2, 2019