Initial transfer of larger repo from git. IF full history and branches are needed must go to github at https://github.com/DulcisL/CCUCoding.git

This commit is contained in:
dolcel committed 2026-10-20 23:59:02 +00:00
commit c09ce40be0
4048 files changed
+603256

No files matched your search

+121
View File
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html>
<script id="vertex-shader" type="x-shader/x-vertex">
#version 300 es
// assume both position and normal are in homogeneous form
in vec4 aPosition;
in vec3 aNormal;
out vec4 vColor;
out vec3 R;
uniform vec4 uAmbientProduct, uDiffuseProduct, uSpecularProduct;
uniform mat4 uModelViewMatrix;
uniform mat4 uProjectionMatrix;
uniform vec4 uLightPosition;
uniform float uShininess;
uniform mat3 uNormalMatrix;
void
main()
{
// pos is vertex position in eye coordinates
vec3 pos = (uModelViewMatrix * aPosition).xyz;
// vector from vertex position to light source
vec3 L;
// check for directional light
if(uLightPosition.w == 0.0) L = normalize(uLightPosition.xyz);
else L = normalize( uLightPosition.xyz - pos );
// Because the eye point the is at the orgin
// the vector from the vertex position to the eye is
vec3 E = -normalize(pos);
// halfway vector
vec3 H = normalize(L + E);
// Transform vertex normal into eye coordinates
vec3 N = normalize(uNormalMatrix*aNormal.xyz);
R = reflect(pos, N);
// Compute terms in the illumination equation
vec4 ambient = uAmbientProduct;
float Kd = max(dot(L, N), 0.0);
vec4 diffuse = Kd*uDiffuseProduct;
float Ks = pow( max(dot(N, H), 0.0), uShininess );
vec4 specular = Ks * uSpecularProduct;
if(dot(L, N) < 0.0) {
specular = vec4(0.0, 0.0, 0.0, 1.0);
}
gl_Position = uProjectionMatrix * uModelViewMatrix * aPosition;
vColor = ambient + diffuse +specular;
vColor.a = 1.0;
}
</script>
<script id="fragment-shader" type="x-shader/x-fragment">
#version 300 es
precision mediump float;
in vec4 vColor;
out vec4 fColor;
in vec3 R;
uniform samplerCube texMap;
void
main()
{
vec4 texColor = texture(texMap, R);
fColor = vColor*texColor;
}
</script>
<p> </p>
<button id = "Button0">Increase R</button>
<button id = "Button1">Decrease R</button>
<p> </p>
<button id = "Button2">Increase theta</button>
<button id = "Button3">Decrease theta</button>
<button id = "Button4">Increase phi</button>
<button id = "Button5">Decrease phi</button>
<p> </p>
<button id = "Button6">Increase Subdivisions</button>
<button id = "Button7">Decrease Subdivisions</button>
<p></p>
<script type="text/javascript" src="../Common/initShaders.js"></script>
<script type="text/javascript" src="../Common/MVnew.js"></script>
<script type="text/javascript" src="reflectingSphere.js"></script>
<body>
<canvas id="gl-canvas" width="512" height="512">
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>
</body>
</html>