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.
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_LIGHT0);
|
||||
if (shader == null ) {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_LIGHT0);
|
||||
}
|
||||
|
||||
vectorBuffer.clear();
|
||||
vectorBuffer.put(1.0f).put(1.0f).put(1.0f).put(1.0f);
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
uniform vec4 UNIFORMS;
|
||||
|
||||
varying vec2 dots;
|
||||
|
||||
void main(void) {
|
||||
|
@ -6,6 +8,6 @@ void main(void) {
|
|||
vec3 normal = gl_NormalMatrix * gl_Normal;
|
||||
|
||||
// Pass the dot products to the fragment shader.
|
||||
dots.x = max(dot(normal, gl_LightSource[0].position), 0.0);
|
||||
dots.y = max(dot(normal, gl_LightSource[0].halfVector), 0.0);
|
||||
dots.x = max(dot(normal, vec3(gl_LightSource[0].position)), 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;
|
||||
|
||||
float diffuseDot = max(dot(normal, gl_LightSource[0].position), 0.0);
|
||||
float specularDot = max(dot(normal, gl_LightSource[0].halfVector), 0.0);
|
||||
float diffuseDot = max(dot(normal, vec3(gl_LightSource[0].position)), 0.0);
|
||||
float specularDot = max(dot(normal, vec3(gl_LightSource[0].halfVector)), 0.0);
|
||||
specularDot = pow(specularDot, UNIFORMS.y);
|
||||
|
||||
// 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;
|
||||
|
||||
// Accumulate color contributions.
|
||||
color3D = diffuseDot * color3D + gl_LightModel.ambient;
|
||||
gl_FrontColor.rgb = specularDot * gl_LightSource[0].specular + color3D;
|
||||
color3D = diffuseDot * color3D + vec3(gl_LightModel.ambient);
|
||||
gl_FrontColor.rgb = specularDot * vec3(gl_LightSource[0].specular) + color3D;
|
||||
gl_FrontColor.a = 1.0;
|
||||
}
|
Loading…
Reference in New Issue