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
This commit is contained in:
parent
13132e10cc
commit
5111fd8b66
@ -400,14 +400,7 @@ public class OGLESShaderRenderer implements Renderer {
|
||||
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
|
||||
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) {
|
||||
GLES20.glDepthMask(true);
|
||||
context.depthWriteEnabled = true;
|
||||
@ -422,14 +415,14 @@ public class OGLESShaderRenderer implements Renderer {
|
||||
GLES20.glColorMask(false, false, false, false);
|
||||
context.colorWriteEnabled = false;
|
||||
}
|
||||
if (state.isPointSprite() && !context.pointSprite) {
|
||||
// GLES20.glEnable(GLES20.GL_POINT_SPRITE);
|
||||
// GLES20.glTexEnvi(GLES20.GL_POINT_SPRITE, GLES20.GL_COORD_REPLACE, GLES20.GL_TRUE);
|
||||
// GLES20.glEnable(GLES20.GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
// GLES20.glPointParameterf(GLES20.GL_POINT_SIZE_MIN, 1.0f);
|
||||
} else if (!state.isPointSprite() && context.pointSprite) {
|
||||
// GLES20.glDisable(GLES20.GL_POINT_SPRITE);
|
||||
}
|
||||
// if (state.isPointSprite() && !context.pointSprite) {
|
||||
//// GLES20.glEnable(GLES20.GL_POINT_SPRITE);
|
||||
//// GLES20.glTexEnvi(GLES20.GL_POINT_SPRITE, GLES20.GL_COORD_REPLACE, GLES20.GL_TRUE);
|
||||
//// GLES20.glEnable(GLES20.GL_VERTEX_PROGRAM_POINT_SIZE);
|
||||
//// GLES20.glPointParameterf(GLES20.GL_POINT_SIZE_MIN, 1.0f);
|
||||
// } else if (!state.isPointSprite() && context.pointSprite) {
|
||||
//// GLES20.glDisable(GLES20.GL_POINT_SPRITE);
|
||||
// }
|
||||
|
||||
if (state.isPolyOffset()) {
|
||||
if (!context.polyOffsetEnabled) {
|
||||
|
@ -76,5 +76,11 @@ public enum FixedFuncBinding {
|
||||
* If lighting is disabled, vertex color is modulated with
|
||||
* {@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)
|
||||
*/
|
||||
public boolean alphaTestEnabled = false;
|
||||
public float alphaTestFallOff = 0f;
|
||||
|
||||
/**
|
||||
* @see RenderState#setDepthWrite(boolean)
|
||||
@ -271,7 +271,7 @@ public class RenderContext {
|
||||
public void reset(){
|
||||
cullMode = RenderState.FaceCullMode.Off;
|
||||
depthTestEnabled = false;
|
||||
alphaTestEnabled = false;
|
||||
alphaTestFallOff = 0f;
|
||||
depthWriteEnabled = false;
|
||||
colorWriteEnabled = false;
|
||||
clipRectEnabled = false;
|
||||
|
@ -500,11 +500,14 @@ public class RenderManager {
|
||||
//else the geom is not rendered
|
||||
if (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";
|
||||
g.getMaterial().selectTechnique(forcedTechnique, this);
|
||||
// use geometry's material
|
||||
g.getMaterial().render(g, this);
|
||||
g.getMaterial().selectTechnique(tmpTech, this);
|
||||
forcedRenderState = s;
|
||||
//Reverted this part from revision 6197
|
||||
//If forcedTechnique does not exists, and frocedMaterial is not set, the geom MUST NOT be rendered
|
||||
} else if (forcedMaterial != null) {
|
||||
|
@ -226,7 +226,6 @@ public class LwjglGL1Renderer implements GL1Renderer {
|
||||
}
|
||||
|
||||
public void setFixedFuncBinding(FixedFuncBinding ffBinding, Object val) {
|
||||
float falloff;
|
||||
switch (ffBinding) {
|
||||
case Color:
|
||||
context.color = (ColorRGBA) val;
|
||||
|
@ -486,13 +486,13 @@ public class LwjglRenderer implements Renderer {
|
||||
context.depthTestEnabled = false;
|
||||
}
|
||||
|
||||
if (state.isAlphaTest() && !context.alphaTestEnabled) {
|
||||
if (state.isAlphaTest() && context.alphaTestFallOff == 0) {
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, state.getAlphaFallOff());
|
||||
context.alphaTestEnabled = true;
|
||||
} else if (!state.isAlphaTest() && context.alphaTestEnabled) {
|
||||
context.alphaTestFallOff = state.getAlphaFallOff();
|
||||
} else if (!state.isAlphaTest() && context.alphaTestFallOff != 0) {
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
context.alphaTestEnabled = false;
|
||||
context.alphaTestFallOff = 0;
|
||||
}
|
||||
|
||||
if (state.isDepthWrite() && !context.depthWriteEnabled) {
|
||||
@ -1038,7 +1038,7 @@ public class LwjglRenderer implements Renderer {
|
||||
// Check if GLSL version is 1.5 for shader
|
||||
GL30.glBindFragDataLocation(id, 0, "outFragColor");
|
||||
// For MRT
|
||||
for(int i = 0 ; i < maxMRTFBOAttachs ; i++) {
|
||||
for (int i = 0; i < maxMRTFBOAttachs; i++) {
|
||||
GL30.glBindFragDataLocation(id, i, "outFragData[" + i + "]");
|
||||
}
|
||||
}
|
||||
@ -1895,7 +1895,7 @@ public class LwjglRenderer implements Renderer {
|
||||
|
||||
public void setTexture(int unit, Texture tex) {
|
||||
Image image = tex.getImage();
|
||||
if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated()) ) {
|
||||
if (image.isUpdateNeeded() || (image.isGeneratedMipmapsRequired() && !image.isMipmapsGenerated())) {
|
||||
updateTexImageData(image, tex.getType(), unit);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user