uniform
attribute
varying
gl_Position
gl_FragColor
uniform
gl_FragColor
varying
gl_Position
attribute
viewMatrix * vec4(cameraPosition, 1.0)
in the vertex shader? vec4(0.0, 0.0, 0.0, 1.0)
vec4(1.0, 1.0, 1.0, 1.0)
vec4(position, 1.0)
vec4(cameraPosition - position, 1.0)
vec4(position - cameraPosition, 1.0)
0.0
in the shader? step(t, x)
means x < t ? 0.0 : 1.0
. step(0.75, 0.5)
step(1.0, 0.5)
step(0.5, 0.5)
step(0.25, 0.5)
step(0.0, 0.5)
mesh = new THREE.Mesh(geometry, material)
with material = new THREE.ShaderMaterial({uniforms ...})
, where does the vertex shader get values for attribute vec3 color
? geometry.getAttribute("color")
material.color
mesh.getAttribute("color")
mesh.color
material.uniforms.color
a = vec3(1.0, 0.0, 0.0)
and b = normalize(vec3(1.0, 1.0, 0.0))
? dot(a, b)
dot(b, a)
-dot(b, a)
cos(atan(b / a))
cos(atan(a \ b))
cos(theta) = -1
and the Phong coefficient or shininess
is p = 3
. What is the intensity of the specular light? Note: the intensity is calculated by pow(clamp(cos(theta), 0.0, 1.0), p)
. 0.0
1.0
-1.0
3
-3
lp = vec3(1.0, 1.0, 1.0)
in the scene coordinates to the camera coordinates in the vertex shaders (so that the light does not move with the camera)? vec3(viewMatrix * vec4(lp, 1.0))
viewMatrix * lp
normalMatrix * lp
vec3(projectionMatrix * viewMatrix * vec4(lp, 1.0))
projectionMatrix * viewMatrix * lp
Last Updated: November 30, 2024 at 4:35 AM