Bladeren bron

Fixed OpenGL light prepass capability detection.
Fixed PackDepthRGB().

Lasse Öörni 14 jaren geleden
bovenliggende
commit
21c8926da3

+ 3 - 3
Engine/Graphics/OpenGL/OGLGraphics.cpp

@@ -254,10 +254,10 @@ bool Graphics::SetMode(int width, int height, bool fullscreen, bool vsync, bool
             return false;
         }
         
-        if (_GLEE_ARB_texture_float)
+        int numSupportedRTs = 1;
+        glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &numSupportedRTs);
+        if (numSupportedRTs >= 2)
             lightPrepassSupport_ = true;
-        else
-            lightPrepassSupport_ = false;
         
         // Set window close callback
         glfwSetWindowCloseCallback(CloseCallback);

+ 1 - 1
SourceAssets/GLSLShaders/GBuffer.frag

@@ -31,5 +31,5 @@ void main()
     float specPower = cMatSpecProperties.y / 255.0;
 
     gl_FragData[0] = vec4(normal * 0.5 + 0.5, specPower);
-    gl_FragData[1] = vec4(PackDepth(vTexCoord.z), 0.0);
+    gl_FragData[1] = vec4(PackDepthRGB(vTexCoord.z), 0.0);
 }

+ 2 - 2
SourceAssets/GLSLShaders/LightVolume.frag

@@ -16,7 +16,7 @@ void main()
 {
     // If rendering a directional light quad, optimize out the w divide
     #ifdef DIRLIGHT
-        float depth = UnpackDepth(texture2D(sDepthBuffer, vScreenPos).rgb);
+        float depth = UnpackDepthRGB(texture2D(sDepthBuffer, vScreenPos).rgb);
         #ifdef ORTHO
             vec3 worldPos = mix(vNearRay, vFarRay, depth);
         #else
@@ -24,7 +24,7 @@ void main()
         #endif
         vec4 normalInput = texture2D(sNormalBuffer, vScreenPos);
     #else
-        float depth = UnpackDepth(texture2DProj(sDepthBuffer, vScreenPos).rgb);
+        float depth = UnpackDepthRGB(texture2DProj(sDepthBuffer, vScreenPos).rgb);
         #ifdef ORTHO
             vec3 worldPos = mix(vNearRay, vFarRay, depth) / vScreenPos.w;
         #else

+ 6 - 6
SourceAssets/GLSLShaders/Samplers.frag

@@ -24,21 +24,21 @@ vec3 DecodeNormal(vec4 normalInput)
     return normal;
 }
 
-vec3 PackDepth(float depth)
+vec3 PackDepthRGB(float depth)
 {
     vec3 ret;
-    depth *= 255;
+    depth *= 255.0;
     ret.x = floor(depth);
-    depth = (depth - ret.x) * 255;
+    depth = (depth - ret.x) * 255.0;
     ret.y = floor(depth);
     ret.z = (depth - ret.y);
-    ret.xy *= 1.0 / 255;
+    ret.xy *= 1.0 / 255.0;
     return ret;
 }
 
-float UnpackDepth(vec3 depth)
+float UnpackDepthRGB(vec3 depth)
 {
-    const vec3 dotValues = vec3(1.0, 1.0 / 255, 1.0 / (255 * 255));
+    const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
     return dot(depth, dotValues);
 }