OpenGL Renderer: Fix rendering on very very very old GPUs, such as the ATi Mobility X1600 (circa 2006).
- This change basically returns us to using 1D textures for color LUTs instead of using uniform arrays. 1D textures seem to be more compatible for most older hardware. - Unfortunately, while most older GPUs will work better with this change, this may break the OpenGL renderer on even older GPUs, such as the GeForce 7800 GT (circa 2005). - I'm estimating that more old GPUs benefit from this change than not, and so using 1D textures is what will stand. The vast majority of users will be using hardware newer than this, and so anyone who can't run OpenGL renderer in 2022 can just switch to SoftRasterizer.
This commit is contained in:
parent
45a2f424e6
commit
ab38d17fea
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2021 DeSmuME team
|
||||
Copyright (C) 2008-2022 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -354,9 +354,9 @@ varying vec4 vtxColor;\n\
|
|||
varying float isPolyDrawable;\n\
|
||||
\n\
|
||||
uniform sampler2D texRenderObject;\n\
|
||||
uniform sampler1D texToonTable;\n\
|
||||
\n\
|
||||
uniform float stateAlphaTestRef;\n\
|
||||
uniform vec4 stateToonColor[32];\n\
|
||||
\n\
|
||||
uniform int polyMode;\n\
|
||||
uniform bool polyIsWireframe;\n\
|
||||
|
@ -387,6 +387,7 @@ void main()\n\
|
|||
#endif\n\
|
||||
\n\
|
||||
vec4 mainTexColor = (ENABLE_TEXTURE_SAMPLING && polyEnableTexture) ? texture2D(texRenderObject, vtxTexCoord) : vec4(1.0, 1.0, 1.0, 1.0);\n\
|
||||
vec3 newToonColor = texture1D(texToonTable, vtxColor.r).rgb;\n\
|
||||
\n\
|
||||
if (!texSingleBitAlpha)\n\
|
||||
{\n\
|
||||
|
@ -419,7 +420,6 @@ void main()\n\
|
|||
}\n\
|
||||
else if (polyMode == 2)\n\
|
||||
{\n\
|
||||
vec3 newToonColor = stateToonColor[int((vtxColor.r * 31.0) + 0.5)].rgb;\n\
|
||||
#if TOON_SHADING_MODE\n\
|
||||
newFragColor.rgb = min((mainTexColor.rgb * vtxColor.r) + newToonColor.rgb, 1.0);\n\
|
||||
#else\n\
|
||||
|
@ -436,7 +436,7 @@ void main()\n\
|
|||
discard;\n\
|
||||
}\n\
|
||||
\n\
|
||||
gl_FragData[0] = newFragColor;\n\
|
||||
OUTFRAGCOLOR = newFragColor;\n\
|
||||
\n\
|
||||
#if ENABLE_EDGE_MARK\n\
|
||||
gl_FragData[ATTACHMENT_POLY_ID] = (isPolyDrawable > 0.0) ? vec4( float(polyID)/63.0, float(polyIsWireframe), 0.0, float(newFragColor.a > 0.999) ) : vec4(0.0, 0.0, 0.0, 0.0);\n\
|
||||
|
@ -519,8 +519,8 @@ varying vec2 texCoord[5];\n\
|
|||
\n\
|
||||
uniform sampler2D texInFragDepth;\n\
|
||||
uniform sampler2D texInPolyID;\n\
|
||||
uniform sampler1D texEdgeColor;\n\
|
||||
\n\
|
||||
uniform vec4 stateEdgeColor[8];\n\
|
||||
uniform int clearPolyID;\n\
|
||||
uniform float clearDepth;\n\
|
||||
\n\
|
||||
|
@ -533,6 +533,13 @@ void main()\n\
|
|||
polyIDInfo[3] = texture2D(texInPolyID, texCoord[3]);\n\
|
||||
polyIDInfo[4] = texture2D(texInPolyID, texCoord[4]);\n\
|
||||
\n\
|
||||
vec4 edgeColor[5];\n\
|
||||
edgeColor[0] = texture1D(texEdgeColor, polyIDInfo[0].r);\n\
|
||||
edgeColor[1] = texture1D(texEdgeColor, polyIDInfo[1].r);\n\
|
||||
edgeColor[2] = texture1D(texEdgeColor, polyIDInfo[2].r);\n\
|
||||
edgeColor[3] = texture1D(texEdgeColor, polyIDInfo[3].r);\n\
|
||||
edgeColor[4] = texture1D(texEdgeColor, polyIDInfo[4].r);\n\
|
||||
\n\
|
||||
bool isWireframe[5];\n\
|
||||
isWireframe[0] = bool(polyIDInfo[0].g);\n\
|
||||
\n\
|
||||
|
@ -565,49 +572,49 @@ void main()\n\
|
|||
{\n\
|
||||
if (gl_FragCoord.x >= FRAMEBUFFER_SIZE_X-1.0)\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[0]/8];\n\
|
||||
newEdgeColor = edgeColor[0];\n\
|
||||
}\n\
|
||||
else\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[1]/8];\n\
|
||||
newEdgeColor = edgeColor[1];\n\
|
||||
}\n\
|
||||
}\n\
|
||||
else if ( ((gl_FragCoord.y >= FRAMEBUFFER_SIZE_Y-1.0) ? isEdgeMarkingClearValues : ((polyID[0] != polyID[2]) && (depth[0] >= depth[2]) && !isWireframe[2])) )\n\
|
||||
{\n\
|
||||
if (gl_FragCoord.y >= FRAMEBUFFER_SIZE_Y-1.0)\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[0]/8];\n\
|
||||
newEdgeColor = edgeColor[0];\n\
|
||||
}\n\
|
||||
else\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[2]/8];\n\
|
||||
newEdgeColor = edgeColor[2];\n\
|
||||
}\n\
|
||||
}\n\
|
||||
else if ( ((gl_FragCoord.x < 1.0) ? isEdgeMarkingClearValues : ((polyID[0] != polyID[3]) && (depth[0] >= depth[3]) && !isWireframe[3])) )\n\
|
||||
{\n\
|
||||
if (gl_FragCoord.x < 1.0)\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[0]/8];\n\
|
||||
newEdgeColor = edgeColor[0];\n\
|
||||
}\n\
|
||||
else\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[3]/8];\n\
|
||||
newEdgeColor = edgeColor[3];\n\
|
||||
}\n\
|
||||
}\n\
|
||||
else if ( ((gl_FragCoord.y < 1.0) ? isEdgeMarkingClearValues : ((polyID[0] != polyID[4]) && (depth[0] >= depth[4]) && !isWireframe[4])) )\n\
|
||||
{\n\
|
||||
if (gl_FragCoord.y < 1.0)\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[0]/8];\n\
|
||||
newEdgeColor = edgeColor[0];\n\
|
||||
}\n\
|
||||
else\n\
|
||||
{\n\
|
||||
newEdgeColor = stateEdgeColor[polyID[4]/8];\n\
|
||||
newEdgeColor = edgeColor[4];\n\
|
||||
}\n\
|
||||
}\n\
|
||||
}\n\
|
||||
\n\
|
||||
gl_FragData[0] = newEdgeColor;\n\
|
||||
gl_FragColor = newEdgeColor;\n\
|
||||
}\n\
|
||||
"};
|
||||
|
||||
|
@ -658,7 +665,7 @@ void main()\n\
|
|||
newFoggedColor = mix(inFragColor, (stateEnableFogAlphaOnly) ? vec4(inFragColor.rgb, stateFogColor.a) : stateFogColor, fogMixWeight);\n\
|
||||
}\n\
|
||||
\n\
|
||||
gl_FragData[0] = newFoggedColor;\n\
|
||||
gl_FragColor = newFoggedColor;\n\
|
||||
}\n\
|
||||
"};
|
||||
|
||||
|
@ -690,7 +697,7 @@ void main()\n\
|
|||
colorRGBA6665.rgb = floor(colorRGBA6665.rgb / 4.0);\n\
|
||||
colorRGBA6665.a = floor(colorRGBA6665.a / 8.0);\n\
|
||||
\n\
|
||||
gl_FragData[0] = (colorRGBA6665 / 255.0);\n\
|
||||
gl_FragColor = (colorRGBA6665 / 255.0);\n\
|
||||
}\n\
|
||||
"};
|
||||
|
||||
|
@ -704,7 +711,7 @@ void main()\n\
|
|||
{\n\
|
||||
// Note that we swap B and R since pixel readbacks are done in BGRA format for fastest\n\
|
||||
// performance. The final color is still in RGBA format.\n\
|
||||
gl_FragData[0] = texture2D(texInFragColor, texCoord).bgra;\n\
|
||||
gl_FragColor = texture2D(texInFragColor, texCoord).bgra;\n\
|
||||
}\n\
|
||||
"};
|
||||
|
||||
|
@ -1140,6 +1147,7 @@ OpenGLRenderer::OpenGLRenderer()
|
|||
isMultisampledFBOSupported = false;
|
||||
isShaderSupported = false;
|
||||
isVAOSupported = false;
|
||||
_isDepthLEqualPolygonFacingSupported = false;
|
||||
willFlipOnlyFramebufferOnGPU = false;
|
||||
willFlipAndConvertFramebufferOnGPU = false;
|
||||
willUsePerSampleZeroDstPass = false;
|
||||
|
@ -2039,7 +2047,7 @@ Render3DError OpenGLRenderer::DrawAlphaTexturePolygon(const GLenum polyPrimitive
|
|||
else if (DRAWMODE != OGLPolyDrawMode_DrawOpaquePolys)
|
||||
{
|
||||
// Draw the translucent fragments.
|
||||
if (this->_emulateDepthLEqualPolygonFacing && isPolyFrontFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported && isPolyFrontFacing)
|
||||
{
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glUniform1i(OGLRef.uniformDrawModeDepthEqualsTest[this->_geometryProgramFlags.value], GL_TRUE);
|
||||
|
@ -2061,7 +2069,7 @@ Render3DError OpenGLRenderer::DrawAlphaTexturePolygon(const GLenum polyPrimitive
|
|||
}
|
||||
|
||||
glUniform1i(OGLRef.uniformTexDrawOpaque[this->_geometryProgramFlags.value], GL_TRUE);
|
||||
if (this->_emulateDepthLEqualPolygonFacing && isPolyFrontFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported && isPolyFrontFacing)
|
||||
{
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glUniform1i(OGLRef.uniformDrawModeDepthEqualsTest[this->_geometryProgramFlags.value], GL_TRUE);
|
||||
|
@ -2085,7 +2093,7 @@ Render3DError OpenGLRenderer::DrawAlphaTexturePolygon(const GLenum polyPrimitive
|
|||
{
|
||||
glUniform1i(OGLRef.uniformTexDrawOpaque[this->_geometryProgramFlags.value], GL_TRUE);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported)
|
||||
{
|
||||
if (isPolyFrontFacing)
|
||||
{
|
||||
|
@ -2211,7 +2219,7 @@ Render3DError OpenGLRenderer::DrawOtherPolygon(const GLenum polyPrimitive,
|
|||
}
|
||||
else if (DRAWMODE == OGLPolyDrawMode_DrawOpaquePolys)
|
||||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported)
|
||||
{
|
||||
if (isPolyFrontFacing)
|
||||
{
|
||||
|
@ -2248,7 +2256,7 @@ Render3DError OpenGLRenderer::DrawOtherPolygon(const GLenum polyPrimitive,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing && isPolyFrontFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported && isPolyFrontFacing)
|
||||
{
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glUniform1i(OGLRef.uniformDrawModeDepthEqualsTest[this->_geometryProgramFlags.value], GL_TRUE);
|
||||
|
@ -2270,12 +2278,12 @@ Render3DError OpenGLRenderer::ApplyRenderingSettings(const GFX3D_State &renderSt
|
|||
const bool didSelectedMultisampleSizeChange = (this->_selectedMultisampleSize != CommonSettings.GFX3D_Renderer_MultisampleSize);
|
||||
const bool didEmulateNDSDepthCalculationChange = (this->_emulateNDSDepthCalculation != CommonSettings.OpenGL_Emulation_NDSDepthCalculation);
|
||||
const bool didEnableTextureSmoothingChange = (this->_enableTextureSmoothing != CommonSettings.GFX3D_Renderer_TextureSmoothing);
|
||||
const bool didEmulateDepthLEqualPolygonFacingChange = (this->_emulateDepthLEqualPolygonFacing != (CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing && this->isShaderSupported));
|
||||
const bool didEmulateDepthLEqualPolygonFacingChange = (this->_emulateDepthLEqualPolygonFacing != (CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported));
|
||||
|
||||
this->_emulateShadowPolygon = CommonSettings.OpenGL_Emulation_ShadowPolygon;
|
||||
this->_emulateSpecialZeroAlphaBlending = CommonSettings.OpenGL_Emulation_SpecialZeroAlphaBlending;
|
||||
this->_emulateNDSDepthCalculation = CommonSettings.OpenGL_Emulation_NDSDepthCalculation;
|
||||
this->_emulateDepthLEqualPolygonFacing = CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing && this->isShaderSupported;
|
||||
this->_emulateDepthLEqualPolygonFacing = CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported;
|
||||
|
||||
this->_selectedMultisampleSize = CommonSettings.GFX3D_Renderer_MultisampleSize;
|
||||
this->_enableMultisampledRendering = ((this->_selectedMultisampleSize >= 2) && this->isMultisampledFBOSupported);
|
||||
|
@ -2396,79 +2404,18 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
|
|||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropyOGL);
|
||||
this->_deviceInfo.maxAnisotropy = maxAnisotropyOGL;
|
||||
|
||||
this->isShaderSupported = this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_shader_objects") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_shader") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_fragment_shader") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_program");
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
GLint maxColorAttachmentsOGL = 0;
|
||||
GLint maxDrawBuffersOGL = 0;
|
||||
GLint maxShaderTexUnitsOGL = 0;
|
||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachmentsOGL);
|
||||
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &maxDrawBuffersOGL);
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &maxShaderTexUnitsOGL);
|
||||
|
||||
if ( (maxColorAttachmentsOGL >= 4) && (maxDrawBuffersOGL >= 4) && (maxShaderTexUnitsOGL >= 8) )
|
||||
{
|
||||
this->_enableTextureSmoothing = CommonSettings.GFX3D_Renderer_TextureSmoothing;
|
||||
this->_emulateShadowPolygon = CommonSettings.OpenGL_Emulation_ShadowPolygon;
|
||||
this->_emulateSpecialZeroAlphaBlending = CommonSettings.OpenGL_Emulation_SpecialZeroAlphaBlending;
|
||||
this->_emulateNDSDepthCalculation = CommonSettings.OpenGL_Emulation_NDSDepthCalculation;
|
||||
this->_emulateDepthLEqualPolygonFacing = CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing;
|
||||
|
||||
error = this->CreateGeometryPrograms();
|
||||
if (error == OGLERROR_NOERR)
|
||||
{
|
||||
error = this->CreateGeometryZeroDstAlphaProgram(GeometryZeroDstAlphaPixelMaskVtxShader_100, GeometryZeroDstAlphaPixelMaskFragShader_100);
|
||||
if (error == OGLERROR_NOERR)
|
||||
{
|
||||
INFO("OpenGL: Successfully created geometry shaders.\n");
|
||||
|
||||
error = this->InitPostprocessingPrograms(EdgeMarkVtxShader_100,
|
||||
EdgeMarkFragShader_100,
|
||||
FramebufferOutputVtxShader_100,
|
||||
FramebufferOutputRGBA6665FragShader_100,
|
||||
FramebufferOutputRGBA8888FragShader_100);
|
||||
}
|
||||
}
|
||||
|
||||
if (error != OGLERROR_NOERR)
|
||||
{
|
||||
glUseProgram(0);
|
||||
this->DestroyGeometryPrograms();
|
||||
this->DestroyGeometryZeroDstAlphaProgram();
|
||||
this->isShaderSupported = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO("OpenGL: Driver does not support at least 4 color attachments, 4 draw buffers, and 8 texture image units.\n");
|
||||
this->isShaderSupported = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
glGenTextures(1, &OGLRef.texFinalColorID);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_FinalColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texFinalColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_framebufferWidth, this->_framebufferHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO("OpenGL: Shaders are unsupported. Disabling shaders and using fixed-function pipeline. Some emulation features will be disabled.\n");
|
||||
|
||||
if (this->IsVersionSupported(2, 0, 0))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
// Need to generate this texture first because FBO creation needs it.
|
||||
// This texture is only required by shaders, and so if shader creation
|
||||
// fails, then we can immediately delete this texture if an error occurs.
|
||||
glGenTextures(1, &OGLRef.texFinalColorID);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_FinalColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texFinalColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_framebufferWidth, this->_framebufferHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
this->isVBOSupported = this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_buffer_object");
|
||||
if (this->isVBOSupported)
|
||||
|
@ -2484,6 +2431,14 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
|
|||
}
|
||||
}
|
||||
|
||||
this->isVAOSupported = this->isVBOSupported &&
|
||||
(this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_array_object") ||
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_APPLE_vertex_array_object"));
|
||||
if (this->isVAOSupported)
|
||||
{
|
||||
this->CreateVAOs();
|
||||
}
|
||||
|
||||
this->isPBOSupported = this->isVBOSupported &&
|
||||
(this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_pixel_buffer_object") ||
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_EXT_pixel_buffer_object"));
|
||||
|
@ -2500,15 +2455,6 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
|
|||
}
|
||||
}
|
||||
|
||||
this->isVAOSupported = this->isShaderSupported &&
|
||||
this->isVBOSupported &&
|
||||
(this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_array_object") ||
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_APPLE_vertex_array_object"));
|
||||
if (this->isVAOSupported)
|
||||
{
|
||||
this->CreateVAOs();
|
||||
}
|
||||
|
||||
// Don't use ARB versions since we're using the EXT versions for backwards compatibility.
|
||||
this->isFBOSupported = this->IsExtensionPresent(&oglExtensionSet, "GL_EXT_framebuffer_object") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_EXT_framebuffer_blit") &&
|
||||
|
@ -2520,35 +2466,10 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
|
|||
|
||||
if (maxColorAttachments >= 4)
|
||||
{
|
||||
// This texture will be used as an FBO color attachment.
|
||||
// If this texture wasn't already created by passing the shader support check,
|
||||
// then create the texture now.
|
||||
bool createdTextureForFBO = false;
|
||||
if (OGLRef.texFinalColorID == 0)
|
||||
{
|
||||
glGenTextures(1, &OGLRef.texFinalColorID);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB + OGLTextureUnitID_FinalColor);
|
||||
glBindTexture(GL_TEXTURE_2D, OGLRef.texFinalColorID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->_framebufferWidth, this->_framebufferHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
createdTextureForFBO = true;
|
||||
}
|
||||
|
||||
error = this->CreateFBOs();
|
||||
if (error != OGLERROR_NOERR)
|
||||
{
|
||||
this->isFBOSupported = false;
|
||||
|
||||
if (createdTextureForFBO)
|
||||
{
|
||||
glDeleteTextures(1, &OGLRef.texFinalColorID);
|
||||
OGLRef.texFinalColorID = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2612,13 +2533,81 @@ Render3DError OpenGLRenderer_1_2::InitExtensions()
|
|||
INFO("OpenGL: Multisampled FBOs are unsupported. Multisample antialiasing will be disabled.\n");
|
||||
}
|
||||
|
||||
this->isShaderSupported = this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_shader_objects") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_shader") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_fragment_shader") &&
|
||||
this->IsExtensionPresent(&oglExtensionSet, "GL_ARB_vertex_program");
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
GLint maxColorAttachmentsOGL = 0;
|
||||
GLint maxDrawBuffersOGL = 0;
|
||||
GLint maxShaderTexUnitsOGL = 0;
|
||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &maxColorAttachmentsOGL);
|
||||
glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &maxDrawBuffersOGL);
|
||||
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &maxShaderTexUnitsOGL);
|
||||
|
||||
if ( (maxColorAttachmentsOGL >= 4) && (maxDrawBuffersOGL >= 4) && (maxShaderTexUnitsOGL >= 8) )
|
||||
{
|
||||
this->_enableTextureSmoothing = CommonSettings.GFX3D_Renderer_TextureSmoothing;
|
||||
this->_emulateShadowPolygon = CommonSettings.OpenGL_Emulation_ShadowPolygon;
|
||||
this->_emulateSpecialZeroAlphaBlending = CommonSettings.OpenGL_Emulation_SpecialZeroAlphaBlending;
|
||||
this->_emulateNDSDepthCalculation = CommonSettings.OpenGL_Emulation_NDSDepthCalculation;
|
||||
this->_emulateDepthLEqualPolygonFacing = CommonSettings.OpenGL_Emulation_DepthLEqualPolygonFacing;
|
||||
|
||||
error = this->CreateGeometryPrograms();
|
||||
if (error == OGLERROR_NOERR)
|
||||
{
|
||||
error = this->CreateGeometryZeroDstAlphaProgram(GeometryZeroDstAlphaPixelMaskVtxShader_100, GeometryZeroDstAlphaPixelMaskFragShader_100);
|
||||
if (error == OGLERROR_NOERR)
|
||||
{
|
||||
INFO("OpenGL: Successfully created geometry shaders.\n");
|
||||
|
||||
error = this->InitPostprocessingPrograms(EdgeMarkVtxShader_100,
|
||||
EdgeMarkFragShader_100,
|
||||
FramebufferOutputVtxShader_100,
|
||||
FramebufferOutputRGBA6665FragShader_100,
|
||||
FramebufferOutputRGBA8888FragShader_100);
|
||||
}
|
||||
}
|
||||
|
||||
if (error != OGLERROR_NOERR)
|
||||
{
|
||||
glUseProgram(0);
|
||||
this->DestroyGeometryPrograms();
|
||||
this->DestroyGeometryZeroDstAlphaProgram();
|
||||
this->isShaderSupported = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO("OpenGL: Driver does not support at least 4 color attachments, 4 draw buffers, and 8 texture image units.\n");
|
||||
this->isShaderSupported = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->isShaderSupported)
|
||||
{
|
||||
INFO("OpenGL: Shaders are unsupported. Disabling shaders and using fixed-function pipeline. Some emulation features will be disabled.\n");
|
||||
|
||||
glDeleteTextures(1, &OGLRef.texFinalColorID);
|
||||
OGLRef.texFinalColorID = 0;
|
||||
|
||||
if (this->IsVersionSupported(2, 0, 0))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Set rendering support flags based on driver features.
|
||||
this->willFlipAndConvertFramebufferOnGPU = this->isShaderSupported && this->isVBOSupported;
|
||||
this->willFlipOnlyFramebufferOnGPU = this->willFlipAndConvertFramebufferOnGPU || this->isFBOSupported;
|
||||
this->_deviceInfo.isEdgeMarkSupported = (this->isShaderSupported && this->isVBOSupported && this->isFBOSupported);
|
||||
this->_deviceInfo.isFogSupported = (this->isShaderSupported && this->isVBOSupported && this->isFBOSupported);
|
||||
this->_deviceInfo.isEdgeMarkSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
|
||||
this->_deviceInfo.isFogSupported = this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
|
||||
this->_deviceInfo.isTextureSmoothingSupported = this->isShaderSupported;
|
||||
|
||||
// We're requiring OpenGL v2.1 for this feature because it relies on gl_FrontFacing, which may not be supported on v2.0 drivers.
|
||||
this->_isDepthLEqualPolygonFacingSupported = this->IsVersionSupported(2, 1, 0) && this->isShaderSupported && this->isVBOSupported && this->isFBOSupported;
|
||||
|
||||
this->_enableMultisampledRendering = ((this->_selectedMultisampleSize >= 2) && this->isMultisampledFBOSupported);
|
||||
|
||||
this->InitFinalRenderStates(&oglExtensionSet); // This must be done last
|
||||
|
@ -3005,8 +2994,24 @@ Render3DError OpenGLRenderer_1_2::CreateGeometryPrograms()
|
|||
Render3DError error = OGLERROR_NOERR;
|
||||
OGLRenderRef &OGLRef = *this->ref;
|
||||
|
||||
glGenTextures(1, &OGLRef.texToonTableID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texToonTableID);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 32, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
||||
|
||||
glGenTextures(1, &OGLRef.texEdgeColorTableID);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texEdgeColorTableID);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, 8, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
|
||||
glGenTextures(1, &OGLRef.texFogDensityTableID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogDensityTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texFogDensityTableID);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
@ -3028,21 +3033,23 @@ Render3DError OpenGLRenderer_1_2::CreateGeometryPrograms()
|
|||
fragShaderHeader << "#define FRAMEBUFFER_SIZE_X " << this->_framebufferWidth << ".0 \n";
|
||||
fragShaderHeader << "#define FRAMEBUFFER_SIZE_Y " << this->_framebufferHeight << ".0 \n";
|
||||
fragShaderHeader << "\n";
|
||||
fragShaderHeader << "#define OUTFRAGCOLOR " << ((this->isFBOSupported) ? "gl_FragData[0]" : "gl_FragColor") << "\n";
|
||||
fragShaderHeader << "\n";
|
||||
|
||||
for (size_t flagsValue = 0; flagsValue < 128; flagsValue++, programFlags.value++)
|
||||
{
|
||||
std::stringstream shaderFlags;
|
||||
shaderFlags << "#define USE_TEXTURE_SMOOTHING " << ((this->_enableTextureSmoothing) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define USE_NDS_DEPTH_CALCULATION " << ((this->_emulateNDSDepthCalculation) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define USE_DEPTH_LEQUAL_POLYGON_FACING " << ((this->_emulateDepthLEqualPolygonFacing) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define USE_DEPTH_LEQUAL_POLYGON_FACING " << ((this->_emulateDepthLEqualPolygonFacing && this->IsVersionSupported(2, 1, 0) && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n";
|
||||
shaderFlags << "\n";
|
||||
shaderFlags << "#define ENABLE_W_DEPTH " << ((programFlags.EnableWDepth) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define ENABLE_ALPHA_TEST " << ((programFlags.EnableAlphaTest) ? "true\n" : "false\n");
|
||||
shaderFlags << "#define ENABLE_TEXTURE_SAMPLING " << ((programFlags.EnableTextureSampling) ? "true\n" : "false\n");
|
||||
shaderFlags << "#define TOON_SHADING_MODE " << ((programFlags.ToonShadingMode) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define ENABLE_FOG " << ((programFlags.EnableFog) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define ENABLE_EDGE_MARK " << ((programFlags.EnableEdgeMark) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define DRAW_MODE_OPAQUE " << ((programFlags.OpaqueDrawMode) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define ENABLE_FOG " << ((programFlags.EnableFog && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define ENABLE_EDGE_MARK " << ((programFlags.EnableEdgeMark && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n";
|
||||
shaderFlags << "#define DRAW_MODE_OPAQUE " << ((programFlags.OpaqueDrawMode && this->IsVersionSupported(2, 1, 0) && this->isVBOSupported && this->isFBOSupported) ? 1 : 0) << "\n";
|
||||
shaderFlags << "\n";
|
||||
shaderFlags << "#define ATTACHMENT_WORKING_BUFFER " << GeometryAttachmentWorkingBuffer[programFlags.DrawBuffersMode] << "\n";
|
||||
shaderFlags << "#define ATTACHMENT_POLY_ID " << GeometryAttachmentPolyID[programFlags.DrawBuffersMode] << "\n";
|
||||
|
@ -3083,14 +3090,16 @@ Render3DError OpenGLRenderer_1_2::CreateGeometryPrograms()
|
|||
const GLint uniformTexRenderObject = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "texRenderObject");
|
||||
glUniform1i(uniformTexRenderObject, 0);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing && !programFlags.OpaqueDrawMode)
|
||||
const GLint uniformTexToonTable = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "texToonTable");
|
||||
glUniform1i(uniformTexToonTable, OGLTextureUnitID_LookupTable);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported && !programFlags.OpaqueDrawMode)
|
||||
{
|
||||
const GLint uniformTexBackfacing = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "inBackFacing");
|
||||
glUniform1i(uniformTexBackfacing, OGLTextureUnitID_FinalColor);
|
||||
}
|
||||
|
||||
OGLRef.uniformStateAlphaTestRef[flagsValue] = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "stateAlphaTestRef");
|
||||
OGLRef.uniformStateToonColor[flagsValue] = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "stateToonColor");
|
||||
|
||||
OGLRef.uniformPolyTexScale[flagsValue] = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "polyTexScale");
|
||||
OGLRef.uniformPolyMode[flagsValue] = glGetUniformLocation(OGLRef.programGeometryID[flagsValue], "polyMode");
|
||||
|
@ -3140,6 +3149,12 @@ void OpenGLRenderer_1_2::DestroyGeometryPrograms()
|
|||
glDeleteShader(OGLRef.vertexGeometryShaderID);
|
||||
OGLRef.vertexGeometryShaderID = 0;
|
||||
|
||||
glDeleteTextures(1, &ref->texToonTableID);
|
||||
OGLRef.texToonTableID = 0;
|
||||
|
||||
glDeleteTextures(1, &ref->texEdgeColorTableID);
|
||||
OGLRef.texEdgeColorTableID = 0;
|
||||
|
||||
glDeleteTextures(1, &ref->texFogDensityTableID);
|
||||
OGLRef.texFogDensityTableID = 0;
|
||||
}
|
||||
|
@ -3256,12 +3271,13 @@ Render3DError OpenGLRenderer_1_2::CreateEdgeMarkProgram(const char *vtxShaderCSt
|
|||
|
||||
const GLint uniformTexGDepth = glGetUniformLocation(OGLRef.programEdgeMarkID, "texInFragDepth");
|
||||
const GLint uniformTexGPolyID = glGetUniformLocation(OGLRef.programEdgeMarkID, "texInPolyID");
|
||||
const GLint uniformTexEdgeColorTable = glGetUniformLocation(OGLRef.programEdgeMarkID, "texEdgeColor");
|
||||
glUniform1i(uniformTexGDepth, OGLTextureUnitID_DepthStencil);
|
||||
glUniform1i(uniformTexGPolyID, OGLTextureUnitID_GPolyID);
|
||||
glUniform1i(uniformTexEdgeColorTable, OGLTextureUnitID_LookupTable);
|
||||
|
||||
OGLRef.uniformStateClearPolyID = glGetUniformLocation(OGLRef.programEdgeMarkID, "clearPolyID");
|
||||
OGLRef.uniformStateClearDepth = glGetUniformLocation(OGLRef.programEdgeMarkID, "clearDepth");
|
||||
OGLRef.uniformStateEdgeColor = glGetUniformLocation(OGLRef.programEdgeMarkID, "stateEdgeColor");
|
||||
|
||||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
@ -3358,7 +3374,7 @@ Render3DError OpenGLRenderer_1_2::CreateFogProgram(const OGLFogProgramKey fogPro
|
|||
glUniform1i(uniformTexGColor, OGLTextureUnitID_GColor);
|
||||
glUniform1i(uniformTexGDepth, OGLTextureUnitID_DepthStencil);
|
||||
glUniform1i(uniformTexGFog, OGLTextureUnitID_FogAttr);
|
||||
glUniform1i(uniformTexFogDensityTable, OGLTextureUnitID_FogDensityTable);
|
||||
glUniform1i(uniformTexFogDensityTable, OGLTextureUnitID_LookupTable);
|
||||
|
||||
OGLRef.uniformStateEnableFogAlphaOnly = glGetUniformLocation(shaderID.program, "stateEnableFogAlphaOnly");
|
||||
OGLRef.uniformStateFogColor = glGetUniformLocation(shaderID.program, "stateFogColor");
|
||||
|
@ -3652,10 +3668,13 @@ Render3DError OpenGLRenderer_1_2::InitPostprocessingPrograms(const char *edgeMar
|
|||
Render3DError error = OGLERROR_NOERR;
|
||||
OGLRenderRef &OGLRef = *this->ref;
|
||||
|
||||
error = this->CreateEdgeMarkProgram(edgeMarkVtxShaderCString, edgeMarkFragShaderCString);
|
||||
if (error != OGLERROR_NOERR)
|
||||
if (this->isVBOSupported && this->isFBOSupported)
|
||||
{
|
||||
return error;
|
||||
error = this->CreateEdgeMarkProgram(edgeMarkVtxShaderCString, edgeMarkFragShaderCString);
|
||||
if (error != OGLERROR_NOERR)
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
error = this->CreateFramebufferOutput6665Program(0, framebufferOutputVtxShaderCString, framebufferOutputRGBA6665FragShaderCString);
|
||||
|
@ -3693,7 +3712,7 @@ Render3DError OpenGLRenderer_1_2::UploadClearImage(const u16 *__restrict colorBu
|
|||
OGLRenderRef &OGLRef = *this->ref;
|
||||
this->_clearImageIndex ^= 0x01;
|
||||
|
||||
if (this->isShaderSupported && this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
for (size_t i = 0; i < GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT; i++)
|
||||
{
|
||||
|
@ -3711,7 +3730,7 @@ Render3DError OpenGLRenderer_1_2::UploadClearImage(const u16 *__restrict colorBu
|
|||
|
||||
const bool didColorChange = (memcmp(OGLRef.workingCIColorBuffer, colorBuffer, GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(u16)) != 0);
|
||||
const bool didDepthStencilChange = (memcmp(OGLRef.workingCIDepthStencilBuffer[this->_clearImageIndex], OGLRef.workingCIDepthStencilBuffer[this->_clearImageIndex ^ 0x01], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(GLuint)) != 0);
|
||||
const bool didFogAttributesChange = this->_enableFog && this->isShaderSupported && (memcmp(OGLRef.workingCIFogAttributesBuffer[this->_clearImageIndex], OGLRef.workingCIFogAttributesBuffer[this->_clearImageIndex ^ 0x01], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(GLuint)) != 0);
|
||||
const bool didFogAttributesChange = this->_enableFog && this->_deviceInfo.isFogSupported && (memcmp(OGLRef.workingCIFogAttributesBuffer[this->_clearImageIndex], OGLRef.workingCIFogAttributesBuffer[this->_clearImageIndex ^ 0x01], GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * sizeof(GLuint)) != 0);
|
||||
|
||||
glActiveTextureARB(GL_TEXTURE0_ARB);
|
||||
|
||||
|
@ -3964,7 +3983,7 @@ void OpenGLRenderer_1_2::_ResolveWorkingBackFacing()
|
|||
{
|
||||
OGLRenderRef &OGLRef = *this->ref;
|
||||
|
||||
if (!this->_emulateDepthLEqualPolygonFacing || !this->isMultisampledFBOSupported || (OGLRef.selectedRenderingFBO != OGLRef.fboMSIntermediateRenderID))
|
||||
if (!this->_emulateDepthLEqualPolygonFacing || !this->_isDepthLEqualPolygonFacingSupported || !this->isMultisampledFBOSupported || (OGLRef.selectedRenderingFBO != OGLRef.fboMSIntermediateRenderID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3998,14 +4017,14 @@ void OpenGLRenderer_1_2::_ResolveGeometry()
|
|||
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
if (this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
glReadBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glBlitFramebufferEXT(0, 0, this->_framebufferWidth, this->_framebufferHeight, 0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
|
@ -4276,18 +4295,7 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine)
|
|||
this->_pendingRenderStates.clearDepth = (GLfloat)this->_clearAttributes.depth / (GLfloat)0x00FFFFFF;
|
||||
this->_pendingRenderStates.alphaTestRef = divide5bitBy31_LUT[engine.renderState.alphaTestRef];
|
||||
|
||||
if (renderNeedsToonTable)
|
||||
{
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
this->_pendingRenderStates.toonColor[i].r = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] ) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].g = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] >> 5) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].b = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] >> 10) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].a = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->_deviceInfo.isFogSupported && this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
this->_fogProgramKey.key = 0;
|
||||
this->_fogProgramKey.offset = engine.renderState.fogOffset & 0x7FFF;
|
||||
|
@ -4306,20 +4314,24 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine)
|
|||
fogDensityTable[i] = (engine.renderState.fogDensityTable[i] == 127) ? 255 : engine.renderState.fogDensityTable[i] << 1;
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogDensityTable);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texFogDensityTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RED, GL_UNSIGNED_BYTE, fogDensityTable);
|
||||
}
|
||||
|
||||
if (this->_deviceInfo.isEdgeMarkSupported && this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
const GLfloat edgeColorAlpha = (engine.renderState.enableAntialiasing) ? (16.0f/31.0f) : 1.0f;
|
||||
const u8 alpha8 = (engine.renderState.enableAntialiasing) ? 0x80 : 0xFF;
|
||||
FragmentColor edgeColor32[8];
|
||||
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
this->_pendingRenderStates.edgeColor[i].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] ) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 5) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 10) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].a = edgeColorAlpha;
|
||||
edgeColor32[i].color = COLOR555TO8888(engine.renderState.edgeMarkColorTable[i] & 0x7FFF, alpha8);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texEdgeColorTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, edgeColor32);
|
||||
}
|
||||
|
||||
if (this->isShaderSupported)
|
||||
|
@ -4329,15 +4341,17 @@ Render3DError OpenGLRenderer_1_2::BeginRender(const GFX3D &engine)
|
|||
this->_geometryProgramFlags.EnableAlphaTest = (engine.renderState.enableAlphaTest) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableTextureSampling = (this->_enableTextureSampling) ? 1 : 0;
|
||||
this->_geometryProgramFlags.ToonShadingMode = (engine.renderState.shading) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableFog = (this->_enableFog) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableEdgeMark = (this->_enableEdgeMark) ? 1 : 0;
|
||||
this->_geometryProgramFlags.OpaqueDrawMode = 1;
|
||||
this->_geometryProgramFlags.EnableFog = (this->_enableFog && this->_deviceInfo.isFogSupported) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableEdgeMark = (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported) ? 1 : 0;
|
||||
this->_geometryProgramFlags.OpaqueDrawMode = (this->_isDepthLEqualPolygonFacingSupported) ? 1 : 0;
|
||||
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
|
||||
if (renderNeedsToonTable)
|
||||
{
|
||||
glUniform4fv(OGLRef.uniformStateToonColor[this->_geometryProgramFlags.value], 32, (const GLfloat *)&this->_pendingRenderStates.toonColor);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texToonTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, engine.renderState.u16ToonTable);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -4488,7 +4502,7 @@ Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer()
|
|||
return OGLERROR_NOERR;
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
if (this->_needsZeroDstAlphaPass && this->_emulateSpecialZeroAlphaBlending)
|
||||
{
|
||||
|
@ -4504,11 +4518,14 @@ Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer()
|
|||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
// Pass 2: Unblended edge mark colors to zero-alpha pixels
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texEdgeColorTableID);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glUseProgram(OGLRef.programEdgeMarkID);
|
||||
glUniform1i(OGLRef.uniformStateClearPolyID, this->_pendingRenderStates.clearPolyID);
|
||||
glUniform1f(OGLRef.uniformStateClearDepth, this->_pendingRenderStates.clearDepth);
|
||||
glUniform4fv(OGLRef.uniformStateEdgeColor, 8, (const GLfloat *)this->_pendingRenderStates.edgeColor);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||
glStencilFunc(GL_NOTEQUAL, 0x40, 0x40);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
@ -4521,10 +4538,13 @@ Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer()
|
|||
}
|
||||
else
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texEdgeColorTableID);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
glUseProgram(OGLRef.programEdgeMarkID);
|
||||
glUniform1i(OGLRef.uniformStateClearPolyID, this->_pendingRenderStates.clearPolyID);
|
||||
glUniform1f(OGLRef.uniformStateClearDepth, this->_pendingRenderStates.clearDepth);
|
||||
glUniform4fv(OGLRef.uniformStateEdgeColor, 8, (const GLfloat *)this->_pendingRenderStates.edgeColor);
|
||||
glDrawBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
|
@ -4533,8 +4553,12 @@ Render3DError OpenGLRenderer_1_2::PostprocessFramebuffer()
|
|||
}
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texFogDensityTableID);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
std::map<u32, OGLFogShaderID>::iterator it = this->_fogProgramMap.find(this->_fogProgramKey.key);
|
||||
if (it == this->_fogProgramMap.end())
|
||||
{
|
||||
|
@ -4609,21 +4633,21 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported)
|
||||
{
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
|
@ -4659,21 +4683,21 @@ Render3DError OpenGLRenderer_1_2::ClearUsingImage(const u16 *__restrict colorBuf
|
|||
|
||||
if (this->isShaderSupported)
|
||||
{
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported)
|
||||
{
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
glReadBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
|
@ -4721,21 +4745,21 @@ Render3DError OpenGLRenderer_1_2::ClearUsingValues(const FragmentColor &clearCol
|
|||
glClearStencil(clearAttributes.opaquePolyID);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
if (this->_emulateDepthLEqualPolygonFacing)
|
||||
if (this->_emulateDepthLEqualPolygonFacing && this->_isDepthLEqualPolygonFacingSupported)
|
||||
{
|
||||
glDrawBuffer(GL_WORKING_ATTACHMENT_ID);
|
||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
glDrawBuffer(GL_POLYID_ATTACHMENT_ID);
|
||||
glClearColor((GLfloat)clearAttributes.opaquePolyID/63.0f, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
glDrawBuffer(GL_FOGATTRIBUTES_ATTACHMENT_ID);
|
||||
glClearColor(clearAttributes.isFogged, 0.0, 0.0, 1.0);
|
||||
|
@ -5338,7 +5362,12 @@ Render3DError OpenGLRenderer_1_2::SetFramebufferSize(size_t w, size_t h)
|
|||
this->DestroyGeometryPrograms();
|
||||
|
||||
this->CreateGeometryPrograms();
|
||||
this->CreateEdgeMarkProgram(EdgeMarkVtxShader_100, EdgeMarkFragShader_100);
|
||||
|
||||
if (this->isVBOSupported && this->isFBOSupported)
|
||||
{
|
||||
this->CreateEdgeMarkProgram(EdgeMarkVtxShader_100, EdgeMarkFragShader_100);
|
||||
}
|
||||
|
||||
this->CreateFramebufferOutput6665Program(0, FramebufferOutputVtxShader_100, FramebufferOutputRGBA6665FragShader_100);
|
||||
this->CreateFramebufferOutput6665Program(1, FramebufferOutputVtxShader_100, FramebufferOutputRGBA6665FragShader_100);
|
||||
this->CreateFramebufferOutput8888Program(0, FramebufferOutputVtxShader_100, FramebufferOutputRGBA8888FragShader_100);
|
||||
|
@ -5504,18 +5533,7 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D &engine)
|
|||
this->_pendingRenderStates.clearDepth = (GLfloat)this->_clearAttributes.depth / (GLfloat)0x00FFFFFF;
|
||||
this->_pendingRenderStates.alphaTestRef = divide5bitBy31_LUT[engine.renderState.alphaTestRef];
|
||||
|
||||
if (renderNeedsToonTable)
|
||||
{
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
this->_pendingRenderStates.toonColor[i].r = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] ) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].g = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] >> 5) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].b = divide5bitBy31_LUT[(engine.renderState.u16ToonTable[i] >> 10) & 0x001F];
|
||||
this->_pendingRenderStates.toonColor[i].a = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (this->_deviceInfo.isFogSupported && this->_enableFog)
|
||||
if (this->_enableFog && this->_deviceInfo.isFogSupported)
|
||||
{
|
||||
this->_fogProgramKey.key = 0;
|
||||
this->_fogProgramKey.offset = engine.renderState.fogOffset & 0x7FFF;
|
||||
|
@ -5534,20 +5552,24 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D &engine)
|
|||
fogDensityTable[i] = (engine.renderState.fogDensityTable[i] == 127) ? 255 : engine.renderState.fogDensityTable[i] << 1;
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogDensityTable);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texFogDensityTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RED, GL_UNSIGNED_BYTE, fogDensityTable);
|
||||
}
|
||||
|
||||
if (this->_deviceInfo.isEdgeMarkSupported && this->_enableEdgeMark)
|
||||
if (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported)
|
||||
{
|
||||
const GLfloat edgeColorAlpha = (engine.renderState.enableAntialiasing) ? (16.0f/31.0f) : 1.0f;
|
||||
const u8 alpha8 = (engine.renderState.enableAntialiasing) ? 0x80 : 0xFF;
|
||||
FragmentColor edgeColor32[8];
|
||||
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
this->_pendingRenderStates.edgeColor[i].r = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] ) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].g = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 5) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].b = divide5bitBy31_LUT[(engine.renderState.edgeMarkColorTable[i] >> 10) & 0x001F];
|
||||
this->_pendingRenderStates.edgeColor[i].a = edgeColorAlpha;
|
||||
edgeColor32[i].color = COLOR555TO8888(engine.renderState.edgeMarkColorTable[i] & 0x7FFF, alpha8);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texEdgeColorTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, edgeColor32);
|
||||
}
|
||||
|
||||
// Setup render states
|
||||
|
@ -5556,15 +5578,17 @@ Render3DError OpenGLRenderer_2_0::BeginRender(const GFX3D &engine)
|
|||
this->_geometryProgramFlags.EnableAlphaTest = (engine.renderState.enableAlphaTest) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableTextureSampling = (this->_enableTextureSampling) ? 1 : 0;
|
||||
this->_geometryProgramFlags.ToonShadingMode = (engine.renderState.shading) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableFog = (this->_enableFog) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableEdgeMark = (this->_enableEdgeMark) ? 1 : 0;
|
||||
this->_geometryProgramFlags.OpaqueDrawMode = 1;
|
||||
this->_geometryProgramFlags.EnableFog = (this->_enableFog && this->_deviceInfo.isFogSupported) ? 1 : 0;
|
||||
this->_geometryProgramFlags.EnableEdgeMark = (this->_enableEdgeMark && this->_deviceInfo.isEdgeMarkSupported) ? 1 : 0;
|
||||
this->_geometryProgramFlags.OpaqueDrawMode = (this->_isDepthLEqualPolygonFacingSupported) ? 1 : 0;
|
||||
|
||||
this->_SetupGeometryShaders(this->_geometryProgramFlags);
|
||||
|
||||
if (renderNeedsToonTable)
|
||||
{
|
||||
glUniform4fv(OGLRef.uniformStateToonColor[this->_geometryProgramFlags.value], 32, (const GLfloat *)&this->_pendingRenderStates.toonColor);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texToonTableID);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, engine.renderState.u16ToonTable);
|
||||
}
|
||||
|
||||
glReadBuffer(GL_COLOROUT_ATTACHMENT_ID);
|
||||
|
|
|
@ -323,8 +323,8 @@ enum OGLTextureUnitID
|
|||
OGLTextureUnitID_DepthStencil,
|
||||
OGLTextureUnitID_GPolyID,
|
||||
OGLTextureUnitID_FogAttr,
|
||||
OGLTextureUnitID_PolyStates,
|
||||
OGLTextureUnitID_FogDensityTable
|
||||
OGLTextureUnitID_PolyStates,
|
||||
OGLTextureUnitID_LookupTable,
|
||||
};
|
||||
|
||||
enum OGLBindingPointID
|
||||
|
@ -523,6 +523,8 @@ struct OGLRenderRef
|
|||
GLuint texGDepthStencilID;
|
||||
GLuint texFinalColorID;
|
||||
GLuint texFogDensityTableID;
|
||||
GLuint texToonTableID;
|
||||
GLuint texEdgeColorTableID;
|
||||
GLuint texMSGColorID;
|
||||
GLuint texMSGWorkingID;
|
||||
|
||||
|
@ -564,11 +566,9 @@ struct OGLRenderRef
|
|||
GLint uniformStateEnableFogAlphaOnly;
|
||||
GLint uniformStateClearPolyID;
|
||||
GLint uniformStateClearDepth;
|
||||
GLint uniformStateEdgeColor;
|
||||
GLint uniformStateFogColor;
|
||||
|
||||
GLint uniformStateAlphaTestRef[256];
|
||||
GLint uniformStateToonColor[256];
|
||||
GLint uniformPolyTexScale[256];
|
||||
GLint uniformPolyMode[256];
|
||||
GLint uniformPolyIsWireframe[256];
|
||||
|
@ -721,6 +721,7 @@ protected:
|
|||
bool _emulateSpecialZeroAlphaBlending;
|
||||
bool _emulateNDSDepthCalculation;
|
||||
bool _emulateDepthLEqualPolygonFacing;
|
||||
bool _isDepthLEqualPolygonFacingSupported;
|
||||
|
||||
FragmentColor *_mappedFramebuffer;
|
||||
FragmentColor *_workingTextureUnpackBuffer;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2021 DeSmuME team
|
||||
Copyright (C) 2008-2022 DeSmuME team
|
||||
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -1187,7 +1187,7 @@ Render3DError OpenGLRenderer_3_2::CreateGeometryPrograms()
|
|||
}
|
||||
|
||||
glGenTextures(1, &OGLRef.texFogDensityTableID);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogDensityTable);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glBindTexture(GL_TEXTURE_1D, OGLRef.texFogDensityTableID);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
@ -1622,7 +1622,7 @@ Render3DError OpenGLRenderer_3_2::CreateFogProgram(const OGLFogProgramKey fogPro
|
|||
const GLint uniformTexFogDensityTable = glGetUniformLocation(shaderID.program, "texFogDensityTable");
|
||||
glUniform1i(uniformTexGDepth, OGLTextureUnitID_DepthStencil);
|
||||
glUniform1i(uniformTexGFog, OGLTextureUnitID_FogAttr);
|
||||
glUniform1i(uniformTexFogDensityTable, OGLTextureUnitID_FogDensityTable);
|
||||
glUniform1i(uniformTexFogDensityTable, OGLTextureUnitID_LookupTable);
|
||||
|
||||
if (!this->_isDualSourceBlendingSupported)
|
||||
{
|
||||
|
@ -2111,7 +2111,7 @@ Render3DError OpenGLRenderer_3_2::BeginRender(const GFX3D &engine)
|
|||
fogDensityTable[i] = (engine.renderState.fogDensityTable[i] == 127) ? 255 : engine.renderState.fogDensityTable[i] << 1;
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_FogDensityTable);
|
||||
glActiveTexture(GL_TEXTURE0 + OGLTextureUnitID_LookupTable);
|
||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 32, GL_RED, GL_UNSIGNED_BYTE, fogDensityTable);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue