pouic long boiiiiiiii
This commit is contained in:
@ -1,25 +1,35 @@
|
||||
const vertex_shader_source = `
|
||||
attribute vec4 aPos;
|
||||
attribute vec4 aColor;
|
||||
attribute vec3 aNormal;
|
||||
|
||||
uniform mat4 uModView;
|
||||
uniform mat4 uProj;
|
||||
uniform mat4 uNormalMat;
|
||||
|
||||
varying lowp vec4 vColor;
|
||||
varying highp vec3 vLighting;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProj * uModView * aPos;
|
||||
vColor = aColor;
|
||||
|
||||
highp vec3 ambientLight = vec3(0.3, 0.3, 0.3);
|
||||
highp vec3 directionalLightColor = vec3(1, 1, 1);
|
||||
highp vec3 directionalVector = normalize(vec3(0.85, 0.8, 0.75));
|
||||
|
||||
highp vec4 transformedNormal = uNormalMat * vec4(aNormal, 1.0);
|
||||
|
||||
highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);
|
||||
vLighting = ambientLight + (directionalLightColor * directional);
|
||||
}
|
||||
`;
|
||||
|
||||
const fragment_shader_source = `
|
||||
varying lowp vec4 vColor;
|
||||
varying highp vec3 vLighting;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
highp vec3 color = vec3(1.0, 1.0, 1.0);
|
||||
gl_FragColor = vec4(color * vLighting, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
@ -50,7 +60,7 @@ function loadShader(gl, type, source)
|
||||
|
||||
if(!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
|
||||
{
|
||||
alert(`An error occurred compiling the shaders: ${gl.getShaderInfoLog(shader)}`);
|
||||
alert(`An error occurred while compiling the shaders: ${gl.getShaderInfoLog(shader)}`);
|
||||
gl.deleteShader(shader);
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user