OpenGL Renderer: Prevent applying edge marking on wireframe polygons.
This commit is contained in:
parent
c71da856f5
commit
a2273b5eac
|
@ -307,7 +307,7 @@ static const char *fragmentShader_100 = {"\
|
||||||
uniform float stateAlphaTestRef;\n\
|
uniform float stateAlphaTestRef;\n\
|
||||||
\n\
|
\n\
|
||||||
uniform int polyMode;\n\
|
uniform int polyMode;\n\
|
||||||
uniform bool polyIsTranslucent;\n\
|
uniform bool polyIsWireframe;\n\
|
||||||
uniform bool polySetNewDepthForTranslucent;\n\
|
uniform bool polySetNewDepthForTranslucent;\n\
|
||||||
uniform int polyID;\n\
|
uniform int polyID;\n\
|
||||||
\n\
|
\n\
|
||||||
|
@ -372,8 +372,8 @@ static const char *fragmentShader_100 = {"\
|
||||||
}\n\
|
}\n\
|
||||||
else if (polyMode == 2)\n\
|
else if (polyMode == 2)\n\
|
||||||
{\n\
|
{\n\
|
||||||
vec3 toonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb);\n\
|
vec3 newToonColor = vec3(texture1D(texToonTable, vtxColor.r).rgb);\n\
|
||||||
newFragColor.rgb = (stateToonShadingMode == 0) ? mainTexColor.rgb * toonColor.rgb : min((mainTexColor.rgb * vtxColor.r) + toonColor.rgb, 1.0);\n\
|
newFragColor.rgb = (stateToonShadingMode == 0) ? mainTexColor.rgb * newToonColor.rgb : min((mainTexColor.rgb * vtxColor.r) + newToonColor.rgb, 1.0);\n\
|
||||||
}\n\
|
}\n\
|
||||||
else if (polyMode == 3)\n\
|
else if (polyMode == 3)\n\
|
||||||
{\n\
|
{\n\
|
||||||
|
@ -390,7 +390,7 @@ static const char *fragmentShader_100 = {"\
|
||||||
newFragDepth = vec4(packVec3FromFloat(newFragDepthValue), 1.0);\n\
|
newFragDepth = vec4(packVec3FromFloat(newFragDepthValue), 1.0);\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
newPolyID = vec4(float(polyID)/63.0, 0.0, 0.0, float(newFragColor.a > 0.999));\n\
|
newPolyID = vec4( float(polyID)/63.0, float(polyIsWireframe), 0.0, float(newFragColor.a > 0.999) );\n\
|
||||||
newFogAttributes = vec4( float(polyEnableFog), 0.0, 0.0, float((newFragColor.a > 0.999) ? 1.0 : 0.5) );\n\
|
newFogAttributes = vec4( float(polyEnableFog), 0.0, 0.0, float((newFragColor.a > 0.999) ? 1.0 : 0.5) );\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
|
@ -439,12 +439,26 @@ static const char *EdgeMarkFragShader_100 = {"\
|
||||||
\n\
|
\n\
|
||||||
void main()\n\
|
void main()\n\
|
||||||
{\n\
|
{\n\
|
||||||
|
vec4 polyIDInfo[5];\n\
|
||||||
|
polyIDInfo[0] = texture2D(texInPolyID, texCoord[0]);\n\
|
||||||
|
polyIDInfo[1] = texture2D(texInPolyID, texCoord[1]);\n\
|
||||||
|
polyIDInfo[2] = texture2D(texInPolyID, texCoord[2]);\n\
|
||||||
|
polyIDInfo[3] = texture2D(texInPolyID, texCoord[3]);\n\
|
||||||
|
polyIDInfo[4] = texture2D(texInPolyID, texCoord[4]);\n\
|
||||||
|
\n\
|
||||||
int polyID[5];\n\
|
int polyID[5];\n\
|
||||||
polyID[0] = int((texture2D(texInPolyID, texCoord[0]).r * 63.0) + 0.5);\n\
|
polyID[0] = int((polyIDInfo[0].r * 63.0) + 0.5);\n\
|
||||||
polyID[1] = int((texture2D(texInPolyID, texCoord[1]).r * 63.0) + 0.5);\n\
|
polyID[1] = int((polyIDInfo[1].r * 63.0) + 0.5);\n\
|
||||||
polyID[2] = int((texture2D(texInPolyID, texCoord[2]).r * 63.0) + 0.5);\n\
|
polyID[2] = int((polyIDInfo[2].r * 63.0) + 0.5);\n\
|
||||||
polyID[3] = int((texture2D(texInPolyID, texCoord[3]).r * 63.0) + 0.5);\n\
|
polyID[3] = int((polyIDInfo[3].r * 63.0) + 0.5);\n\
|
||||||
polyID[4] = int((texture2D(texInPolyID, texCoord[4]).r * 63.0) + 0.5);\n\
|
polyID[4] = int((polyIDInfo[4].r * 63.0) + 0.5);\n\
|
||||||
|
\n\
|
||||||
|
bool isWireframe[5];\n\
|
||||||
|
isWireframe[0] = bool(polyIDInfo[0].g);\n\
|
||||||
|
isWireframe[1] = bool(polyIDInfo[1].g);\n\
|
||||||
|
isWireframe[2] = bool(polyIDInfo[2].g);\n\
|
||||||
|
isWireframe[3] = bool(polyIDInfo[3].g);\n\
|
||||||
|
isWireframe[4] = bool(polyIDInfo[4].g);\n\
|
||||||
\n\
|
\n\
|
||||||
float depth[5];\n\
|
float depth[5];\n\
|
||||||
depth[0] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[0]).rgb);\n\
|
depth[0] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[0]).rgb);\n\
|
||||||
|
@ -453,18 +467,21 @@ static const char *EdgeMarkFragShader_100 = {"\
|
||||||
depth[3] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[3]).rgb);\n\
|
depth[3] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[3]).rgb);\n\
|
||||||
depth[4] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[4]).rgb);\n\
|
depth[4] = unpackFloatFromVec3(texture2D(texInFragDepth, texCoord[4]).rgb);\n\
|
||||||
\n\
|
\n\
|
||||||
vec4 edgeColor = vec4(0.0, 0.0, 0.0, 0.0);\n\
|
vec4 newEdgeColor = vec4(0.0, 0.0, 0.0, 0.0);\n\
|
||||||
\n\
|
\n\
|
||||||
|
if (!isWireframe[0])\n\
|
||||||
|
{\n\
|
||||||
for (int i = 1; i < 5; i++)\n\
|
for (int i = 1; i < 5; i++)\n\
|
||||||
{\n\
|
{\n\
|
||||||
if (polyID[0] != polyID[i] && depth[0] >= depth[i])\n\
|
if ( (polyID[0] != polyID[i]) && (depth[0] >= depth[i]) && !isWireframe[i] )\n\
|
||||||
{\n\
|
{\n\
|
||||||
edgeColor = stateEdgeColor[polyID[i]/8];\n\
|
newEdgeColor = stateEdgeColor[polyID[i]/8];\n\
|
||||||
break;\n\
|
break;\n\
|
||||||
}\n\
|
}\n\
|
||||||
}\n\
|
}\n\
|
||||||
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
gl_FragData[0] = edgeColor;\n\
|
gl_FragData[0] = newEdgeColor;\n\
|
||||||
}\n\
|
}\n\
|
||||||
"};
|
"};
|
||||||
|
|
||||||
|
@ -1653,7 +1670,7 @@ Render3DError OpenGLRenderer_1_2::InitGeometryProgramShaderLocations()
|
||||||
|
|
||||||
OGLRef.uniformPolyTexScale = glGetUniformLocation(OGLRef.programGeometryID, "polyTexScale");
|
OGLRef.uniformPolyTexScale = glGetUniformLocation(OGLRef.programGeometryID, "polyTexScale");
|
||||||
OGLRef.uniformPolyMode = glGetUniformLocation(OGLRef.programGeometryID, "polyMode");
|
OGLRef.uniformPolyMode = glGetUniformLocation(OGLRef.programGeometryID, "polyMode");
|
||||||
OGLRef.uniformPolyIsTranslucent = glGetUniformLocation(OGLRef.programGeometryID, "polyIsTranslucent");
|
OGLRef.uniformPolyIsWireframe = glGetUniformLocation(OGLRef.programGeometryID, "polyIsWireframe");
|
||||||
OGLRef.uniformPolySetNewDepthForTranslucent = glGetUniformLocation(OGLRef.programGeometryID, "polySetNewDepthForTranslucent");
|
OGLRef.uniformPolySetNewDepthForTranslucent = glGetUniformLocation(OGLRef.programGeometryID, "polySetNewDepthForTranslucent");
|
||||||
OGLRef.uniformPolyAlpha = glGetUniformLocation(OGLRef.programGeometryID, "polyAlpha");
|
OGLRef.uniformPolyAlpha = glGetUniformLocation(OGLRef.programGeometryID, "polyAlpha");
|
||||||
OGLRef.uniformPolyID = glGetUniformLocation(OGLRef.programGeometryID, "polyID");
|
OGLRef.uniformPolyID = glGetUniformLocation(OGLRef.programGeometryID, "polyID");
|
||||||
|
@ -3071,7 +3088,7 @@ Render3DError OpenGLRenderer_1_2::SetupPolygon(const POLY &thePoly)
|
||||||
glUniform1i(OGLRef.uniformPolyEnableFog, (attr.enableRenderFog) ? GL_TRUE : GL_FALSE);
|
glUniform1i(OGLRef.uniformPolyEnableFog, (attr.enableRenderFog) ? GL_TRUE : GL_FALSE);
|
||||||
glUniform1f(OGLRef.uniformPolyAlpha, (attr.isWireframe) ? 1.0f : divide5bitBy31_LUT[attr.alpha]);
|
glUniform1f(OGLRef.uniformPolyAlpha, (attr.isWireframe) ? 1.0f : divide5bitBy31_LUT[attr.alpha]);
|
||||||
glUniform1i(OGLRef.uniformPolyID, attr.polygonID);
|
glUniform1i(OGLRef.uniformPolyID, attr.polygonID);
|
||||||
glUniform1i(OGLRef.uniformPolyIsTranslucent, (attr.isTranslucent && !isOpaqueDecal) ? GL_TRUE : GL_FALSE);
|
glUniform1i(OGLRef.uniformPolyIsWireframe, (attr.isWireframe) ? GL_TRUE : GL_FALSE);
|
||||||
glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, (attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE);
|
glUniform1i(OGLRef.uniformPolySetNewDepthForTranslucent, (attr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -377,7 +377,7 @@ struct OGLPolyStates
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct { GLubyte enableTexture, enableFog, isTranslucent, setNewDepthForTranslucent; };
|
struct { GLubyte enableTexture, enableFog, isWireframe, setNewDepthForTranslucent; };
|
||||||
GLubyte flags[4];
|
GLubyte flags[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ struct OGLRenderRef
|
||||||
|
|
||||||
GLint uniformPolyTexScale;
|
GLint uniformPolyTexScale;
|
||||||
GLint uniformPolyMode;
|
GLint uniformPolyMode;
|
||||||
GLint uniformPolyIsTranslucent;
|
GLint uniformPolyIsWireframe;
|
||||||
GLint uniformPolySetNewDepthForTranslucent;
|
GLint uniformPolySetNewDepthForTranslucent;
|
||||||
GLint uniformPolyAlpha;
|
GLint uniformPolyAlpha;
|
||||||
GLint uniformPolyID;
|
GLint uniformPolyID;
|
||||||
|
|
|
@ -116,7 +116,7 @@ static const char *GeometryVtxShader_150 = {"\
|
||||||
out vec4 vtxColor; \n\
|
out vec4 vtxColor; \n\
|
||||||
flat out uint polyEnableTexture;\n\
|
flat out uint polyEnableTexture;\n\
|
||||||
flat out uint polyEnableFog;\n\
|
flat out uint polyEnableFog;\n\
|
||||||
flat out uint polyIsTranslucent;\n\
|
flat out uint polyIsWireframe;\n\
|
||||||
flat out uint polySetNewDepthForTranslucent;\n\
|
flat out uint polySetNewDepthForTranslucent;\n\
|
||||||
flat out uint polyMode;\n\
|
flat out uint polyMode;\n\
|
||||||
flat out uint polyID;\n\
|
flat out uint polyID;\n\
|
||||||
|
@ -133,7 +133,7 @@ static const char *GeometryVtxShader_150 = {"\
|
||||||
\n\
|
\n\
|
||||||
polyEnableTexture = polyStateFlags[0];\n\
|
polyEnableTexture = polyStateFlags[0];\n\
|
||||||
polyEnableFog = polyStateFlags[1];\n\
|
polyEnableFog = polyStateFlags[1];\n\
|
||||||
polyIsTranslucent = polyStateFlags[2];\n\
|
polyIsWireframe = polyStateFlags[2];\n\
|
||||||
polySetNewDepthForTranslucent = polyStateFlags[3];\n\
|
polySetNewDepthForTranslucent = polyStateFlags[3];\n\
|
||||||
polyMode = polyStateValues[1];\n\
|
polyMode = polyStateValues[1];\n\
|
||||||
polyID = polyStateValues[2];\n\
|
polyID = polyStateValues[2];\n\
|
||||||
|
@ -159,7 +159,7 @@ static const char *GeometryFragShader_150 = {"\
|
||||||
in vec4 vtxColor;\n\
|
in vec4 vtxColor;\n\
|
||||||
flat in uint polyEnableTexture;\n\
|
flat in uint polyEnableTexture;\n\
|
||||||
flat in uint polyEnableFog;\n\
|
flat in uint polyEnableFog;\n\
|
||||||
flat in uint polyIsTranslucent;\n\
|
flat in uint polyIsWireframe;\n\
|
||||||
flat in uint polySetNewDepthForTranslucent;\n\
|
flat in uint polySetNewDepthForTranslucent;\n\
|
||||||
flat in uint polyMode;\n\
|
flat in uint polyMode;\n\
|
||||||
flat in uint polyID;\n\
|
flat in uint polyID;\n\
|
||||||
|
@ -274,7 +274,7 @@ static const char *GeometryFragShader_150 = {"\
|
||||||
newFragDepth = vec4(packVec3FromFloat(newFragDepthValue), 1.0);\n\
|
newFragDepth = vec4(packVec3FromFloat(newFragDepthValue), 1.0);\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
newPolyID = vec4(float(polyID)/63.0, 0.0, 0.0, float(newFragColor.a > 0.999));\n\
|
newPolyID = vec4( float(polyID)/63.0, float(polyIsWireframe == 1u), 0.0, float(newFragColor.a > 0.999) );\n\
|
||||||
newFogAttributes = vec4( float(polyEnableFog), 0.0, 0.0, float((newFragColor.a > 0.999) ? 1.0 : 0.5) );\n\
|
newFogAttributes = vec4( float(polyEnableFog), 0.0, 0.0, float((newFragColor.a > 0.999) ? 1.0 : 0.5) );\n\
|
||||||
}\n\
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
|
@ -365,12 +365,26 @@ static const char *EdgeMarkFragShader_150 = {"\
|
||||||
\n\
|
\n\
|
||||||
void main()\n\
|
void main()\n\
|
||||||
{\n\
|
{\n\
|
||||||
|
vec4 polyIDInfo[5];\n\
|
||||||
|
polyIDInfo[0] = texture(texInPolyID, texCoord[0]);\n\
|
||||||
|
polyIDInfo[1] = texture(texInPolyID, texCoord[1]);\n\
|
||||||
|
polyIDInfo[2] = texture(texInPolyID, texCoord[2]);\n\
|
||||||
|
polyIDInfo[3] = texture(texInPolyID, texCoord[3]);\n\
|
||||||
|
polyIDInfo[4] = texture(texInPolyID, texCoord[4]);\n\
|
||||||
|
\n\
|
||||||
int polyID[5];\n\
|
int polyID[5];\n\
|
||||||
polyID[0] = int((texture(texInPolyID, texCoord[0]).r * 63.0) + 0.5);\n\
|
polyID[0] = int((polyIDInfo[0].r * 63.0) + 0.5);\n\
|
||||||
polyID[1] = int((texture(texInPolyID, texCoord[1]).r * 63.0) + 0.5);\n\
|
polyID[1] = int((polyIDInfo[1].r * 63.0) + 0.5);\n\
|
||||||
polyID[2] = int((texture(texInPolyID, texCoord[2]).r * 63.0) + 0.5);\n\
|
polyID[2] = int((polyIDInfo[2].r * 63.0) + 0.5);\n\
|
||||||
polyID[3] = int((texture(texInPolyID, texCoord[3]).r * 63.0) + 0.5);\n\
|
polyID[3] = int((polyIDInfo[3].r * 63.0) + 0.5);\n\
|
||||||
polyID[4] = int((texture(texInPolyID, texCoord[4]).r * 63.0) + 0.5);\n\
|
polyID[4] = int((polyIDInfo[4].r * 63.0) + 0.5);\n\
|
||||||
|
\n\
|
||||||
|
bool isWireframe[5];\n\
|
||||||
|
isWireframe[0] = bool(polyIDInfo[0].g);\n\
|
||||||
|
isWireframe[1] = bool(polyIDInfo[1].g);\n\
|
||||||
|
isWireframe[2] = bool(polyIDInfo[2].g);\n\
|
||||||
|
isWireframe[3] = bool(polyIDInfo[3].g);\n\
|
||||||
|
isWireframe[4] = bool(polyIDInfo[4].g);\n\
|
||||||
\n\
|
\n\
|
||||||
float depth[5];\n\
|
float depth[5];\n\
|
||||||
depth[0] = unpackFloatFromVec3(texture(texInFragDepth, texCoord[0]).rgb);\n\
|
depth[0] = unpackFloatFromVec3(texture(texInFragDepth, texCoord[0]).rgb);\n\
|
||||||
|
@ -381,14 +395,17 @@ static const char *EdgeMarkFragShader_150 = {"\
|
||||||
\n\
|
\n\
|
||||||
vec4 newEdgeColor = vec4(0.0, 0.0, 0.0, 0.0);\n\
|
vec4 newEdgeColor = vec4(0.0, 0.0, 0.0, 0.0);\n\
|
||||||
\n\
|
\n\
|
||||||
|
if (!isWireframe[0])\n\
|
||||||
|
{\n\
|
||||||
for (int i = 1; i < 5; i++)\n\
|
for (int i = 1; i < 5; i++)\n\
|
||||||
{\n\
|
{\n\
|
||||||
if (polyID[0] != polyID[i] && depth[0] >= depth[i])\n\
|
if ( (polyID[0] != polyID[i]) && (depth[0] >= depth[i]) && !isWireframe[i] )\n\
|
||||||
{\n\
|
{\n\
|
||||||
newEdgeColor = state.edgeColor[polyID[i]/8];\n\
|
newEdgeColor = state.edgeColor[polyID[i]/8];\n\
|
||||||
break;\n\
|
break;\n\
|
||||||
}\n\
|
}\n\
|
||||||
}\n\
|
}\n\
|
||||||
|
}\n\
|
||||||
\n\
|
\n\
|
||||||
outFragColor = newEdgeColor;\n\
|
outFragColor = newEdgeColor;\n\
|
||||||
}\n\
|
}\n\
|
||||||
|
@ -1465,7 +1482,7 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D &engine)
|
||||||
|
|
||||||
polyStates[i].enableTexture = (this->_textureList[i]->IsSamplingEnabled()) ? GL_TRUE : GL_FALSE;
|
polyStates[i].enableTexture = (this->_textureList[i]->IsSamplingEnabled()) ? GL_TRUE : GL_FALSE;
|
||||||
polyStates[i].enableFog = (polyAttr.enableRenderFog) ? GL_TRUE : GL_FALSE;
|
polyStates[i].enableFog = (polyAttr.enableRenderFog) ? GL_TRUE : GL_FALSE;
|
||||||
polyStates[i].isTranslucent = (polyAttr.isTranslucent && !((polyAttr.polygonMode == POLYGON_MODE_DECAL) && polyAttr.isOpaque)) ? GL_TRUE : GL_FALSE;
|
polyStates[i].isWireframe = (polyAttr.isWireframe) ? GL_TRUE : GL_FALSE;
|
||||||
polyStates[i].setNewDepthForTranslucent = (polyAttr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE;
|
polyStates[i].setNewDepthForTranslucent = (polyAttr.enableAlphaDepthWrite) ? GL_TRUE : GL_FALSE;
|
||||||
polyStates[i].polyAlpha = (polyAttr.isWireframe) ? 0x1F : polyAttr.alpha;
|
polyStates[i].polyAlpha = (polyAttr.isWireframe) ? 0x1F : polyAttr.alpha;
|
||||||
polyStates[i].polyMode = polyAttr.polygonMode;
|
polyStates[i].polyMode = polyAttr.polygonMode;
|
||||||
|
|
Loading…
Reference in New Issue