0

I am not focused on a particular shader language. But I am trying to find a way to have a vector always coming from the top of my view.
Here are some screenshots to illustrate what I need.

Edit: I would like to obtain a mask. Here is a sample code for masking only bottom faces.

float mask = 1 - saturate(dot(float3(0.0, 1.0, 0.0), -worldNormal));

But the float3(0.0, 1.0, 0.0) is not in the camera space and I would like to have it like the screenshots above.
It's maybe a matrix trick.

reference1 reference2 reference3

genpfault
  • 51,148
  • 11
  • 85
  • 139
MaT
  • 1,556
  • 3
  • 28
  • 64
  • 2
    The camera's up-vector is the second row (or column, depending on your API) of the view matrix. If you don't have a pure view matrix, you can pass the vector as a shader variable. – Nico Schertler Apr 09 '14 at 08:46
  • Thanks a lot @NicoSchertler it's exactly what I wanted. – MaT Apr 09 '14 at 11:08

1 Answers1

2

Thanks to Nico Schertler. The simplest way to have the camera's up-vector is to capture the second row of the view matrix.

view matrix

Here is an interesting article about it : Understanding the View Matrix

Community
  • 1
  • 1
MaT
  • 1,556
  • 3
  • 28
  • 64