Search Unity

Camera Up vector in vertex shader.

Discussion in 'Shaders' started by Hjeldnes, Jul 22, 2012.

  1. Hjeldnes

    Hjeldnes

    Joined:
    Jul 22, 2012
    Posts:
    116
    Hello!

    I'm working on a billboard/sprite vertex shader (for snow/rain), and I wonder if there is a way I can access the camera's upvector from within the vertex shader.
    I pass the vector using Shader.SetGlobalVector("_Upvec", cam.transform.up); now and it works fine, but I suppose if this vector is already available from built in parameters, or through view matrices somehow?
    My hlsl knowledge is a bit rusty, so any input appreciated :)

    Thanks!

    Edit: Ok, it seems like I found the right vector. This works:

    upvec = UNITY_MATRIX_IT_MV[1].xyz;

    Kjetil
     
    Last edited: Jul 22, 2012