Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion code/def_files/data/effects/batched-f.sdr
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2DArray;
#endif

#include "gamma.sdr"

in vec4 fragTexCoord;
in vec4 fragColor;

out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;

uniform sampler2DArray baseMap;

Expand Down
5 changes: 5 additions & 0 deletions code/def_files/data/effects/batched-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#ifdef GL_ES
precision highp float;
precision highp int;
#endif

in vec4 vertPosition;
in vec4 vertTexCoord;
in vec4 vertColor;
Expand Down
7 changes: 6 additions & 1 deletion code/def_files/data/effects/bloom-comp-f.sdr
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
#endif

in vec4 fragTexCoord;

out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;

uniform sampler2D bloomed;

Expand Down
8 changes: 7 additions & 1 deletion code/def_files/data/effects/blur-f.sdr
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
out vec4 fragOut0;
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
#endif

layout (location=0) out vec4 fragOut0;

in vec4 fragTexCoord;

Expand Down
8 changes: 7 additions & 1 deletion code/def_files/data/effects/brightpass-f.sdr
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
#endif

in vec4 fragTexCoord;
out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;
uniform sampler2D tex;
const float Luminance = 0.08;
const float fMiddleGray = 0.2;
Expand Down
11 changes: 9 additions & 2 deletions code/def_files/data/effects/copy-f.sdr
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
#endif

in vec4 fragTexCoord;
out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;

#ifdef COPY_ARRAY
uniform sampler2DArray tex;
Expand All @@ -10,7 +17,7 @@ uniform sampler2D tex;
void main()
{
#ifdef COPY_ARRAY
fragOut0 = texture(tex, vec3(fragTexCoord.xy, 0));
fragOut0 = texture(tex, vec3(fragTexCoord.xy, 0.0));
#else
fragOut0 = texture(tex, fragTexCoord.xy);
#endif
Expand Down
20 changes: 16 additions & 4 deletions code/def_files/data/effects/decal-f.sdr
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -6,9 +12,15 @@
#include "normals.sdr"
#include "gamma.sdr"

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;
Expand Down Expand Up @@ -82,7 +94,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;
}
Expand Down
6 changes: 6 additions & 0 deletions code/def_files/data/effects/decal-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
#endif

in vec4 vertPosition;
in mat4 vertModelMatrix;
Expand Down
20 changes: 14 additions & 6 deletions code/def_files/data/effects/deferred-clear-f.sdr
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
out vec4 fragOut0;
out vec4 fragOut1;
out vec4 fragOut2;
out vec4 fragOut3;
out vec4 fragOut4;
out vec4 fragOut5;
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
#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
Expand Down
28 changes: 20 additions & 8 deletions code/def_files/data/effects/deferred-f.sdr
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
//? #version 150
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#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"

out vec4 fragOut0;
#ifndef GL_ES
layout(location = 0) out vec4 fragOut0;
#else
layout(location = 5) out vec4 fragOut0;
#endif

uniform sampler2D ColorBuffer;
uniform sampler2D NormalBuffer;
Expand Down Expand Up @@ -93,7 +105,7 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li
lightDirOut = ExpandLightSize(lightDirOut, reflectDir);
dist = length(lightDirOut);
// 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
Expand Down Expand Up @@ -135,7 +147,7 @@ void GetLightInfo(vec3 position, in float alpha, in vec3 reflectDir, out vec3 li
lightDirOut = ExpandLightSize(lightDirOut, reflectDir);
float dist = length(lightDirOut);
// 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
Expand Down Expand Up @@ -181,11 +193,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.
Expand All @@ -203,7 +215,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;
Expand Down Expand Up @@ -273,6 +285,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));
}
7 changes: 7 additions & 0 deletions code/def_files/data/effects/deferred-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#endif

#include "lighting.sdr"

Expand Down
9 changes: 8 additions & 1 deletion code/def_files/data/effects/effect-distort-f.sdr
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
#endif

in vec4 fragTexCoord;
in vec4 fragColor;
in float fragOffset;

out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;

uniform sampler2DArray baseMap;
uniform sampler2D depthMap;
Expand Down
7 changes: 7 additions & 0 deletions code/def_files/data/effects/effect-distort-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
#endif

in vec4 vertPosition;
in vec4 vertTexCoord;
in vec4 vertColor;
Expand Down
9 changes: 8 additions & 1 deletion code/def_files/data/effects/effect-f.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#endif

#include "gamma.sdr"
#include "z-compress.sdr"
Expand All @@ -7,7 +14,7 @@ in vec4 fragPosition;
in vec4 fragTexCoord;
in vec4 fragColor;

out vec4 fragOut0;
layout (location=0) out vec4 fragOut0;

uniform sampler2DArray baseMap;
uniform sampler2D depthMap;
Expand Down
8 changes: 8 additions & 0 deletions code/def_files/data/effects/effect-g.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#endif

layout (points) in;
layout (triangle_strip, max_vertices = 4) out;

Expand Down
7 changes: 7 additions & 0 deletions code/def_files/data/effects/effect-v.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#endif

in vec4 vertPosition;
in vec4 vertTexCoord;
Expand Down
10 changes: 7 additions & 3 deletions code/def_files/data/effects/envmap-sphere-warp-f.sdr
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#define M_PI 3.1415926535897932384626433832795
#ifdef GL_ES
precision highp float;
precision highp int;
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);
Expand Down
11 changes: 8 additions & 3 deletions code/def_files/data/effects/fog-f.sdr
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#ifdef GL_ES
precision highp float;
precision highp int;
precision highp sampler2D;
#endif

#include "gamma.sdr"

in vec4 fragTexCoord;

out vec4 fragOut0;
layout(location=0) out vec4 fragOut0;

uniform sampler2D tex;
uniform sampler2D depth_tex;
Expand All @@ -27,7 +32,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));

Expand All @@ -37,7 +42,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);
Expand Down
18 changes: 17 additions & 1 deletion code/def_files/data/effects/fxaa-f.sdr
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#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 int;
precision highp sampler2D;
precision highp sampler2DArray;
precision highp samplerCube;
#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
Expand Down Expand Up @@ -489,8 +501,12 @@ FxaaFloat4 FxaaPixelShader(
}
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;
void main() {
fragOut0 = FxaaPixelShader(v_pos, tex0, v_rcpFrame, FXAA_QUALITY_SUBPIX, FXAA_QUALITY_EDGE_THRESHOLD, FXAA_QUALITY_EDGE_THRESHOLD_MIN);
}
Loading
Loading