Fixed bugs
This commit is contained in:
parent
79e83e4533
commit
efd6d8bda6
|
@ -206,8 +206,10 @@ public final class ShadersTest {
|
||||||
// Setup lighting for when we have fixed function fragment rendering.
|
// Setup lighting for when we have fixed function fragment rendering.
|
||||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||||
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
if (shader == null ) {
|
||||||
GL11.glEnable(GL11.GL_LIGHT0);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHT0);
|
||||||
|
}
|
||||||
|
|
||||||
vectorBuffer.clear();
|
vectorBuffer.clear();
|
||||||
vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
|
vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
|
||||||
|
|
|
@ -5,7 +5,7 @@ varying vec2 dots;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// Offset window-space fragment position.
|
// Offset window-space fragment position.
|
||||||
vec3 color2D = vec3(gl_FragCoord + UNIFORMS.zwxx);
|
vec3 color2D = vec3(gl_FragCoord + UNIFORMS.zwxx);
|
||||||
|
|
||||||
// Normalize position.
|
// Normalize position.
|
||||||
// Multiply with current sin.
|
// Multiply with current sin.
|
||||||
color2D.xy = normalize(color2D) * UNIFORMS.x;
|
color2D.xy = normalize(color2D) * UNIFORMS.x;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
uniform vec4 UNIFORMS;
|
||||||
|
|
||||||
varying vec2 dots;
|
varying vec2 dots;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
|
@ -6,6 +8,6 @@ void main(void) {
|
||||||
vec3 normal = gl_NormalMatrix * gl_Normal;
|
vec3 normal = gl_NormalMatrix * gl_Normal;
|
||||||
|
|
||||||
// Pass the dot products to the fragment shader.
|
// Pass the dot products to the fragment shader.
|
||||||
dots.x = max(dot(normal, gl_LightSource[0].position), 0.0);
|
dots.x = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
|
||||||
dots.y = max(dot(normal, gl_LightSource[0].halfVector), 0.0);
|
dots.y = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ void main(void) {
|
||||||
|
|
||||||
vec3 normal = gl_NormalMatrix * gl_Normal;
|
vec3 normal = gl_NormalMatrix * gl_Normal;
|
||||||
|
|
||||||
float diffuseDot = max(dot(normal, gl_LightSource[0].position), 0.0);
|
float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
|
||||||
float specularDot = max(dot(normal, gl_LightSource[0].halfVector), 0.0);
|
float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
|
||||||
specularDot = pow(specularDot, UNIFORMS.y);
|
specularDot = pow(specularDot, UNIFORMS.y);
|
||||||
|
|
||||||
// Normalize position, to get a {-1..1} value for each vertex.
|
// Normalize position, to get a {-1..1} value for each vertex.
|
||||||
|
@ -16,7 +16,7 @@ void main(void) {
|
||||||
color3D = (color3D * 0.5 + 0.5) * 2.0;
|
color3D = (color3D * 0.5 + 0.5) * 2.0;
|
||||||
|
|
||||||
// Accumulate color contributions.
|
// Accumulate color contributions.
|
||||||
color3D = diffuseDot * color3D + gl_LightModel.ambient;
|
color3D = diffuseDot * color3D + vec3(gl_LightModel.ambient);
|
||||||
gl_FrontColor.rgb = specularDot * gl_LightSource[0].specular + color3D;
|
gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D;
|
||||||
gl_FrontColor.a = 1.0;
|
gl_FrontColor.a = 1.0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue