diff --git a/code/def_files/data/effects/batched-f.sdr b/code/def_files/data/effects/batched-f.sdr index 660787fe4e2..e46e5208afc 100644 --- a/code/def_files/data/effects/batched-f.sdr +++ b/code/def_files/data/effects/batched-f.sdr @@ -1,12 +1,16 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2DArray; +#endif #include "gamma.sdr" +layout(location=0) out vec4 fragOut0; + #ifdef VULKAN layout (location = 0) in vec4 fragTexCoord; layout (location = 1) in vec4 fragColor; -layout (location = 0) out vec4 fragOut0; - layout (set = 1, binding = 1) uniform sampler2DArray baseMap; layout (set = 2, binding = 0, std140) uniform genericData { @@ -17,8 +21,6 @@ layout (set = 2, binding = 0, std140) uniform genericData { in vec4 fragTexCoord; in vec4 fragColor; -out vec4 fragOut0; - uniform sampler2DArray baseMap; layout (std140) uniform genericData { diff --git a/code/def_files/data/effects/batched-v.sdr b/code/def_files/data/effects/batched-v.sdr index 9f1efb6f213..87bb3983acf 100644 --- a/code/def_files/data/effects/batched-v.sdr +++ b/code/def_files/data/effects/batched-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +#endif + #ifdef VULKAN layout (location = 0) in vec4 vertPosition; layout (location = 1) in vec4 vertColor; diff --git a/code/def_files/data/effects/bloom-comp-f.sdr b/code/def_files/data/effects/bloom-comp-f.sdr index 20d8859a643..74fee1c1c13 100644 --- a/code/def_files/data/effects/bloom-comp-f.sdr +++ b/code/def_files/data/effects/bloom-comp-f.sdr @@ -1,11 +1,16 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif + +layout(location=0) out vec4 fragOut0; #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D bloomed; #else in vec4 fragTexCoord; -out vec4 fragOut0; + uniform sampler2D bloomed; #endif diff --git a/code/def_files/data/effects/blur-f.sdr b/code/def_files/data/effects/blur-f.sdr index 8063b8e4e03..47bcf42da05 100644 --- a/code/def_files/data/effects/blur-f.sdr +++ b/code/def_files/data/effects/blur-f.sdr @@ -1,9 +1,15 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else -out vec4 fragOut0; in vec4 fragTexCoord; uniform sampler2D tex; #endif diff --git a/code/def_files/data/effects/brightpass-f.sdr b/code/def_files/data/effects/brightpass-f.sdr index e1632a23d13..219f65bd06e 100644 --- a/code/def_files/data/effects/brightpass-f.sdr +++ b/code/def_files/data/effects/brightpass-f.sdr @@ -1,12 +1,18 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; #endif + const float Luminance = 0.08; const float fMiddleGray = 0.2; const float fWhiteCutoff = 0.4; diff --git a/code/def_files/data/effects/copy-f.sdr b/code/def_files/data/effects/copy-f.sdr index 28c29bdfac8..db9e9166b69 100644 --- a/code/def_files/data/effects/copy-f.sdr +++ b/code/def_files/data/effects/copy-f.sdr @@ -1,10 +1,15 @@ +#ifdef GL_ES +precision highp sampler2D; +precision highp sampler2DArray; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; #ifdef COPY_ARRAY uniform sampler2DArray tex; #else diff --git a/code/def_files/data/effects/decal-f.sdr b/code/def_files/data/effects/decal-f.sdr index 34d65a67ba8..6c1577bcd3d 100644 --- a/code/def_files/data/effects/decal-f.sdr +++ b/code/def_files/data/effects/decal-f.sdr @@ -1,3 +1,9 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +precision highp sampler2DArray; +#endif // NOTE: The technique and some of this code is based on this tutorial: // http://martindevans.me/game-development/2015/02/27/Drawing-Stuff-On-Other-Stuff-With-Deferred-Screenspace-Decals/ @@ -29,9 +35,14 @@ layout (set = 1, binding = 1) uniform sampler2DArray decalTextures; layout (set = 1, binding = 4) uniform sampler2D gDepthBuffer; layout (set = 1, binding = 6) uniform sampler2D gNormalBuffer; #else -out vec4 fragOut0; // Diffuse buffer -out vec4 fragOut1; // Normal buffer -out vec4 fragOut2; // Emissive buffer +layout (location=0) out vec4 fragOut0; // Diffuse buffer +#ifndef GL_ES +layout (location=1) out vec4 fragOut1; // Normal buffer +layout (location=2) out vec4 fragOut2; // Emissive buffer +#else +layout (location=2) out vec4 fragOut1; // Normal buffer -> COLOR_ATTACHMENT2 +layout (location=4) out vec4 fragOut2; // Emissive buffer -> COLOR_ATTACHMENT4 +#endif flat in mat4 invModelMatrix; flat in vec3 decalDirection; @@ -124,7 +135,7 @@ vec3 getPixelNormal(vec3 frag_position, vec2 tex_coord, inout float alpha, out v } // Make a smooth alpha transition leading up to an edge - alpha = alpha * (1 - smoothstep(angle_fade_start, normal_angle_cutoff, angle)); + alpha = alpha * (1.0 - smoothstep(angle_fade_start, normal_angle_cutoff, angle)); return normal; } diff --git a/code/def_files/data/effects/decal-v.sdr b/code/def_files/data/effects/decal-v.sdr index 42d99146327..46998b7983a 100644 --- a/code/def_files/data/effects/decal-v.sdr +++ b/code/def_files/data/effects/decal-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +#endif #ifdef VULKAN // Binding 0: box vertex positions diff --git a/code/def_files/data/effects/default-material-f.sdr b/code/def_files/data/effects/default-material-f.sdr index cec7df3a766..236421b31d7 100644 --- a/code/def_files/data/effects/default-material-f.sdr +++ b/code/def_files/data/effects/default-material-f.sdr @@ -1,3 +1,16 @@ +#ifdef GL_ES +#extension GL_EXT_clip_cull_distance : enable +precision highp float; +precision highp int; +precision highp sampler2DArray; +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif + #ifdef VULKAN layout(set = 2, binding = 0, std140) #else @@ -20,22 +33,28 @@ uniform genericData { uint clipEnabled; }; +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(set = 1, binding = 1) uniform sampler2DArray baseMap; layout(location = 0) in vec4 fragTexCoord; layout(location = 1) in vec4 fragColor; - -layout(location = 0) out vec4 fragOut0; +#ifndef USE_HW_CLIP_DISTANCE +layout(location = 2) in float vClipDist; +#endif #else +#ifndef USE_HW_CLIP_DISTANCE +in float vClipDist; +#endif + uniform sampler2DArray baseMap; in vec4 fragTexCoord; in vec4 fragColor; -out vec4 fragOut0; #endif @@ -43,6 +62,11 @@ out vec4 fragOut0; void main() { +#ifndef USE_HW_CLIP_DISTANCE + if (clipEnabled != 0u && vClipDist < 0.0) { + discard; + } +#endif vec4 baseColor = texture(baseMap, vec3(fragTexCoord.xy, float(baseMapIndex))); if(alphaThreshold > baseColor.a) discard; baseColor.rgb = (srgb == 1) ? srgb_to_linear(baseColor.rgb) : baseColor.rgb; diff --git a/code/def_files/data/effects/default-material-v.sdr b/code/def_files/data/effects/default-material-v.sdr index 902240860ea..07e1fb2ddc4 100644 --- a/code/def_files/data/effects/default-material-v.sdr +++ b/code/def_files/data/effects/default-material-v.sdr @@ -1,3 +1,15 @@ +#ifdef GL_ES +#extension GL_EXT_clip_cull_distance : enable +precision highp float; +precision highp int; +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif + #ifdef VULKAN layout(set = 2, binding = 0, std140) #else @@ -38,10 +50,15 @@ layout(location = 2) in vec4 vertTexCoord; layout(location = 0) out vec4 fragTexCoord; layout(location = 1) out vec4 fragColor; +#ifndef USE_HW_CLIP_DISTANCE +layout(location = 2) out float vClipDist; +#endif #else -out float gl_ClipDistance[1]; +#ifndef USE_HW_CLIP_DISTANCE +out float vClipDist; +#endif out vec4 fragTexCoord; in vec4 vertTexCoord; @@ -58,13 +75,16 @@ void main() gl_Position = projMatrix * modelViewMatrix * vertPosition; if (clipEnabled != 0u) { + #ifdef USE_HW_CLIP_DISTANCE gl_ClipDistance[0] = dot(clipEquation, modelMatrix * vertPosition); + #else + vClipDist = dot(clipEquation, modelMatrix * vertPosition); + #endif } else { -#ifdef VULKAN - // Vulkan has no glEnable(GL_CLIP_DISTANCE0) equivalent — clip distances are - // always evaluated when declared in the shader. Must write a positive value - // when clipping is disabled to prevent undefined-value vertex culling. + #ifdef USE_HW_CLIP_DISTANCE gl_ClipDistance[0] = 1.0; -#endif + #else + vClipDist = 1.0; + #endif } } diff --git a/code/def_files/data/effects/deferred-clear-f.sdr b/code/def_files/data/effects/deferred-clear-f.sdr index 4d49695ef90..3faddb831fe 100644 --- a/code/def_files/data/effects/deferred-clear-f.sdr +++ b/code/def_files/data/effects/deferred-clear-f.sdr @@ -1,9 +1,14 @@ -out vec4 fragOut0; -out vec4 fragOut1; -out vec4 fragOut2; -out vec4 fragOut3; -out vec4 fragOut4; -out vec4 fragOut5; +#ifdef GL_ES +precision highp float; +#endif + +layout (location=0) out vec4 fragOut0; +layout (location=1) out vec4 fragOut1; +layout (location=2) out vec4 fragOut2; +layout (location=3) out vec4 fragOut3; +layout (location=4) out vec4 fragOut4; +layout (location=5) out vec4 fragOut5; + void main() { fragOut0 = vec4(0.0, 0.0, 0.0, 1.0); // color diff --git a/code/def_files/data/effects/deferred-f.sdr b/code/def_files/data/effects/deferred-f.sdr index fb5d9021ebd..d27e86ffc05 100644 --- a/code/def_files/data/effects/deferred-f.sdr +++ b/code/def_files/data/effects/deferred-f.sdr @@ -1,13 +1,21 @@ //? #version 150 +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +precision highp samplerCube; +precision highp sampler2DArrayShadow; +#endif + #include "lighting.sdr" //! #include "lighting.sdr" #include "gamma.sdr" //! #include "gamma.sdr" #include "shadows.sdr" //! #include "shadows.sdr" #include "z-compress.sdr" //! #include "z-compress.sdr" -#ifdef VULKAN +#ifndef GL_ES layout(location = 0) out vec4 fragOut0; #else -out vec4 fragOut0; +layout(location = 5) out vec4 fragOut0; //COLOR_ATTACHMENTn is on location n in ES, here it uses COLOR_ATTACHMENT5 #endif #ifdef VULKAN @@ -141,7 +149,7 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li dist = length(lightDirOut); lightDist = dist; // Energy conservation term - float alpha_adjust = clamp(alpha + (sourceRadius/(2*dist)), 0.0, 1.0); + float alpha_adjust = clamp(alpha + (sourceRadius/(2.0*dist)), 0.0, 1.0); area_normalisation = alpha/alpha_adjust; area_normalisation *= area_normalisation; //end chunk @@ -184,7 +192,7 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li float dist = length(lightDirOut); lightDist = dist; // Energy conservation term - float alpha_adjust = min(alpha + (sourceRadius/(2*dist)), 1.0); + float alpha_adjust = min(alpha + (sourceRadius/(2.0*dist)), 1.0); area_normalisation = alpha/alpha_adjust; // don't need to square as it's a line rather than a sphere. //end chunk @@ -231,11 +239,11 @@ void ComputeEnvLight(float alpha, float ao, vec3 light_dir, vec3 eyeDir, vec3 no // so let s = (2/alpha^2 - 2) // 1/2 log(s + 1) = 1/2 log(2/alpha^2 -1) - const float ENV_REZ = 512; // Ideally this would be #define'd and shader recompiled with envmap rez changes - const float REZ_BIAS = log2(ENV_REZ * sqrt(3)); + const float ENV_REZ = 512.0; // Ideally this would be #define'd and shader recompiled with envmap rez changes + const float REZ_BIAS = log2(ENV_REZ * sqrt(3.0)); float alphaSqr = alpha * alpha; - float rough_bias = 0.5 * log2(2/alphaSqr - 1); + float rough_bias = 0.5 * log2(2.0/alphaSqr - 1.0); float mip_bias = REZ_BIAS - rough_bias; // Sample light, using mip bias to blur it. @@ -253,7 +261,7 @@ void ComputeEnvLight(float alpha, float ao, vec3 light_dir, vec3 eyeDir, vec3 no // Pseudo-IBL, so use k_IBL float k = alpha * alpha/ 2.0f; - float NdotL = max(dot(light_dir, normal),0); + float NdotL = max(dot(light_dir, normal),0.0); float g1vNL = GeometrySchlickGGX(NdotL, k); vec3 specEnvLighting = specEnvColour.rgb * fresnel * g1vNL; @@ -331,6 +339,6 @@ void main() float NdotL = clamp(dot(normal, lightDir), 0.0, 1.0); fragmentColor.rgb = computeLighting(specColor.rgb, diffColor, lightDir, normal.xyz, halfVec, eyeDir, roughness, fresnel, NdotL).rgb * diffuseLightColor * attenuation * area_normalisation; } - + fragOut0 = max(fragmentColor, vec4(0.0)); } diff --git a/code/def_files/data/effects/deferred-v.sdr b/code/def_files/data/effects/deferred-v.sdr index 2c9d4b02c66..98fa87d7f67 100644 --- a/code/def_files/data/effects/deferred-v.sdr +++ b/code/def_files/data/effects/deferred-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +#endif #include "lighting.sdr" diff --git a/code/def_files/data/effects/effect-distort-f.sdr b/code/def_files/data/effects/effect-distort-f.sdr index b43907a39da..d06ff7409d8 100644 --- a/code/def_files/data/effects/effect-distort-f.sdr +++ b/code/def_files/data/effects/effect-distort-f.sdr @@ -1,10 +1,16 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +precision highp sampler2DArray; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec4 fragTexCoord; layout(location = 1) in vec4 fragColor; layout(location = 2) in float fragOffset; -layout(location = 0) out vec4 fragOut0; - layout(set = 1, binding = 1) uniform sampler2DArray baseMap; layout(set = 1, binding = 4) uniform sampler2D depthMap; layout(set = 1, binding = 5) uniform sampler2D frameBuffer; @@ -14,8 +20,6 @@ in vec4 fragTexCoord; in vec4 fragColor; in float fragOffset; -out vec4 fragOut0; - uniform sampler2DArray baseMap; uniform sampler2D depthMap; uniform sampler2D distMap; diff --git a/code/def_files/data/effects/effect-distort-v.sdr b/code/def_files/data/effects/effect-distort-v.sdr index 5673b1baf3e..2eb075be1d4 100644 --- a/code/def_files/data/effects/effect-distort-v.sdr +++ b/code/def_files/data/effects/effect-distort-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +#endif + #ifdef VULKAN layout(location = 0) in vec4 vertPosition; layout(location = 1) in vec4 vertColor; diff --git a/code/def_files/data/effects/effect-f.sdr b/code/def_files/data/effects/effect-f.sdr index f46147830e5..b8a73fbef8d 100644 --- a/code/def_files/data/effects/effect-f.sdr +++ b/code/def_files/data/effects/effect-f.sdr @@ -1,15 +1,21 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +precision highp sampler2DArray; +#endif #include "gamma.sdr" #include "z-compress.sdr" +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec4 fragTexCoord; layout(location = 1) in vec4 fragColor; layout(location = 2) in float fragRadius; layout(location = 3) in vec4 fragPosition; -layout(location = 0) out vec4 fragOut0; - layout(set = 1, binding = 1) uniform sampler2DArray baseMap; layout(set = 1, binding = 4) uniform sampler2D depthMap; #else @@ -18,8 +24,6 @@ in vec4 fragPosition; in vec4 fragTexCoord; in vec4 fragColor; -out vec4 fragOut0; - uniform sampler2DArray baseMap; uniform sampler2D depthMap; #endif diff --git a/code/def_files/data/effects/effect-g.sdr b/code/def_files/data/effects/effect-g.sdr index d1cb2311291..44e8545ee72 100644 --- a/code/def_files/data/effects/effect-g.sdr +++ b/code/def_files/data/effects/effect-g.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +#endif + layout (points) in; layout (triangle_strip, max_vertices = 4) out; diff --git a/code/def_files/data/effects/effect-v.sdr b/code/def_files/data/effects/effect-v.sdr index 86244a7ee84..3662e9e8649 100644 --- a/code/def_files/data/effects/effect-v.sdr +++ b/code/def_files/data/effects/effect-v.sdr @@ -1,3 +1,6 @@ +#ifdef GL_ES +precision highp float; +#endif #ifdef VULKAN layout(location = 0) in vec4 vertPosition; diff --git a/code/def_files/data/effects/envmap-sphere-warp-f.sdr b/code/def_files/data/effects/envmap-sphere-warp-f.sdr index ab2b4071618..8cc562e693f 100644 --- a/code/def_files/data/effects/envmap-sphere-warp-f.sdr +++ b/code/def_files/data/effects/envmap-sphere-warp-f.sdr @@ -1,11 +1,14 @@ #define M_PI 3.1415926535897932384626433832795 +#ifdef GL_ES +precision highp float; +precision highp samplerCube; +#endif + uniform samplerCube envmap; in vec4 fragTexCoord; -out vec4 fragOut0; - -layout (location = 0) out vec4 outColor; +layout(location=0) out vec4 fragOut0; void main() { const float theta = -fragTexCoord.x * (2.0 * M_PI); diff --git a/code/def_files/data/effects/fog-f.sdr b/code/def_files/data/effects/fog-f.sdr index 6c822bb67e3..c252e91b611 100644 --- a/code/def_files/data/effects/fog-f.sdr +++ b/code/def_files/data/effects/fog-f.sdr @@ -1,17 +1,20 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif #include "gamma.sdr" +layout(location=0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; layout(set = 1, binding = 4) uniform sampler2D depth_tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; - uniform sampler2D tex; uniform sampler2D depth_tex; #endif @@ -40,7 +43,7 @@ void main() // If the scene is in fog then we change the color we operate on based on the depth of the pixel float depth_val = texture(depth_tex, fragTexCoord.xy).x; // Transform depth value from [0, 1] to [-1, 1] - float depth_normalized = 2 * depth_val - 1; + float depth_normalized = 2.0 * depth_val - 1.0; // Now we compute the depth value in projection space using the clipping plane information float view_depth = 2.0 * zNear * zFar / (zFar + zNear - depth_normalized * (zFar - zNear)); @@ -50,7 +53,7 @@ void main() if (isinf(view_depth)) { fragOut0.rgb = color_in.rgb; } else { - float fog_dist = clamp(1 - pow(fog_density, view_depth - fog_start) , 0.0, 1.0); + float fog_dist = clamp(1.0 - pow(fog_density, view_depth - fog_start) , 0.0, 1.0); vec3 finalFogColor = srgb_to_linear(fog_color); fragOut0.rgb = mix(color_in.rgb, finalFogColor, fog_dist); diff --git a/code/def_files/data/effects/fxaa-f.sdr b/code/def_files/data/effects/fxaa-f.sdr index 329b68384b7..0cd59026d25 100644 --- a/code/def_files/data/effects/fxaa-f.sdr +++ b/code/def_files/data/effects/fxaa-f.sdr @@ -1,3 +1,12 @@ +#ifdef GL_ES +#ifdef GL_EXT_gpu_shader5 + #extension GL_EXT_gpu_shader5 : enable + #define FXAA_GATHER4_ALPHA 1 +#endif +precision highp float; +precision highp sampler2D; +#endif + #define FXAA_EARLY_EXIT 1 #define FXAA_DISCARD 1 #define FXAA_FAST_PIXEL_OFFSET 1 // With OpenGL 3.2 we can always do this @@ -500,8 +509,12 @@ layout(std140, set = 2, binding = 0) uniform genericData { #else uniform sampler2D tex0; in vec2 v_rcpFrame; +#ifdef GL_ES +in vec2 v_pos; +#else noperspective in vec2 v_pos; -out vec4 fragOut0; +#endif +layout(location=0)out vec4 fragOut0; #endif void main() { diff --git a/code/def_files/data/effects/fxaa-v.sdr b/code/def_files/data/effects/fxaa-v.sdr index 22a9053f2a1..fa5bc259b25 100644 --- a/code/def_files/data/effects/fxaa-v.sdr +++ b/code/def_files/data/effects/fxaa-v.sdr @@ -1,3 +1,6 @@ +#ifdef GL_ES +precision highp float; +#endif #ifdef VULKAN layout(location = 0) out vec2 fragTexCoord; @@ -10,7 +13,11 @@ void main() { in vec4 vertPosition; out vec2 v_rcpFrame; +#ifdef GL_ES +out vec2 v_pos; +#else noperspective out vec2 v_pos; +#endif layout (std140) uniform genericData { float rt_w; diff --git a/code/def_files/data/effects/fxaapre-f.sdr b/code/def_files/data/effects/fxaapre-f.sdr index 64dd3487342..a9f6c03c503 100644 --- a/code/def_files/data/effects/fxaapre-f.sdr +++ b/code/def_files/data/effects/fxaapre-f.sdr @@ -1,6 +1,12 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif + +layout(location=0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; // [0]=real color (passed through as-is), [1]=luma detection proxy (see // getAADetectionView; may be the same view as [0] when not HDR) layout(set = 1, binding = 1) uniform sampler2D fxaaTex[2]; @@ -8,9 +14,9 @@ layout(set = 1, binding = 1) uniform sampler2D fxaaTex[2]; #define lumaTex fxaaTex[1] #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; #endif + void main() { vec4 color = texture(tex, fragTexCoord.xy); #ifdef VULKAN diff --git a/code/def_files/data/effects/gamma-correct-f.sdr b/code/def_files/data/effects/gamma-correct-f.sdr index dc6ec534257..2f5201fcd1c 100644 --- a/code/def_files/data/effects/gamma-correct-f.sdr +++ b/code/def_files/data/effects/gamma-correct-f.sdr @@ -1,12 +1,17 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif + #include "gamma.sdr" +layout(location=0)out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; #endif diff --git a/code/def_files/data/effects/gamma.sdr b/code/def_files/data/effects/gamma.sdr index a57ce437bdf..7067fef93bf 100644 --- a/code/def_files/data/effects/gamma.sdr +++ b/code/def_files/data/effects/gamma.sdr @@ -1,3 +1,6 @@ +#ifdef GL_ES +precision highp float; +#endif const float SRGB_GAMMA = 2.2; const float SRGB_GAMMA_INVERSE = 1.0 / SRGB_GAMMA; diff --git a/code/def_files/data/effects/irrmap-f.sdr b/code/def_files/data/effects/irrmap-f.sdr index 556480d22e5..ea07011469d 100644 --- a/code/def_files/data/effects/irrmap-f.sdr +++ b/code/def_files/data/effects/irrmap-f.sdr @@ -1,15 +1,21 @@ //!#version 150 -#include "gamma.sdr" //! #include "gamma.sdr" +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp samplerCube; +#endif + +#include "gamma.sdr" #define PI 3.1415926535897932384626433832795 +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform samplerCube envmap; #else uniform samplerCube envmap; in vec4 fragTexCoord; -out vec4 fragOut0; #endif #ifdef VULKAN @@ -154,8 +160,8 @@ vec3( 0.7305, 0.6698, 0.1333) ); void main() { - float xpos = 2 * gl_FragCoord.x/16 - 1; // remap to (-1, 1) - float ypos = 2 * gl_FragCoord.y/16 - 1; + float xpos = 2.0 * gl_FragCoord.x/16.0 - 1.0; // remap to (-1, 1) + float ypos = 2.0 * gl_FragCoord.y/16.0 - 1.0; vec3 fragDir; vec4 fragCol = vec4(0.0); @@ -191,5 +197,5 @@ void main() { vec3 sampDir = points[i] + (aPdotD - PdotD) * fragDir; fragCol += aPdotD * vec4(srgb_to_linear(texture(envmap, sampDir)).rgb, 1.0); } - fragOut0 = linear_to_srgb(PI * fragCol * (1.0/128)); + fragOut0 = linear_to_srgb(PI * fragCol * (1.0/128.0)); } \ No newline at end of file diff --git a/code/def_files/data/effects/lighting.sdr b/code/def_files/data/effects/lighting.sdr index 799617b52eb..00ae3fb2fa0 100644 --- a/code/def_files/data/effects/lighting.sdr +++ b/code/def_files/data/effects/lighting.sdr @@ -8,7 +8,7 @@ const int LT_AMBIENT = 4; // Directionless ambient light const float SPEC_FACTOR_NO_SPEC_MAP = 0.1; const float GLOW_MAP_INTENSITY = 1.5; const float GLOW_MAP_SRGB_MULTIPLIER = 3.0; -const float PI = 3.14159f; +const float PI = 3.14159265359; vec3 FresnelSchlick(vec3 halfVec, vec3 view, vec3 specColor) @@ -57,7 +57,7 @@ vec3 ComputeGGX(vec3 specColor, vec3 diffColor, vec3 light, vec3 normal, vec3 ha - vec3 specular = distribution * fresnel * geometry / (4*dotNV*dotNL + 0.0001); + vec3 specular = distribution * fresnel * geometry / (4.0*dotNV*dotNL + 0.0001); // Diffuse term - Lambertian, kD represents energy lost to specular reflection. vec3 kD = vec3(1.0)-fresnel; @@ -70,7 +70,7 @@ vec3 ComputeGGX(vec3 specColor, vec3 diffColor, vec3 light, vec3 normal, vec3 ha vec3 computeLighting(vec3 specColor, vec3 diffColor, vec3 light, vec3 normal, vec3 halfVec, vec3 view, float roughness, float fresnelFactor, float dotNL) { #ifdef FLAG_LIGHT_MODEL_BLINN_PHONG - return SpecularBlinnPhong(specColor, light, normal, halfVec, 32, fresnelFactor, dotNL); + return SpecularBlinnPhong(specColor, light, normal, halfVec, 32.0, fresnelFactor, dotNL); #else return ComputeGGX(specColor, diffColor, light, normal, halfVec, view, roughness, fresnelFactor, dotNL); #endif diff --git a/code/def_files/data/effects/ls-f.sdr b/code/def_files/data/effects/ls-f.sdr index cc4ff755da0..694ed7f454a 100644 --- a/code/def_files/data/effects/ls-f.sdr +++ b/code/def_files/data/effects/ls-f.sdr @@ -1,7 +1,14 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; + layout(set = 1, binding = 1) uniform sampler2D textures[16]; #define scene textures[0] @@ -9,8 +16,6 @@ layout(set = 1, binding = 1) uniform sampler2D textures[16]; #else in vec4 fragTexCoord; -out vec4 fragOut0; - uniform sampler2D scene; uniform sampler2D cockpit; #endif diff --git a/code/def_files/data/effects/main-f.sdr b/code/def_files/data/effects/main-f.sdr index 1a46b848d9e..276045c790d 100644 --- a/code/def_files/data/effects/main-f.sdr +++ b/code/def_files/data/effects/main-f.sdr @@ -1,4 +1,19 @@ //? #version 150 +#ifdef GL_ES +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +precision highp int; +precision highp sampler2D; +precision highp sampler2DArray; +precision highp sampler2DArrayShadow; +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif + #include "shadows.sdr" //! #include "shadows.sdr" #include "lighting.sdr" //! #include "lighting.sdr" #include "gamma.sdr" //! #include "gamma.sdr" @@ -108,6 +123,13 @@ uniform shadowCascadeParams { vec4 smoothness_factors[(NUM_SHADOW_CASCADES + 4 - 1) / 4]; }; + +layout(location = 0) out vec4 fragOut0; +layout(location = 1) out vec4 fragOut1; +layout(location = 2) out vec4 fragOut2; +layout(location = 3) out vec4 fragOut3; +layout(location = 4) out vec4 fragOut4; + #ifdef VULKAN layout(set = 1, binding = 1) uniform sampler2DArray materialTextures[16]; #define sBasemap materialTextures[0] @@ -135,13 +157,12 @@ layout(location = 0) in VertexOutput { vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; #prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS + +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertIn; -layout(location = 0) out vec4 fragOut0; -layout(location = 1) out vec4 fragOut1; -layout(location = 2) out vec4 fragOut2; -layout(location = 3) out vec4 fragOut3; -layout(location = 4) out vec4 fragOut4; #else #prereplace IF_FLAG_COMPILED MODEL_SDR_FLAG_DIFFUSE uniform sampler2DArray sBasemap; @@ -181,13 +202,10 @@ in VertexOutput { vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; #prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertIn; - -out vec4 fragOut0; -out vec4 fragOut1; -out vec4 fragOut2; -out vec4 fragOut3; -out vec4 fragOut4; #endif vec3 FresnelLazarovEnv(vec3 specColor, vec3 view, vec3 normal, float gloss) @@ -272,6 +290,10 @@ vec3 CalculateLighting(vec3 normal, vec3 diffuseMaterial, vec3 specularMaterial, void main() { + #ifndef USE_HW_CLIP_DISTANCE + if (vertIn.vClipDist < 0.0) discard; + #endif + vec3 eyeDir = vec3(normalize(-vertIn.position).xyz); vec2 texCoord = vertIn.texCoord.xy; @@ -448,7 +470,7 @@ void main() #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_DIFFUSE // This code will only be used by the forward renderer so we apply the fog effect to both the emissive and the base // color. - float fogDensityFinal = clamp(1 - pow(fogDensity, vertIn.fogDist) , 0.0, 1.0); + float fogDensityFinal = clamp(1.0 - pow(fogDensity, vertIn.fogDist) , 0.0, 1.0); baseColor.rgb = mix(emissiveColor.rgb + baseColor.rgb, finalFogColor, fogDensityFinal); emissiveColor.rgb = vec3(0.0); // Zero the emissive color since it has already been added by the previous line specColor.rgb *= fogDensityFinal; @@ -493,11 +515,11 @@ void main() #prereplace IF_NOT_FLAG MODEL_SDR_FLAG_LIGHT #prereplace IF_FLAG MODEL_SDR_FLAG_SPEC baseColor.rgb += pow(1.0 - clamp(dot(eyeDir, normal), 0.0, 1.0), 5.0 * clamp(glossData, 0.01, 1.0)) * specColor.rgb; - glossData = 0; + glossData = 0.0f; #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_SPEC // If there is no lighting then we copy the color data so far into the emissive. emissiveColor.rgb += baseColor.rgb; - aoFactors.x = 0; + aoFactors.x = 0.0f; #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_LIGHT #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_DEFERRED diff --git a/code/def_files/data/effects/main-g.sdr b/code/def_files/data/effects/main-g.sdr index e348c386dfa..4e28e913d72 100644 --- a/code/def_files/data/effects/main-g.sdr +++ b/code/def_files/data/effects/main-g.sdr @@ -1,4 +1,17 @@ +#ifdef GL_ES +#extension GL_EXT_gpu_shader5: enable +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +precision highp int; +#else #extension GL_ARB_gpu_shader5: enable +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif #conditional_include +"LARGE_SHADER" "main_large.sdr" #conditional_include -"LARGE_SHADER" "main_small.sdr" @@ -100,6 +113,9 @@ in VertexOutput { vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; #prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertIn[]; out VertexOutput { @@ -117,6 +133,10 @@ out VertexOutput { vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; #prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS + +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertOut; #ifdef MODEL_SDR_FLAG_THICK_OUTLINES @@ -166,8 +186,19 @@ out VertexOutput { #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_SHADOWS if (use_clip_plane != 0) { - gl_ClipDistance[0] = gl_in[vert].gl_ClipDistance[0]; + #ifndef USE_HW_CLIP_DISTANCE + vertOut.vClipDist = vertIn[vert].vClipDist; + #else + gl_ClipDistance[0] = gl_in[vert].gl_ClipDistance[0]; + #endif + } else { + #ifndef USE_HW_CLIP_DISTANCE + vertOut.vClipDist = 1.0; + #else + gl_ClipDistance[0] = 1.0; + #endif } + EmitVertex(); } diff --git a/code/def_files/data/effects/main-v.sdr b/code/def_files/data/effects/main-v.sdr index 39426766ab1..66d4c2a73d8 100644 --- a/code/def_files/data/effects/main-v.sdr +++ b/code/def_files/data/effects/main-v.sdr @@ -1,8 +1,24 @@ #ifndef VULKAN //? #version 150 +#ifdef GL_ES +#extension GL_EXT_gpu_shader5: enable +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +precision highp int; +precision highp samplerBuffer; +precision highp sampler2DArrayShadow; +#else #extension GL_ARB_gpu_shader5: enable #endif +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif + #include "shadows.sdr" #conditional_include +"LARGE_SHADER" "main_large.sdr" @@ -135,8 +151,15 @@ layout(location = 0) out VertexOutput { vec4 texCoord; mat3 tangentMatrix; float fogDist; + +#prereplace IF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; +#prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS + +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertOut; #else #prereplace IF_FLAG_COMPILED MODEL_SDR_FLAG_TRANSFORM @@ -158,6 +181,10 @@ out VertexOutput { vec4 shadowUV[NUM_SHADOW_CASCADES]; vec4 shadowPos; #prereplace ENDIF_FLAG_COMPILED MODEL_SDR_FLAG_SHADOWS + +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertOut; #define TEXELS_PER_MATRIX 4 @@ -239,12 +266,20 @@ void main() } #prereplace ENDIF_FLAG //MODEL_SDR_FLAG_TRANSFORM - // Clip plane - if(use_clip_plane != 0) { - gl_ClipDistance[0] = dot(clip_equation, modelMatrix * orient * vertex); - } else { - gl_ClipDistance[0] = 1.0; - } + #ifdef USE_HW_CLIP_DISTANCE + if (use_clip_plane != 0) { + gl_ClipDistance[0] = dot(clip_equation, modelMatrix * orient * vertex); + } else { + gl_ClipDistance[0] = 1.0; + } + #else + if (use_clip_plane != 0) { + vertOut.vClipDist = dot(clip_equation, modelMatrix * orient * vertex); + } else { + vertOut.vClipDist = 1.0; + } + #endif + vertOut.position = position; vertOut.normal = normal; diff --git a/code/def_files/data/effects/msaa-f.sdr b/code/def_files/data/effects/msaa-f.sdr index 85ce8d36aff..002abf1e025 100644 --- a/code/def_files/data/effects/msaa-f.sdr +++ b/code/def_files/data/effects/msaa-f.sdr @@ -1,7 +1,9 @@ #include "z-compress.sdr" - -#ifdef VULKAN -layout(location = 0) in vec2 fragTexCoord; +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2DMS; +#endif layout(location = 0) out vec4 fragOut0; layout(location = 1) out vec4 fragOut1; @@ -9,6 +11,9 @@ layout(location = 2) out vec4 fragOut2; layout(location = 3) out vec4 fragOut3; layout(location = 4) out vec4 fragOut4; +#ifdef VULKAN +layout(location = 0) in vec2 fragTexCoord; + layout(set = 1, binding = 1) uniform sampler2DMS msaaTex[6]; #define texColor msaaTex[0] #define texPos msaaTex[1] @@ -23,12 +28,7 @@ layout(std140, set = 2, binding = 0) uniform genericData { }; #else in vec4 fragTexCoord; -out vec4 fragOut0; -out vec4 fragOut1; -out vec4 fragOut2; -out vec4 fragOut3; -out vec4 fragOut4; -out vec4 fragOut5; +layout(location=5)out vec4 fragOut5; uniform sampler2DMS texColor; uniform sampler2DMS texPos; diff --git a/code/def_files/data/effects/nanovg-f.sdr b/code/def_files/data/effects/nanovg-f.sdr index dbe41703069..4ba74a86c98 100644 --- a/code/def_files/data/effects/nanovg-f.sdr +++ b/code/def_files/data/effects/nanovg-f.sdr @@ -1,3 +1,8 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2DArray; +#endif #ifdef VULKAN layout (location = 0) in vec2 ftcoord; diff --git a/code/def_files/data/effects/nanovg-v.sdr b/code/def_files/data/effects/nanovg-v.sdr index 2974de708e1..89a56d5a4cd 100644 --- a/code/def_files/data/effects/nanovg-v.sdr +++ b/code/def_files/data/effects/nanovg-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +#endif #ifdef VULKAN layout (location = 0) in vec4 vertPosition; diff --git a/code/def_files/data/effects/normals.sdr b/code/def_files/data/effects/normals.sdr index 8123bd13747..185dc5cbff2 100644 --- a/code/def_files/data/effects/normals.sdr +++ b/code/def_files/data/effects/normals.sdr @@ -7,6 +7,6 @@ vec3 unpackNormal(vec2 normal_sample) { vec3 normal; normal.xy = normal_sample * 2.0 - 1.0; - normal.z = sqrt(1 - normal_sample.x * normal_sample.x - normal_sample.y * normal_sample.y); + normal.z = sqrt(1.0 - normal_sample.x * normal_sample.x - normal_sample.y * normal_sample.y); return normal; } diff --git a/code/def_files/data/effects/passthrough-f.sdr b/code/def_files/data/effects/passthrough-f.sdr index 6e3134e068e..3b06379b9bd 100644 --- a/code/def_files/data/effects/passthrough-f.sdr +++ b/code/def_files/data/effects/passthrough-f.sdr @@ -1,9 +1,14 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +#endif #include "gamma.sdr" in vec4 fragTexCoord; in vec4 fragColor; -out vec4 fragOut0; +layout(location=0) out vec4 fragOut0; uniform sampler2D baseMap; diff --git a/code/def_files/data/effects/post-f.sdr b/code/def_files/data/effects/post-f.sdr index 6e12a5e20fb..29bc2a78ae7 100644 --- a/code/def_files/data/effects/post-f.sdr +++ b/code/def_files/data/effects/post-f.sdr @@ -1,11 +1,16 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; layout(set = 1, binding = 4) uniform sampler2D depth_tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; uniform sampler2D depth_tex; #endif diff --git a/code/def_files/data/effects/rocketui-f.sdr b/code/def_files/data/effects/rocketui-f.sdr index 688d2ec5fe2..a3559ab4b89 100644 --- a/code/def_files/data/effects/rocketui-f.sdr +++ b/code/def_files/data/effects/rocketui-f.sdr @@ -1,10 +1,17 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2DArray; +#endif + +layout(location = 0) out vec4 fragOut0; #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; layout(location = 1) in vec4 fragColor; layout(location = 2) in vec2 fragScreenPosition; -layout(location = 0) out vec4 fragOut0; + layout(set = 1, binding = 1) uniform sampler2DArray baseMap; #else @@ -12,8 +19,6 @@ in vec2 fragTexCoord; in vec4 fragColor; in vec2 fragScreenPosition; -out vec4 fragOut0; - uniform sampler2DArray baseMap; #endif diff --git a/code/def_files/data/effects/rocketui-v.sdr b/code/def_files/data/effects/rocketui-v.sdr index 07ae245966f..df966d8a1de 100644 --- a/code/def_files/data/effects/rocketui-v.sdr +++ b/code/def_files/data/effects/rocketui-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +#endif #ifdef VULKAN layout(location = 0) in vec2 vertPosition; diff --git a/code/def_files/data/effects/shadow_map-f.sdr b/code/def_files/data/effects/shadow_map-f.sdr index fff405831fd..652cacb5b64 100644 --- a/code/def_files/data/effects/shadow_map-f.sdr +++ b/code/def_files/data/effects/shadow_map-f.sdr @@ -1,5 +1,30 @@ //? #version 150 +#ifdef GL_ES +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif + +#ifndef USE_HW_CLIP_DISTANCE +#ifdef VULKAN +layout(location = 0) in VertexOutput { + float vClipDist; +} vertIn; +#else +in VertexOutput { + float vClipDist; +} vertIn; +#endif +#endif void main() { +#ifndef USE_HW_CLIP_DISTANCE + if (vertIn.vClipDist < 0.0) discard; +#endif } diff --git a/code/def_files/data/effects/shadow_map-g.sdr b/code/def_files/data/effects/shadow_map-g.sdr index 585276dca69..0f13cb1d1ee 100644 --- a/code/def_files/data/effects/shadow_map-g.sdr +++ b/code/def_files/data/effects/shadow_map-g.sdr @@ -1,9 +1,22 @@ //? #version 150 +#ifdef GL_ES +#extension GL_EXT_gpu_shader5: enable +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +precision highp int; +#else #extension GL_ARB_gpu_shader5: enable +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif layout (triangles) in; layout (triangle_strip, max_vertices = 3) out; -#ifdef GL_ARB_gpu_shader5 +#if defined(GL_ARB_gpu_shader5) || defined(GL_EXT_gpu_shader5) layout(invocations = NUM_SHADOW_CASCADES) in; #endif @@ -20,16 +33,25 @@ layout (std140) uniform shadowCascadeParams { }; in VertexOutput { -#if !defined(GL_ARB_gpu_shader5) +#if !defined(GL_ARB_gpu_shader5) && !defined(GL_EXT_gpu_shader5) float instance; #endif float clipModel; vec3 normal; +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif } vertIn[]; +#ifndef USE_HW_CLIP_DISTANCE +out VertexOutput { + float vClipDist; +} vertOut; +#endif + void main(void) { -#ifdef GL_ARB_gpu_shader5 +#if defined(GL_ARB_gpu_shader5) || defined(GL_EXT_gpu_shader5) if (gl_InvocationID >= cascade_count) return; int cascade_id = cascade_offset + gl_InvocationID; #else @@ -45,7 +67,12 @@ void main(void) } gl_Layer = cascade_id; - gl_ClipDistance[0] = gl_in[vert].gl_ClipDistance[0]; + + #ifndef USE_HW_CLIP_DISTANCE + vertOut.vClipDist = vertIn[vert].vClipDist; + #else + gl_ClipDistance[0] = gl_in[vert].gl_ClipDistance[0]; + #endif EmitVertex(); } diff --git a/code/def_files/data/effects/shadow_map-v.sdr b/code/def_files/data/effects/shadow_map-v.sdr index f3e92cd21d1..15a2f368bcc 100644 --- a/code/def_files/data/effects/shadow_map-v.sdr +++ b/code/def_files/data/effects/shadow_map-v.sdr @@ -1,9 +1,22 @@ //? #version 150 +#ifdef GL_ES +#extension GL_EXT_gpu_shader5: enable +#extension GL_EXT_clip_cull_distance: enable +precision highp float; +precision highp int; +precision highp samplerBuffer; +#else #extension GL_ARB_gpu_shader5: enable - #ifndef GEOMETRY_FALLBACK #extension GL_ARB_shader_viewport_layer_array : enable #endif +#endif + +#if defined(VULKAN) +//define USE_HW_CLIP_DISTANCE from engine side +#elif !defined(GL_ES) || defined(GL_EXT_clip_cull_distance) + #define USE_HW_CLIP_DISTANCE +#endif #ifdef VULKAN layout(location = 0) in vec4 vertPosition; @@ -62,13 +75,26 @@ uniform samplerBuffer transform_tex; // supports writing gl_Layer from the vertex shader, see CAPABILITY_FAST_SHADOWS). #ifdef GEOMETRY_FALLBACK out VertexOutput { -#if !defined(GL_ARB_gpu_shader5) +#if !defined(GL_ARB_gpu_shader5) && !defined(GL_EXT_gpu_shader5) float instance; #endif float clipModel; vec3 normal; +#ifndef USE_HW_CLIP_DISTANCE + float vClipDist; +#endif +} vertOut; +#elif !defined(USE_HW_CLIP_DISTANCE) +#ifdef VULKAN +layout(location = 0) out VertexOutput { + float vClipDist; +} vertOut; +#else +out VertexOutput { + float vClipDist; } vertOut; #endif +#endif #define TEXELS_PER_MATRIX 4 @@ -108,7 +134,7 @@ void main() #ifdef VULKAN int instanceIndex = gl_InstanceIndex; #else - #if !defined(GL_ARB_gpu_shader5) + #if !defined(GL_ARB_gpu_shader5) && !defined(GL_EXT_gpu_shader5) #ifdef APPLE vertOut.instance = float(gl_InstanceIDARB); #else @@ -129,11 +155,19 @@ void main() gl_Position = position; } +#ifdef USE_HW_CLIP_DISTANCE if (use_clip_plane != 0) { gl_ClipDistance[0] = dot(clip_equation, modelMatrix * orient * vertex); } else { gl_ClipDistance[0] = 1.0; } +#else + if (use_clip_plane != 0) { + vertOut.vClipDist = dot(clip_equation, modelMatrix * orient * vertex); + } else { + vertOut.vClipDist = 1.0; + } +#endif #ifdef GEOMETRY_FALLBACK vertOut.normal = normal; diff --git a/code/def_files/data/effects/shield-impact-f.sdr b/code/def_files/data/effects/shield-impact-f.sdr index e847867a9b0..fbdc1ecd141 100644 --- a/code/def_files/data/effects/shield-impact-f.sdr +++ b/code/def_files/data/effects/shield-impact-f.sdr @@ -1,21 +1,22 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2DArray; +#endif #include "gamma.sdr" const float EMISSIVE_GAIN = 2.0; +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec4 fragImpactUV; layout(location = 1) in float fragNormOffset; - -layout(location = 0) out vec4 fragOut0; - layout(set = 1, binding = 1) uniform sampler2DArray shieldMap; #else in vec4 fragImpactUV; in float fragNormOffset; - -out vec4 fragOut0; - uniform sampler2DArray shieldMap; #endif diff --git a/code/def_files/data/effects/shield-impact-v.sdr b/code/def_files/data/effects/shield-impact-v.sdr index 22f423cb3fb..ee078d041ac 100644 --- a/code/def_files/data/effects/shield-impact-v.sdr +++ b/code/def_files/data/effects/shield-impact-v.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +#endif #ifdef VULKAN layout(location = 0) in vec4 vertPosition; diff --git a/code/def_files/data/effects/smaa-blend-f.sdr b/code/def_files/data/effects/smaa-blend-f.sdr index 055d4b617b5..cbb8f3a5917 100644 --- a/code/def_files/data/effects/smaa-blend-f.sdr +++ b/code/def_files/data/effects/smaa-blend-f.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { @@ -16,13 +20,13 @@ layout (std140) uniform genericData { #include "SMAA.sdr" +layout(location=0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; layout(location = 1) in vec2 fragPixcoord; layout(location = 2) in vec4 fragOffset[3]; -layout(location = 0) out vec4 fragOut0; - // [0]=edgesTex, [1]=areaTex, [2]=searchTex layout(set = 1, binding = 1) uniform sampler2D smaaTex[3]; #define edgesTex smaaTex[0] @@ -33,8 +37,6 @@ in vec2 fragTexCoord; in vec2 fragPixcoord; in vec4 fragOffset[3]; -out vec4 fragOut0; - uniform sampler2D edgesTex; uniform sampler2D areaTex; uniform sampler2D searchTex; diff --git a/code/def_files/data/effects/smaa-blend-v.sdr b/code/def_files/data/effects/smaa-blend-v.sdr index a4e51c82a23..b04347279db 100644 --- a/code/def_files/data/effects/smaa-blend-v.sdr +++ b/code/def_files/data/effects/smaa-blend-v.sdr @@ -1,4 +1,3 @@ - #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { vec2 smaa_rt_metrics; diff --git a/code/def_files/data/effects/smaa-edge-f.sdr b/code/def_files/data/effects/smaa-edge-f.sdr index 3628177a08e..24e27ee0dc7 100644 --- a/code/def_files/data/effects/smaa-edge-f.sdr +++ b/code/def_files/data/effects/smaa-edge-f.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { @@ -16,19 +20,17 @@ layout (std140) uniform genericData { #include "SMAA.sdr" +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; layout(location = 1) in vec4 fragOffset[3]; -layout(location = 0) out vec4 fragOut0; - layout(set = 1, binding = 1) uniform sampler2D colorTex; #else in vec2 fragTexCoord; in vec4 fragOffset[3]; -out vec4 fragOut0; - uniform sampler2D colorTex; #endif diff --git a/code/def_files/data/effects/smaa-edge-v.sdr b/code/def_files/data/effects/smaa-edge-v.sdr index 6aa82772665..2983e60d044 100644 --- a/code/def_files/data/effects/smaa-edge-v.sdr +++ b/code/def_files/data/effects/smaa-edge-v.sdr @@ -1,4 +1,3 @@ - #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { vec2 smaa_rt_metrics; diff --git a/code/def_files/data/effects/smaa-neighbour-f.sdr b/code/def_files/data/effects/smaa-neighbour-f.sdr index 56813d9ca59..18973d57d42 100644 --- a/code/def_files/data/effects/smaa-neighbour-f.sdr +++ b/code/def_files/data/effects/smaa-neighbour-f.sdr @@ -1,3 +1,7 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2D; +#endif #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { @@ -16,11 +20,12 @@ layout (std140) uniform genericData { #include "SMAA.sdr" +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; layout(location = 1) in vec4 fragOffset; -layout(location = 0) out vec4 fragOut0; // [0]=colorTex, [1]=blendTex layout(set = 1, binding = 1) uniform sampler2D smaaTex[2]; @@ -30,8 +35,6 @@ layout(set = 1, binding = 1) uniform sampler2D smaaTex[2]; in vec2 fragTexCoord; in vec4 fragOffset; -out vec4 fragOut0; - uniform sampler2D colorTex; uniform sampler2D blendTex; #endif diff --git a/code/def_files/data/effects/smaa-neighbour-v.sdr b/code/def_files/data/effects/smaa-neighbour-v.sdr index 98ca74070c0..de4ad607df7 100644 --- a/code/def_files/data/effects/smaa-neighbour-v.sdr +++ b/code/def_files/data/effects/smaa-neighbour-v.sdr @@ -1,4 +1,3 @@ - #ifdef VULKAN layout(std140, set = 2, binding = 0) uniform genericData { vec2 smaa_rt_metrics; diff --git a/code/def_files/data/effects/smaa-resolve-f.sdr b/code/def_files/data/effects/smaa-resolve-f.sdr index fffe9367416..b9a22ed90d8 100644 --- a/code/def_files/data/effects/smaa-resolve-f.sdr +++ b/code/def_files/data/effects/smaa-resolve-f.sdr @@ -1,10 +1,14 @@ +#ifdef GL_ES +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; #endif diff --git a/code/def_files/data/effects/tonemapping-f.sdr b/code/def_files/data/effects/tonemapping-f.sdr index 98d7a04838b..93d12a134cb 100644 --- a/code/def_files/data/effects/tonemapping-f.sdr +++ b/code/def_files/data/effects/tonemapping-f.sdr @@ -1,13 +1,18 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +#endif #include "gamma.sdr" +layout(location=0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2D tex; #endif diff --git a/code/def_files/data/effects/video-f.sdr b/code/def_files/data/effects/video-f.sdr index 8ea4044baa3..0322b26813f 100644 --- a/code/def_files/data/effects/video-f.sdr +++ b/code/def_files/data/effects/video-f.sdr @@ -1,6 +1,12 @@ +#ifdef GL_ES +precision highp float; +precision highp sampler2DArray; +#endif + +layout(location = 0) out vec4 fragOut0; + #ifdef VULKAN layout(location = 0) in vec4 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2DArray textures[16]; #define ytex textures[0] @@ -8,7 +14,6 @@ layout(set = 1, binding = 1) uniform sampler2DArray textures[16]; #define vtex textures[2] #else in vec4 fragTexCoord; -out vec4 fragOut0; uniform sampler2DArray ytex; uniform sampler2DArray utex; uniform sampler2DArray vtex; diff --git a/code/def_files/data/effects/volumetric-f.sdr b/code/def_files/data/effects/volumetric-f.sdr index b00e721317c..f1e8726a0ab 100644 --- a/code/def_files/data/effects/volumetric-f.sdr +++ b/code/def_files/data/effects/volumetric-f.sdr @@ -1,7 +1,13 @@ +#ifdef GL_ES +precision highp float; +precision highp int; +precision highp sampler2D; +#endif + +layout(location = 0) out vec4 fragOut0; #ifdef VULKAN layout(location = 0) in vec2 fragTexCoord; -layout(location = 0) out vec4 fragOut0; layout(set = 1, binding = 1) uniform sampler2D tex2D[16]; #define composite tex2D[0] #define emissive tex2D[1] @@ -10,7 +16,7 @@ layout(set = 1, binding = 5) uniform sampler3D volume_tex; layout(set = 1, binding = 6) uniform sampler3D noise_volume_tex; #else in vec4 fragTexCoord; -out vec4 fragOut0; + layout (binding = 0) uniform sampler2D composite; layout (binding = 1) uniform sampler2D emissive; layout (binding = 2) uniform sampler2D depth_tex; diff --git a/code/graphics/opengl/es_compatibility.h b/code/graphics/opengl/es_compatibility.h index a864be1545e..3cdae8eeb82 100644 --- a/code/graphics/opengl/es_compatibility.h +++ b/code/graphics/opengl/es_compatibility.h @@ -32,6 +32,7 @@ #define GL_CLAMP_VERTEX_COLOR 0x891A #define GL_CLAMP_FRAGMENT_COLOR 0x891B #define GL_FIXED_ONLY 0x891D +#define GLAD_GL_ARB_shader_viewport_layer_array 0 // Disabled, no gl_layer in vertex shader //0x8DAE //Enums Redefinitions #define GL_CLIP_DISTANCE0 GL_CLIP_DISTANCE0_EXT // GL_EXT_clip_cull_distance @@ -48,6 +49,7 @@ #define GLAD_GL_ARB_texture_storage GL_TRUE // ES 3.2 #define GLAD_GL_ARB_draw_buffers_blend GL_TRUE // ES 3.2 (glBlendFunci and glBlendEquationi) #define GLAD_GL_ARB_vertex_attrib_binding GL_TRUE // ES 3.1 +#define GL_DEPTH_CLAMP GL_DEPTH_CLAMP_EXT //Functions Redefinitions #define glBlendFunciARB glBlendFunci // ES 3.2 @@ -234,11 +236,6 @@ inline void glDrawBuffer(GLenum buf) } } -// does not exist on ES, ES uses layout(location=) directly on shader -// Notes: -// -This function is not required to run. -#define glBindFragDataLocation(program, colorNumber, name) ((void)0) - // glPolygonMode() is not supported on ES, no wireframe, GL_FILL is default, GL_POINTS, and GL_LINES needs an alternative path // Notes: // -This function is not required to run. @@ -254,6 +251,7 @@ static inline void glQueryCounter(GLuint id, GLenum target) #else (void)id; #endif + (void)target; } // glGetCompressedTexImage not present on GLES and no equivalent diff --git a/code/graphics/opengl/gropengl.cpp b/code/graphics/opengl/gropengl.cpp index 444515b797a..ea3b337eeec 100644 --- a/code/graphics/opengl/gropengl.cpp +++ b/code/graphics/opengl/gropengl.cpp @@ -1453,7 +1453,9 @@ bool gr_opengl_init(std::unique_ptr&& graphicsOps) "Deferred lightning is enabled in settings but the gpu does not support the minimum of 6 draw buffers. " "This will result in rendering errors."); } - + + mprintf((" Depth Clamp support : %s\n", GLAD_GL_EXT_depth_clamp ? NOX("YES") : NOX("NO"))); + mprintf((" HW Cull distance support : %s\n", GLAD_GL_EXT_clip_cull_distance ? NOX("YES") : NOX("NO"))); mprintf((" Precompiled shaders support : %s\n", GLAD_GL_OES_get_program_binary ? NOX("YES") : NOX("NO"))); mprintf((" Immutable buffer storage support : %s\n", GLAD_GL_EXT_buffer_storage ? NOX("YES") : NOX("NO"))); mprintf((" BGRA8888 format support: %s\n", GLAD_GL_EXT_texture_format_BGRA8888 ? NOX("YES") : NOX("NO"))); diff --git a/code/graphics/opengl/gropenglshader.cpp b/code/graphics/opengl/gropenglshader.cpp index 41c3142d153..f2e5e5a768f 100644 --- a/code/graphics/opengl/gropenglshader.cpp +++ b/code/graphics/opengl/gropenglshader.cpp @@ -488,13 +488,6 @@ void opengl_compile_shader_actual(shader_type sdr, const uint &flags, opengl_sha glBindAttribLocation(program->getShaderHandle(), (GLint)i, GL_vertex_attrib_info[i].name.c_str()); } - // bind fragment data locations before we link the shader - glBindFragDataLocation(program->getShaderHandle(), 0, "fragOut0"); - glBindFragDataLocation(program->getShaderHandle(), 1, "fragOut1"); - glBindFragDataLocation(program->getShaderHandle(), 2, "fragOut2"); - glBindFragDataLocation(program->getShaderHandle(), 3, "fragOut3"); - glBindFragDataLocation(program->getShaderHandle(), 4, "fragOut4"); - if (do_shader_caching()) { // Enable shader caching glProgramParameteri(program->getShaderHandle(), GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE); diff --git a/code/graphics/vulkan/VulkanRendererSetup.cpp b/code/graphics/vulkan/VulkanRendererSetup.cpp index 90ebc51b567..8b0b673a6d0 100644 --- a/code/graphics/vulkan/VulkanRendererSetup.cpp +++ b/code/graphics/vulkan/VulkanRendererSetup.cpp @@ -426,7 +426,7 @@ bool VulkanRenderer::initialize() // Initialize shader manager m_shaderManager = std::make_unique(); - if (!m_shaderManager->init(m_device.get())) { + if (!m_shaderManager->init(m_device.get(), m_deviceFeatures.shaderClipDistance == VK_TRUE)) { nprintf(("vulkan", "Failed to initialize Vulkan shader manager!\n")); return false; } diff --git a/code/graphics/vulkan/VulkanShader.cpp b/code/graphics/vulkan/VulkanShader.cpp index da9a29bc5dc..d1e7763fb05 100644 --- a/code/graphics/vulkan/VulkanShader.cpp +++ b/code/graphics/vulkan/VulkanShader.cpp @@ -34,7 +34,7 @@ void vulkan_recompile_all_shaders(const std::function& pro VulkanShaderManager::VulkanShaderManager() = default; VulkanShaderManager::~VulkanShaderManager() = default; -bool VulkanShaderManager::init(vk::Device device) +bool VulkanShaderManager::init(vk::Device device, bool hwClipDistance) { if (m_initialized) { return true; @@ -44,7 +44,7 @@ bool VulkanShaderManager::init(vk::Device device) // Initialize runtime shader compiler m_compiler = std::make_unique(); - if (!m_compiler->init()) { + if (!m_compiler->init(hwClipDistance)) { nprintf(("vulkan", "VulkanShaderManager: Failed to initialize shader compiler!\n")); return false; } diff --git a/code/graphics/vulkan/VulkanShader.h b/code/graphics/vulkan/VulkanShader.h index 0f3e13381cb..25a1c724ee9 100644 --- a/code/graphics/vulkan/VulkanShader.h +++ b/code/graphics/vulkan/VulkanShader.h @@ -59,7 +59,7 @@ class VulkanShaderManager { * @param device Vulkan logical device * @return true on success */ - bool init(vk::Device device); + bool init(vk::Device device, bool hwClipDistance); /** * @brief Shutdown and release all shader modules diff --git a/code/graphics/vulkan/VulkanShaderCompiler.cpp b/code/graphics/vulkan/VulkanShaderCompiler.cpp index 2ff077b19ed..39ec38f7e40 100644 --- a/code/graphics/vulkan/VulkanShaderCompiler.cpp +++ b/code/graphics/vulkan/VulkanShaderCompiler.cpp @@ -102,8 +102,9 @@ VulkanShadercLibrary::VulkanShadercLibrary() VulkanShaderCompiler::VulkanShaderCompiler() = default; VulkanShaderCompiler::~VulkanShaderCompiler() = default; -bool VulkanShaderCompiler::init() +bool VulkanShaderCompiler::init(bool hwClipDistance) { + m_hwClipDistance = hwClipDistance; if (m_initialized) { return true; } @@ -148,6 +149,13 @@ SCP_string VulkanShaderCompiler::buildHeader(vk::ShaderStageFlagBits /*stage*/, // shaderc automatically predefines VULKAN=100 when targeting Vulkan, // so we do NOT define it here — doing so causes a "Macro redefined" error. + // gl_ClipDistance[] requires the shaderClipDistance device feature. When the + // device supports it, use the hardware clip path, otherwise + // the shaders fall back to the vClipDist varying (software clipping). + if (m_hwClipDistance) { + header += "#define USE_HW_CLIP_DISTANCE\n"; + } + // Blinn-Phong lighting model (matches OpenGL's opengl_shader_get_header) if (Detail.lighting < 3) { header += "#define FLAG_LIGHT_MODEL_BLINN_PHONG\n"; diff --git a/code/graphics/vulkan/VulkanShaderCompiler.h b/code/graphics/vulkan/VulkanShaderCompiler.h index 73837ef7b64..5a5046d6a5d 100644 --- a/code/graphics/vulkan/VulkanShaderCompiler.h +++ b/code/graphics/vulkan/VulkanShaderCompiler.h @@ -23,6 +23,7 @@ class VulkanShaderCompiler { VulkanShaderCompiler(); ~VulkanShaderCompiler(); + bool init(bool hwClipDistance); bool init(); void shutdown(); @@ -69,6 +70,7 @@ class VulkanShaderCompiler { std::unique_ptr m_shaderc; bool m_initialized = false; + bool m_hwClipDistance = false; }; } // namespace graphics::vulkan diff --git a/freespace2/SDLGraphicsOperations.cpp b/freespace2/SDLGraphicsOperations.cpp index 32702c0fa3c..4c5a45c2b71 100644 --- a/freespace2/SDLGraphicsOperations.cpp +++ b/freespace2/SDLGraphicsOperations.cpp @@ -328,8 +328,9 @@ std::unique_ptr SDLGraphicsOperations::createOpenGLContext(os Assertion(ImGui::GetCurrentContext() != nullptr, "Can't use ImGui without a valid context!"); - #ifndef USE_OPENGL_ES ImGui_ImplSDL3_InitForOpenGL(viewport->toSDLWindow(), ctx); + + #ifndef USE_OPENGL_ES ImGui_ImplOpenGL3_Init(); #else ImGui_ImplOpenGL3_Init("#version 300 es"); diff --git a/lib/opengl/gl/glad_es/include/glad/glad.h b/lib/opengl/gl/glad_es/include/glad/glad.h index 550c4ad13bb..5f5cdf5d548 100644 --- a/lib/opengl/gl/glad_es/include/glad/glad.h +++ b/lib/opengl/gl/glad_es/include/glad/glad.h @@ -1,6 +1,6 @@ /* - OpenGL ES loader generated by glad 0.1.36 on Wed Aug 27 15:16:54 2025. + OpenGL ES loader generated by glad 0.1.36 on Sat Jul 4 19:49:32 2026. Language/Generator: C/C++ Specification: gl @@ -10,6 +10,7 @@ GL_EXT_buffer_storage, GL_EXT_clip_cull_distance, GL_EXT_color_buffer_float, + GL_EXT_depth_clamp, GL_EXT_disjoint_timer_query, GL_EXT_gpu_shader5, GL_EXT_multisampled_render_to_texture, @@ -27,9 +28,9 @@ Reproducible: False Commandline: - --profile="core" --api="gles2=3.2" --generator="c" --spec="gl" --extensions="GL_EXT_buffer_storage,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_disjoint_timer_query,GL_EXT_gpu_shader5,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_format_BGRA8888,GL_KHR_debug,GL_KHR_texture_compression_astc_ldr,GL_OES_get_program_binary" + --profile="core" --api="gles2=3.2" --generator="c" --spec="gl" --extensions="GL_EXT_buffer_storage,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_depth_clamp,GL_EXT_disjoint_timer_query,GL_EXT_gpu_shader5,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_format_BGRA8888,GL_KHR_debug,GL_KHR_texture_compression_astc_ldr,GL_OES_get_program_binary" Online: - https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gles2%3D3.2&extensions=GL_EXT_buffer_storage&extensions=GL_EXT_clip_cull_distance&extensions=GL_EXT_color_buffer_float&extensions=GL_EXT_disjoint_timer_query&extensions=GL_EXT_gpu_shader5&extensions=GL_EXT_multisampled_render_to_texture&extensions=GL_EXT_multisampled_render_to_texture2&extensions=GL_EXT_texture_compression_bptc&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_format_BGRA8888&extensions=GL_KHR_debug&extensions=GL_KHR_texture_compression_astc_ldr&extensions=GL_OES_get_program_binary + https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gles2%3D3.2&extensions=GL_EXT_buffer_storage&extensions=GL_EXT_clip_cull_distance&extensions=GL_EXT_color_buffer_float&extensions=GL_EXT_depth_clamp&extensions=GL_EXT_disjoint_timer_query&extensions=GL_EXT_gpu_shader5&extensions=GL_EXT_multisampled_render_to_texture&extensions=GL_EXT_multisampled_render_to_texture2&extensions=GL_EXT_texture_compression_bptc&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_format_BGRA8888&extensions=GL_KHR_debug&extensions=GL_KHR_texture_compression_astc_ldr&extensions=GL_OES_get_program_binary */ @@ -2257,6 +2258,7 @@ GLAPI PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample; #define GL_CLIP_DISTANCE5_EXT 0x3005 #define GL_CLIP_DISTANCE6_EXT 0x3006 #define GL_CLIP_DISTANCE7_EXT 0x3007 +#define GL_DEPTH_CLAMP_EXT 0x864F #define GL_QUERY_COUNTER_BITS_EXT 0x8864 #define GL_CURRENT_QUERY_EXT 0x8865 #define GL_QUERY_RESULT_EXT 0x8866 @@ -2366,6 +2368,10 @@ GLAPI int GLAD_GL_EXT_clip_cull_distance; #define GL_EXT_color_buffer_float 1 GLAPI int GLAD_GL_EXT_color_buffer_float; #endif +#ifndef GL_EXT_depth_clamp +#define GL_EXT_depth_clamp 1 +GLAPI int GLAD_GL_EXT_depth_clamp; +#endif #ifndef GL_EXT_disjoint_timer_query #define GL_EXT_disjoint_timer_query 1 GLAPI int GLAD_GL_EXT_disjoint_timer_query; diff --git a/lib/opengl/gl/glad_es/src/glad.c b/lib/opengl/gl/glad_es/src/glad.c index e7bae0f7860..df24c8490ef 100644 --- a/lib/opengl/gl/glad_es/src/glad.c +++ b/lib/opengl/gl/glad_es/src/glad.c @@ -1,6 +1,6 @@ /* - OpenGL ES loader generated by glad 0.1.36 on Wed Aug 27 15:16:54 2025. + OpenGL ES loader generated by glad 0.1.36 on Sat Jul 4 19:49:32 2026. Language/Generator: C/C++ Specification: gl @@ -10,6 +10,7 @@ GL_EXT_buffer_storage, GL_EXT_clip_cull_distance, GL_EXT_color_buffer_float, + GL_EXT_depth_clamp, GL_EXT_disjoint_timer_query, GL_EXT_gpu_shader5, GL_EXT_multisampled_render_to_texture, @@ -27,9 +28,9 @@ Reproducible: False Commandline: - --profile="core" --api="gles2=3.2" --generator="c" --spec="gl" --extensions="GL_EXT_buffer_storage,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_disjoint_timer_query,GL_EXT_gpu_shader5,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_format_BGRA8888,GL_KHR_debug,GL_KHR_texture_compression_astc_ldr,GL_OES_get_program_binary" + --profile="core" --api="gles2=3.2" --generator="c" --spec="gl" --extensions="GL_EXT_buffer_storage,GL_EXT_clip_cull_distance,GL_EXT_color_buffer_float,GL_EXT_depth_clamp,GL_EXT_disjoint_timer_query,GL_EXT_gpu_shader5,GL_EXT_multisampled_render_to_texture,GL_EXT_multisampled_render_to_texture2,GL_EXT_texture_compression_bptc,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_EXT_texture_format_BGRA8888,GL_KHR_debug,GL_KHR_texture_compression_astc_ldr,GL_OES_get_program_binary" Online: - https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gles2%3D3.2&extensions=GL_EXT_buffer_storage&extensions=GL_EXT_clip_cull_distance&extensions=GL_EXT_color_buffer_float&extensions=GL_EXT_disjoint_timer_query&extensions=GL_EXT_gpu_shader5&extensions=GL_EXT_multisampled_render_to_texture&extensions=GL_EXT_multisampled_render_to_texture2&extensions=GL_EXT_texture_compression_bptc&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_format_BGRA8888&extensions=GL_KHR_debug&extensions=GL_KHR_texture_compression_astc_ldr&extensions=GL_OES_get_program_binary + https://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gles2%3D3.2&extensions=GL_EXT_buffer_storage&extensions=GL_EXT_clip_cull_distance&extensions=GL_EXT_color_buffer_float&extensions=GL_EXT_depth_clamp&extensions=GL_EXT_disjoint_timer_query&extensions=GL_EXT_gpu_shader5&extensions=GL_EXT_multisampled_render_to_texture&extensions=GL_EXT_multisampled_render_to_texture2&extensions=GL_EXT_texture_compression_bptc&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_EXT_texture_format_BGRA8888&extensions=GL_KHR_debug&extensions=GL_KHR_texture_compression_astc_ldr&extensions=GL_OES_get_program_binary */ #include @@ -501,6 +502,7 @@ PFNGLWAITSYNCPROC glad_glWaitSync = NULL; int GLAD_GL_EXT_buffer_storage = 0; int GLAD_GL_EXT_clip_cull_distance = 0; int GLAD_GL_EXT_color_buffer_float = 0; +int GLAD_GL_EXT_depth_clamp = 0; int GLAD_GL_EXT_disjoint_timer_query = 0; int GLAD_GL_EXT_gpu_shader5 = 0; int GLAD_GL_EXT_multisampled_render_to_texture = 0; @@ -969,6 +971,7 @@ static int find_extensionsGLES2(void) { GLAD_GL_EXT_buffer_storage = has_ext("GL_EXT_buffer_storage"); GLAD_GL_EXT_clip_cull_distance = has_ext("GL_EXT_clip_cull_distance"); GLAD_GL_EXT_color_buffer_float = has_ext("GL_EXT_color_buffer_float"); + GLAD_GL_EXT_depth_clamp = has_ext("GL_EXT_depth_clamp"); GLAD_GL_EXT_disjoint_timer_query = has_ext("GL_EXT_disjoint_timer_query"); GLAD_GL_EXT_gpu_shader5 = has_ext("GL_EXT_gpu_shader5"); GLAD_GL_EXT_multisampled_render_to_texture = has_ext("GL_EXT_multisampled_render_to_texture");