Search Unity

Question in “Hidden/Internal-ScreenSpaceShadows”

Discussion in 'Shaders' started by chenyong, Jul 12, 2017.

  1. chenyong

    chenyong

    Joined:
    Apr 4, 2013
    Posts:
    4
    Unity version:5.5.1
    Hidden/Internal-ScreenSpaceShadows

    struct v2f {
    ...
    // View space ray, for perspective case
    float3 ray : TEXCOORD1;
    }

    v2f vert (appdata v)
    {
    ...
    o.ray = v.normal;
    }

    why just use v.normal can get view space normal??? what does Unity do in the back???

    Thanks!
     
    Last edited: Jul 12, 2017
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    It's probably generating a quad mesh on the fly and storing the view direction into the mesh's vertex data. Makes a lot of sense since it removes a lot of matrix math the GPU needs to do and reduces the amount of information needed to be sent to the GPU.