Search Unity

Does _TexelSize not work in PostProcessing shader?

Discussion in 'Shaders' started by noio, Feb 27, 2019.

  1. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    232
    The title says it all really.

    When I use the following texture declaration:

    Code (CSharp):
    1. uniform sampler2D _MyTex;
    2. uniform float4 _MyTex_TexelSize;
    Inside of a shader that's used in a PostProcessing Stack (v2) effect, the `_TexelSize` property is all zeroes. Is that by design?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,025
    "For each texture that is setup as a shader/material property, Unity also sets up some extra information in additional vector properties." (https://docs.unity3d.com/Manual/SL-PropertiesInPrograms.html)
    If you don't have it declared as
    Code (CSharp):
    1. _MyTex ("Texture", 2D) = "white" {} "
    it won't know about it at all.
     
  3. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    232
    Ah, thank you! That explains the difference.

    The Shaders that are used in the PostProcessing Stack (just through `Shader.Find(path)`) aren't used from a Material.