










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











๎
๎
vec4 AmbientLightColor = mix(GroundColor, SkyColor, (worldNormal.z + 1.0)/2.0); GLSL: ๎ (^) mix(vec x, vec y, float a) returns the linear blend of x and y : (1- a)x + a y
light
light
surface
light
surface
p light l p surface l p surface d
๎ (^) Parameters ๎ (^) Color: L ๎ (^) Position: p light ๎ (^) Direction: d spot ๎ (^) Cone falloff: e ๎ (^) Cone cutoff: ฮธ dspot plight l ฮธ ๎ (^) l = (p light -p surface )/||p light -p surface ||
spot
๎ (^) else I = L (-l โ d spot ) e p surface -d spot
๎ (^) A projector is like a camera 'in reverse' ๎ (^) Has a position, a field of view ๎ (^) Idea: use texture maps and projection matrices to simulation light sources
๎ (^) Eye Space ๎ (^) Camera at origin ๎ (^) X: right ๎ (^) Y: up ๎ (^) Z: -look ๎ (^) Clip Space ๎ (^) -w to +w in each direction ๎ (^) NDC ๎ (^) -1 to +1 in each direction ๎ (^) Screen Coordinates ๎ (^) Range : [1,w] x [1,h] Eye Space Clip Space Normalized Device Coordinates Clip Space Clip Space Screen Coordinates Projection Matrix (P) Perspective division (1/w) Scale and bias Let's look at the pipeline for transforming vertices into screen space
vec4 clip = gl_ModelViewProjectionMatrixgl_Vertex; vec3 ndc = clip.xyz / clip.w; vec2 texcoord = 0.5(ndc.xy + 1.0);
vec4 texture2DProj(sampler2D sampler, vec4 coord [, float bias]); ๎ (^) The texture coordinate coord.s, coord.t is divided by coord.q before texture lookup ๎ (^) texture2DProj(tex, coord) == texture2D(tex, coord.st/coord.q) ๎ (^) Define the scale and bias matrix ๎ (^) Projective texturing GLSL can be done by vec4 spotCoord = SspotProjspotView*gl_Vertex; vec4 spotlightColor = texture2DProj(spotMap, spotCoord); ๎ (^) In the fixed function pipeline simply set the texture matrix ๎ (^) glMatrixMode(GL_TEXTURE); ๎ (^) glTexGen with GL_EYE_LINEAR mode. S =
1 2 0 0 1 2 0 1 2 0 1 2 0 0 1 2 1 2 0 0 0 1
In practice don't do this. Just send the product of the 3 matrices as a uniform mat4.
vec4 spotlightColor = step(0.0, spotCoord.q)*texture2DProj(spotMap, spotCoord, focus);
edge 1