Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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,265
    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.