Search Unity

Textures for Custom Deferred Light ??

Discussion in 'Shaders' started by HWDKoblenz, Jun 26, 2018.

  1. HWDKoblenz

    HWDKoblenz

    Joined:
    Apr 3, 2017
    Posts:
    19
    Hello everyone,

    I was able to make a simple and easy Deferred Shader for my object and an easy deferred Light shader, instead of the build in unity shader. But in my light shader i need my hatching textures to apply the lighing effect instead of just using phong or brdf. But I'm not quite sure if this is possible? How can I add my 2 hatching textures to my light shader? I can set them as propteries, but where can i set the input?

    Maybe one of you knows how this works. Thx

    Chris <3
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    You'll need to set them as global textures via a script.
    https://docs.unity3d.com/ScriptReference/Shader.SetGlobalTexture.html

    You may want to do this every update, or every time your camera renders via OnPreRender or a command buffer. You can also do it only on Awake() or Start(), but Unity has an odd habit of loosing global shader variables occasionally while the game is running for reasons I don't fully understand.
     
  3. HWDKoblenz

    HWDKoblenz

    Joined:
    Apr 3, 2017
    Posts:
    19
    Thank you very much =D. This helped me a lot. !