Search Unity

What means IN.worldRefl ?

Discussion in 'Shaders' started by dccoo, Jul 27, 2019.

  1. dccoo

    dccoo

    Joined:
    Oct 3, 2015
    Posts:
    132
    What does this variable worldRefl of input mean?

    I've seen in some tutorials people using it with cubemaps but I have no idea what it stands for.

    Unity's description is very poor:
    • float3 worldRefl - contains world reflection vector if surface shader does not write to o.Normal. See Reflect-Diffuse shader for example.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    7,128
    It stands for world reflection, because it contains the world reflection vector. In other words it's the world space direction of a mirror reflection using the vertex interpolated surface normal.

    It doesn't work if your Surface Shader uses o.Normal because presumably you want the reflection to use the per pixel normal calculated in the surf function and not the per vertex one.

    It is usually used with cube maps because the most common use of cube maps is to store a 360 world space image which when sampled using the world reflection vector produces a believable reflection.
     
    dccoo likes this.