Implemented fixedfunc binding for AlphaTestFallOff

- Made the relvent changes in lwjgl1Renderer
- Changed the check in the lwjglRenderer (note that it's deprecated in opengl 3)
- Removed the test in the OglESRenderer since GL_ALPHA_TEST/GL_ALPHA_FUNC no longer exists in OGLES 2, this must be handled in the fragment shader aka the alphaDiscardThreshold that is coming back in an upcoming commit.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9747 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent 13132e10cc
commit 5111fd8b66
  1. 25
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
  2. 8
      engine/src/core/com/jme3/material/FixedFuncBinding.java
  3. 4
      engine/src/core/com/jme3/renderer/RenderContext.java
  4. 3
      engine/src/core/com/jme3/renderer/RenderManager.java
  5. 1
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglGL1Renderer.java
  6. 8
      engine/src/lwjgl/com/jme3/renderer/lwjgl/LwjglRenderer.java

@ -400,14 +400,7 @@ public class OGLESShaderRenderer implements Renderer {
GLES20.glDisable(GLES20.GL_DEPTH_TEST); GLES20.glDisable(GLES20.GL_DEPTH_TEST);
context.depthTestEnabled = false; context.depthTestEnabled = false;
} }
if (state.isAlphaTest() && !context.alphaTestEnabled) {
// GLES20.glEnable(GLES20.GL_ALPHA_TEST);
// GLES20.glAlphaFunc(GLES20.GL_GREATER, state.getAlphaFallOff());
context.alphaTestEnabled = true;
} else if (!state.isAlphaTest() && context.alphaTestEnabled) {
// GLES20.glDisable(GLES20.GL_ALPHA_TEST);
context.alphaTestEnabled = false;
}
if (state.isDepthWrite() && !context.depthWriteEnabled) { if (state.isDepthWrite() && !context.depthWriteEnabled) {
GLES20.glDepthMask(true); GLES20.glDepthMask(true);
context.depthWriteEnabled = true; context.depthWriteEnabled = true;
@ -422,14 +415,14 @@ public class OGLESShaderRenderer implements Renderer {
GLES20.glColorMask(false, false, false, false); GLES20.glColorMask(false, false, false, false);
context.colorWriteEnabled = false; context.colorWriteEnabled = false;
} }
if (state.isPointSprite() && !context.pointSprite) { // if (state.isPointSprite() && !context.pointSprite) {
// GLES20.glEnable(GLES20.GL_POINT_SPRITE); //// GLES20.glEnable(GLES20.GL_POINT_SPRITE);
// GLES20.glTexEnvi(GLES20.GL_POINT_SPRITE, GLES20.GL_COORD_REPLACE, GLES20.GL_TRUE); //// GLES20.glTexEnvi(GLES20.GL_POINT_SPRITE, GLES20.GL_COORD_REPLACE, GLES20.GL_TRUE);
// GLES20.glEnable(GLES20.GL_VERTEX_PROGRAM_POINT_SIZE); //// GLES20.glEnable(GLES20.GL_VERTEX_PROGRAM_POINT_SIZE);
// GLES20.glPointParameterf(GLES20.GL_POINT_SIZE_MIN, 1.0f); //// GLES20.glPointParameterf(GLES20.GL_POINT_SIZE_MIN, 1.0f);
} else if (!state.isPointSprite() && context.pointSprite) { // } else if (!state.isPointSprite() && context.pointSprite) {
// GLES20.glDisable(GLES20.GL_POINT_SPRITE); //// GLES20.glDisable(GLES20.GL_POINT_SPRITE);
} // }
if (state.isPolyOffset()) { if (state.isPolyOffset()) {
if (!context.polyOffsetEnabled) { if (!context.polyOffsetEnabled) {

@ -76,5 +76,11 @@ public enum FixedFuncBinding {
* If lighting is disabled, vertex color is modulated with * If lighting is disabled, vertex color is modulated with
* {@link #Color material color}. * {@link #Color material color}.
*/ */
UseVertexColor UseVertexColor,
/**
* Set the alpha threshold to discard pixels.
* @see RenderState#setAlphaFallOff
*/
AlphaTestFallOff
} }

@ -58,7 +58,7 @@ public class RenderContext {
/** /**
* @see RenderState#setAlphaTest(boolean) * @see RenderState#setAlphaTest(boolean)
*/ */
public boolean alphaTestEnabled = false; public float alphaTestFallOff = 0f;
/** /**
* @see RenderState#setDepthWrite(boolean) * @see RenderState#setDepthWrite(boolean)
@ -271,7 +271,7 @@ public class RenderContext {
public void reset(){ public void reset(){
cullMode = RenderState.FaceCullMode.Off; cullMode = RenderState.FaceCullMode.Off;
depthTestEnabled = false; depthTestEnabled = false;
alphaTestEnabled = false; alphaTestFallOff = 0f;
depthWriteEnabled = false; depthWriteEnabled = false;
colorWriteEnabled = false; colorWriteEnabled = false;
clipRectEnabled = false; clipRectEnabled = false;

@ -500,11 +500,14 @@ public class RenderManager {
//else the geom is not rendered //else the geom is not rendered
if (forcedTechnique != null) { if (forcedTechnique != null) {
if (g.getMaterial().getMaterialDef().getTechniqueDef(forcedTechnique) != null) { if (g.getMaterial().getMaterialDef().getTechniqueDef(forcedTechnique) != null) {
RenderState s = forcedRenderState;
forcedRenderState = g.getMaterial().getMaterialDef().getTechniqueDef(forcedTechnique).getRenderState();
tmpTech = g.getMaterial().getActiveTechnique() != null ? g.getMaterial().getActiveTechnique().getDef().getName() : "Default"; tmpTech = g.getMaterial().getActiveTechnique() != null ? g.getMaterial().getActiveTechnique().getDef().getName() : "Default";
g.getMaterial().selectTechnique(forcedTechnique, this); g.getMaterial().selectTechnique(forcedTechnique, this);
// use geometry's material // use geometry's material
g.getMaterial().render(g, this); g.getMaterial().render(g, this);
g.getMaterial().selectTechnique(tmpTech, this); g.getMaterial().selectTechnique(tmpTech, this);
forcedRenderState = s;
//Reverted this part from revision 6197 //Reverted this part from revision 6197
//If forcedTechnique does not exists, and frocedMaterial is not set, the geom MUST NOT be rendered //If forcedTechnique does not exists, and frocedMaterial is not set, the geom MUST NOT be rendered
} else if (forcedMaterial != null) { } else if (forcedMaterial != null) {

@ -226,7 +226,6 @@ public class LwjglGL1Renderer implements GL1Renderer {
} }
public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) { public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) {
float falloff;
switch (ffBinding) { switch (ffBinding) {
case Color: case Color:
context.color = (ColorRGBA) val; context.color = (ColorRGBA) val;

@ -486,13 +486,13 @@ public class LwjglRenderer implements Renderer {
context.depthTestEnabled = false; context.depthTestEnabled = false;
} }
if (state.isAlphaTest() && !context.alphaTestEnabled) { if (state.isAlphaTest() && context.alphaTestFallOff == 0) {
glEnable(GL_ALPHA_TEST); glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, state.getAlphaFallOff()); glAlphaFunc(GL_GREATER, state.getAlphaFallOff());
context.alphaTestEnabled = true; context.alphaTestFallOff = state.getAlphaFallOff();
} else if (!state.isAlphaTest() && context.alphaTestEnabled) { } else if (!state.isAlphaTest() && context.alphaTestFallOff != 0) {
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
context.alphaTestEnabled = false; context.alphaTestFallOff = 0;
} }
if (state.isDepthWrite() && !context.depthWriteEnabled) { if (state.isDepthWrite() && !context.depthWriteEnabled) {

Loading…
Cancel
Save