Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

How to sample a texture in a custom deferred lighting calculation?

Discussion in 'Shaders' started by AlanGameDev, Dec 24, 2016.

  1. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Hello there guys. This isn't a comeback yet, I'm just helping somebody (not sure if I'm gonna check the dozens of alerts yet). That being said:

    I'm making a custom lighting for the deferred path, and I'd like to sample a texture for values, however, I couldn't find a way to access a texture from there. Is there a way to do that?

    Thank you in advance.
     
  2. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    OK, I solved it by passing the texture in Shader.SetGlobalTexture so I just had to declare the sampler2D in the shader (and not the texture in the properties). I don't know if this is the most appropriate solution but it works.