Merge branch 'master' of https://github.com/supertuxkart/stk-code into lights
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
@@ -8,13 +8,8 @@ uniform vec3 inlevel;
|
||||
uniform vec2 outlevel;
|
||||
uniform mat4 invprojm;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
uniform ivec4 color;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
uniform vec3 col;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec4 col;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
varying vec4 col;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -8,15 +8,9 @@ uniform sampler2D Detail;
|
||||
uniform sampler2D SpecMap;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
|
||||
@@ -5,18 +5,11 @@ uniform sampler2D tex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
in float camdist;
|
||||
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
varying float camdist;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
const float maxlen = 0.02;
|
||||
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
uniform sampler2D tex;
|
||||
uniform vec3 col;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -5,13 +5,8 @@ uniform vec2 sunpos;
|
||||
|
||||
const float decaystep = 0.88;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -4,14 +4,9 @@ layout(bindless_sampler) uniform sampler2D tex;
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
#else
|
||||
varying vec3 nor;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
|
||||
@@ -6,13 +6,8 @@ layout(bindless_sampler) uniform sampler2D tex;
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec3 nor;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
@@ -6,15 +6,9 @@ uniform sampler2D tex;
|
||||
uniform sampler2D glosstex;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
#else
|
||||
varying vec3 nor;
|
||||
varying vec2 uv;
|
||||
#define EncodedNormal gl_FragColor.xy
|
||||
#endif
|
||||
|
||||
vec2 EncodeNormal(vec3 n);
|
||||
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
uniform samplerCube tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
@@ -12,15 +12,9 @@ uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
varying vec2 uv_bis;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapValue, float emitMapValue);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2DArray shadowtex;
|
||||
uniform sampler2DArrayShadow shadowtex;
|
||||
|
||||
uniform float split0;
|
||||
uniform float split1;
|
||||
@@ -22,10 +22,17 @@ float getShadowFactor(vec3 pos, int index)
|
||||
vec4 shadowcoord = (ShadowViewProjMatrixes[index] * InverseViewMatrix * vec4(pos, 1.0));
|
||||
shadowcoord.xy /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
float d = .5 * shadowcoord.z + .5;
|
||||
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord, float(index))).x;
|
||||
float d = shadowcoord.z;
|
||||
return min(pow(exp(-32. * d) * z, 8.), 1.);
|
||||
float result = 0.;
|
||||
|
||||
for (float i = -1.; i <= 1.; i += 1.)
|
||||
{
|
||||
for (float j = -1.; j <= 1.; j += 1.)
|
||||
result += texture(shadowtex, vec4(shadowtexcoord + vec2(i,j) / 1024., float(index), d));
|
||||
}
|
||||
|
||||
return result / 9.;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
61
data/shaders/sunlightshadowesm.frag
Normal file
61
data/shaders/sunlightshadowesm.frag
Normal file
@@ -0,0 +1,61 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2DArray shadowtex;
|
||||
|
||||
uniform float split0;
|
||||
uniform float split1;
|
||||
uniform float split2;
|
||||
uniform float splitmax;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
|
||||
vec3 DecodeNormal(vec2 n);
|
||||
vec3 SpecularBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec3 DiffuseBRDF(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness);
|
||||
vec4 getPosFromUVDepth(vec3 uvDepth, mat4 InverseProjectionMatrix);
|
||||
vec3 SunMRP(vec3 normal, vec3 eyedir);
|
||||
|
||||
float getShadowFactor(vec3 pos, int index)
|
||||
{
|
||||
vec4 shadowcoord = (ShadowViewProjMatrixes[index] * InverseViewMatrix * vec4(pos, 1.0));
|
||||
shadowcoord.xy /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord, float(index))).x;
|
||||
float d = shadowcoord.z;
|
||||
return min(pow(exp(-32. * d) * z, 8.), 1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy / screen;
|
||||
float z = texture(dtex, uv).x;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
||||
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
float roughness =texture(ntex, uv).z;
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
vec3 Lightdir = SunMRP(norm, eyedir);
|
||||
float NdotL = clamp(dot(norm, Lightdir), 0., 1.);
|
||||
|
||||
vec3 Specular = SpecularBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
||||
vec3 Diffuse = DiffuseBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
||||
|
||||
// Shadows
|
||||
float factor;
|
||||
if (xpos.z < split0)
|
||||
factor = getShadowFactor(xpos.xyz, 0);
|
||||
else if (xpos.z < split1)
|
||||
factor = getShadowFactor(xpos.xyz, 1);
|
||||
else if (xpos.z < split2)
|
||||
factor = getShadowFactor(xpos.xyz, 2);
|
||||
else if (xpos.z < splitmax)
|
||||
factor = getShadowFactor(xpos.xyz, 3);
|
||||
else
|
||||
factor = 1.;
|
||||
|
||||
Diff = vec4(factor * NdotL * Diffuse * sun_col, 1.);
|
||||
Spec = vec4(factor * NdotL * Specular * sun_col, 1.);
|
||||
}
|
||||
@@ -1,13 +1,7 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
uniform sampler2D tex;
|
||||
uniform ivec4 color;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
varying vec4 color;
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
vec3 getLightFactor(float specMapValue);
|
||||
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
#if __VERSION__ >= 130
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define FragColor gl_FragColor
|
||||
#endif
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user