Browse Source

Fix FXAA3 shader on OpenGL 3. Add non-deprecated aliases for texture2DLod in Samplers.glsl. Thanks to Gunnar Kriik.

Lasse Öörni 10 years ago
parent
commit
368cd56955
2 changed files with 16 additions and 1 deletions
  1. 14 1
      bin/CoreData/Shaders/GLSL/FXAA3.glsl
  2. 2 0
      bin/CoreData/Shaders/GLSL/Samplers.glsl

+ 14 - 1
bin/CoreData/Shaders/GLSL/FXAA3.glsl

@@ -314,8 +314,19 @@ float CalcLuma(vec3 rgb)
 
 /*--------------------------------------------------------------------------*/
 
-#define FxaaTexTop(t, p) vec4(texture2DLod(t, p, 0.0).rgb, 1.0)
+#ifdef GL3
+
+#define FxaaTexTop(t, p) vec4(textureLod(t, p, 0.0).rgb, 1.0)
+#define LumaTop(t, p) CalcLuma(textureLod(t, p, 0.0).rgb)
+#if (FXAA_FAST_PIXEL_OFFSET == 1)
+    #define LumaOff(t, p, o, r) CalcLuma(textureLodOffset(t, p, 0.0, o).rgb)
+#else
+    #define LumaOff(t, p, o, r) CalcLuma(textureLod(t, p + (o * r), 0.0).rgb)
+#endif
 
+#else
+
+#define FxaaTexTop(t, p) vec4(texture2DLod(t, p, 0.0).rgb, 1.0)
 #define LumaTop(t, p) CalcLuma(texture2DLod(t, p, 0.0).rgb)
 #if (FXAA_FAST_PIXEL_OFFSET == 1)
     #define LumaOff(t, p, o, r) CalcLuma(texture2DLodOffset(t, p, 0.0, o).rgb)
@@ -323,6 +334,8 @@ float CalcLuma(vec3 rgb)
     #define LumaOff(t, p, o, r) CalcLuma(texture2DLod(t, p + (o * r), 0.0).rgb)
 #endif
 
+#endif
+
 /*============================================================================
 
                              FXAA3 QUALITY - PC

+ 2 - 0
bin/CoreData/Shaders/GLSL/Samplers.glsl

@@ -29,6 +29,8 @@ uniform samplerCube sLightCubeMap;
 #define texture2DProj textureProj
 #define texture3D texture
 #define textureCube texture
+#define texture2DLod textureLod
+#define texture2DLodOffset textureLodOffset
 #endif
 
 vec3 DecodeNormal(vec4 normalInput)