summaryrefslogtreecommitdiff
path: root/drivers/gles2/shaders
diff options
context:
space:
mode:
authorsantouits <santouits@users.noreply.github.com>2019-01-22 00:42:26 +0200
committersantouits <santouits@users.noreply.github.com>2019-01-22 13:40:28 +0200
commit3c1cd2873b772fbf82184fbf36e8ae891d9829cf (patch)
treea8495d2691512e0b40ab4ed126f620392df72bbb /drivers/gles2/shaders
parent0b0dba38c766a06f169fb492cc6f8c7c3e444de5 (diff)
WebGL1 some changes
glRenderBufferStorage doesn't accept the _DEPTH_COMPONENT24_OES so I changed it to GL_DEPTH_COMPONENT16 https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/renderbufferStorage https://www.khronos.org/registry/webgl/extensions/rejected/OES_depth24/ Enabled ext_shader_texture_lod extension. I guess it does the same like the GL_ARB_shader_texture_lod extension, but in WebGL1 https://www.khronos.org/registry/webgl/extensions/EXT_shader_texture_lod/ And last WebGL1 doesn't allow indexes not constant, so I changed it into a loop reading this: https://stackoverflow.com/questions/19529690/index-expression-must-be-constant-webgl-glsl-error
Diffstat (limited to 'drivers/gles2/shaders')
-rw-r--r--drivers/gles2/shaders/cubemap_filter.glsl18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/gles2/shaders/cubemap_filter.glsl b/drivers/gles2/shaders/cubemap_filter.glsl
index 06274a7698..f551cdb52b 100644
--- a/drivers/gles2/shaders/cubemap_filter.glsl
+++ b/drivers/gles2/shaders/cubemap_filter.glsl
@@ -25,9 +25,17 @@ void main() {
/* clang-format off */
[fragment]
+#ifdef GL_EXT_shader_texture_lod
+#extension GL_EXT_shader_texture_lod : enable
+#define texture2DLod(img, coord, lod) texture2DLodEXT(img, coord, lod)
+#define textureCubeLod(img, coord, lod) textureCubeLodEXT(img, coord, lod)
+#endif
+
+#ifdef GL_ARB_shader_texture_lod
#extension GL_ARB_shader_texture_lod : enable
+#endif
-#ifndef GL_ARB_shader_texture_lod
+#if !defined(GL_EXT_shader_texture_lod) && !defined(GL_ARB_shader_texture_lod)
#define texture2DLod(img, coord, lod) texture2D(img, coord)
#define textureCubeLod(img, coord, lod) textureCube(img, coord)
#endif
@@ -118,7 +126,13 @@ vec3 texelCoordToVec(vec2 uv, int faceID) {
faceUvVectors[5][2] = vec3(0.0, 0.0, 1.0); // +z face
// out = u * s_faceUv[0] + v * s_faceUv[1] + s_faceUv[2].
- vec3 result = (faceUvVectors[faceID][0] * uv.x) + (faceUvVectors[faceID][1] * uv.y) + faceUvVectors[faceID][2];
+ vec3 result;
+ for (int i = 0; i < 6; i++) {
+ if (i == faceID) {
+ result = (faceUvVectors[i][0] * uv.x) + (faceUvVectors[i][1] * uv.y) + faceUvVectors[i][2];
+ break;
+ }
+ }
return normalize(result);
}