As a lab exercise:
Cameraclass. Situate it at the origin, have it look down the negative z-axis, and have it point up.
OnDraw, alter the cone’s
modelviewmatrix to be the regular camera’s view matrix multiplied by the light camera’s view matrix. Run your code. What happens when you hit the cursor keys?
Matrix4class has a
GetTransposemethod that yields a matrix’s transpose. Verify that this produces the expected behavior.
OnInitialize, load in as an
bat_signal_texture->Channels(Texture::RGB); bat_signal_texture->Upload(image->GetWidth(), image->GetHeight(), image->GetPixels());
Matrix4 model_to_tex = translate by (0.5, 0.5, 0.5) * scale by (0.5, 0.5, 0.5) * Matrix4::GetPerspective(fov, texture_aspect_ratio, 0.1f, 1000.0f) * light's view matrix * object's model-to-world transform;
Compute this transform in
OnDraw for the box. Upload it as a uniform to its vertex shader. The texture is 1024×512. I used 80 for the field of view. In our case, the box’s model coordinates are identical to its world coordinates, so the last matrix in the expression can be omitted.
v.glsl, compute texture coordinates for the fragment shader by applying the
model_to_texturematrix to the vertex’s model space coordinates. The result is a
Modulate the resulting color by
litness and add it into the fragment’s color. How do things look?
Now how do things look?
vec3 signal = ftexcoord.w < 0.0 ? vec3(0.0) : texture2DProj(...).rgb;