phong
This commit is contained in:
parent
66430eba5e
commit
0eee41e5ce
|
@ -54,11 +54,33 @@ function main() {
|
|||
varying lowp vec4 vNormal;
|
||||
varying lowp vec3 vPosition;
|
||||
|
||||
void main() {
|
||||
vec3 n = normalize(vec3(-5., 10., -5.));
|
||||
float diffuse = max(dot(vNormal.xyz, n), 0.);
|
||||
vec3 extremize(vec3 v, float n) {
|
||||
if (v.x > n / 2.)
|
||||
v.x = n;
|
||||
else
|
||||
v.x = 0.;
|
||||
if (v.y > n / 2.)
|
||||
v.y = n;
|
||||
else
|
||||
v.y = 0.;
|
||||
if (v.z > n / 2.)
|
||||
v.z = n;
|
||||
else
|
||||
v.z = 0.;
|
||||
return v;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4((vec3(1.) * diffuse * 0.8) + (vec3(1.) * 0.2), 1.0);
|
||||
void main() {
|
||||
vec3 n = normalize(vec3(-500., 1000., 500.) - vPosition);
|
||||
float diffuse = max(dot(vNormal.xyz, n), 0.);
|
||||
float specular = pow(
|
||||
max(dot(
|
||||
reflect(n, vNormal.xyz),
|
||||
normalize(vec3(0., 0., -50.) - vPosition)),
|
||||
0.), 10.);
|
||||
vec3 tmp = extremize(mod(vPosition.xyz + vec3(100.), vec3(3.)), 3.);
|
||||
float texture = (tmp.x + tmp.y + tmp.z) / 9.;
|
||||
gl_FragColor = vec4((vec3(1.) * diffuse * 0.8) + (texture * 0.2) + (specular * vec3(1.)), 1.0);
|
||||
}`;
|
||||
|
||||
/* eslint-enable */
|
||||
|
@ -312,6 +334,12 @@ function drawScene(gl: any,
|
|||
// the center of the scene.
|
||||
const viewMatrix = mat4.create();
|
||||
|
||||
|
||||
mat4.translate(
|
||||
viewMatrix,
|
||||
viewMatrix,
|
||||
[Math.cos(squareRotation) * 5, Math.sin(squareRotation) * 5, 0]);
|
||||
|
||||
mat4.translate(
|
||||
viewMatrix,
|
||||
viewMatrix,
|
||||
|
|
Loading…
Reference in New Issue