test font/back for planes

Thijs Koerselman's icon

I'm rendering planes (jit.gl.gridshape) in jitter using sketch, and I want
to know if I'm looking at the front or the back of a plane. Therefor I guess
I need the planes normal vector and the eye vector. Are these available some
way using sketch/js?

I'd like to texture back and front differently, without rendering 2 textures
and 2 planes all the time.

-thijs

Wesley Smith's icon

I believe you can do this with a shader and a multitextured plane. You
would do something like the following.

Vertex shader:

use gl_Normal to compare normal direction with the eye vector and
store in a varying variable

Fragment Shader:

use that varying variable to pick color either from Tex0 or Tex1 and
assign to the fragment color.

wes

Thijs Koerselman's icon

thanks wes. i'll go for the shader.

best,
-thijs