From 3c0ad074ef4635b6e999867767122bb78143d257 Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Mon, 2 Jul 2012 15:10:36 +0000 Subject: [PATCH] Having Ambient and Diffuse sum to more than one causes inconsistencies with textures. It looks like it is clamping the color from lighting before it multiplies it with the texture. --- .../sf/openrocket/gui/figure3d/RocketFigure3d.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index 3cae27189..61b4241ce 100644 --- a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -17,6 +17,7 @@ import java.util.Set; import javax.media.opengl.GL; import javax.media.opengl.GL2; +import javax.media.opengl.GL2ES1; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; @@ -385,15 +386,19 @@ public class RocketFigure3d extends JPanel implements GLEventListener { gl.glClearDepth(1.0f); // clear z-buffer to the farthest gl.glDepthFunc(GL.GL_LEQUAL); // the type of depth test to do + + gl.glLightModelfv(GL2ES1.GL_LIGHT_MODEL_AMBIENT, + new float[] { 0,0,0 }, 0); - float amb = 0.5f; - float dif = 1.0f; + float amb = 0.3f; + float dif = 1.0f - amb; + float spc = 1.0f; gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_AMBIENT, new float[] { amb, amb, amb, 1 }, 0); gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_DIFFUSE, new float[] { dif, dif, dif, 1 }, 0); gl.glLightfv(GLLightingFunc.GL_LIGHT1, GLLightingFunc.GL_SPECULAR, - new float[] { dif, dif, dif, 1 }, 0); + new float[] { spc, spc, spc, 1 }, 0); gl.glEnable(GLLightingFunc.GL_LIGHT1); gl.glEnable(GLLightingFunc.GL_LIGHTING);