Merge branch 'shaders_formatting' into 'master'

Improve shaders formatting

See merge request OpenMW/openmw!2950
7344-support-launching-the-example-suite
psi29a 2 years ago
commit 88969d5725

@ -5,8 +5,8 @@
uniform vec3 color; uniform vec3 color;
uniform vec3 trans; uniform vec3 trans;
uniform vec3 scale; uniform vec3 scale;
uniform bool useNormalAsColor; uniform bool useNormalAsColor;
uniform bool useAdvancedShader = false; uniform bool useAdvancedShader = false;
centroid varying vec4 passColor; centroid varying vec4 passColor;
varying vec3 vertexNormal; varying vec3 vertexNormal;
@ -27,5 +27,4 @@ void main()
vec3 colorOut = useNormalAsColor? gl_Normal.xyz : color; vec3 colorOut = useNormalAsColor? gl_Normal.xyz : color;
passColor = vec4(colorOut, 1.); passColor = vec4(colorOut, 1.);
} }
} }

@ -6,13 +6,13 @@ uniform sampler2DArray lastShader;
void main() void main()
{ {
int view = 0; int view = 0;
vec3 uvz = vec3(uv.x * 2., uv.y, 0); vec3 uvz = vec3(uv.x * 2., uv.y, 0);
if(uvz.x > 1.) if(uvz.x > 1.)
{ {
uvz.x -= 1.; uvz.x -= 1.;
uvz.z = 1; uvz.z = 1;
} }
gl_FragColor = texture2DArray(lastShader, uvz); gl_FragColor = texture2DArray(lastShader, uvz);
} }

@ -27,7 +27,6 @@ void main()
texture2D(imageIn, uv + vec2(0.0, -oneAndHalfOffset)).r texture2D(imageIn, uv + vec2(0.0, -oneAndHalfOffset)).r
); );
vec4 color = texture2D(imageIn, uv); vec4 color = texture2D(imageIn, uv);
gl_FragColor = applySprings(color, n, n2); gl_FragColor = applySprings(color, n, n2);

@ -35,7 +35,6 @@ float unshadowedLightRatio(float distance)
{ {
shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing); shadowing = min(shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r, shadowing);
doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0))); doneShadows = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));
#if @perspectiveShadowMaps #if @perspectiveShadowMaps
doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0))); doneShadows = doneShadows && all(lessThan(shadowRegionXYZ, vec3(1.0, 1.0, 1.0))) && all(greaterThan(shadowRegionXYZ.xy, vec2(-1.0, -1.0)));
@ -70,12 +69,12 @@ void applyShadowDebugOverlay()
if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0)))) if (all(lessThan(shadowXYZ.xy, vec2(1.0, 1.0))) && all(greaterThan(shadowXYZ.xy, vec2(0.0, 0.0))))
{ {
colourIndex = mod(@shadow_texture_unit_index.0, 3.0); colourIndex = mod(@shadow_texture_unit_index.0, 3.0);
if (colourIndex < 1.0) if (colourIndex < 1.0)
gl_FragData[0].x += 0.1; gl_FragData[0].x += 0.1;
else if (colourIndex < 2.0) else if (colourIndex < 2.0)
gl_FragData[0].y += 0.1; gl_FragData[0].y += 0.1;
else else
gl_FragData[0].z += 0.1; gl_FragData[0].z += 0.1;
doneOverlay = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0))); doneOverlay = all(lessThan(shadowXYZ, vec3(0.95, 0.95, 1.0))) && all(greaterThan(shadowXYZ, vec3(0.05, 0.05, 0.0)));
#if @perspectiveShadowMaps #if @perspectiveShadowMaps

@ -79,7 +79,8 @@ void main()
paintSun(color); paintSun(color);
else if (pass == PASS_SUNGLARE) else if (pass == PASS_SUNGLARE)
paintSunglare(color); paintSunglare(color);
else if (pass == PASS_SUNFLASH_QUERY) { else if (pass == PASS_SUNFLASH_QUERY)
{
processSunflashQuery(); processSunflashQuery();
return; return;
} }

@ -113,9 +113,9 @@ void main(void)
vec4 rainRipple; vec4 rainRipple;
if (rainIntensity > 0.01) if (rainIntensity > 0.01)
rainRipple = rainCombined(position.xy/1000.0, waterTimer) * clamp(rainIntensity, 0.0, 1.0); rainRipple = rainCombined(position.xy/1000.0, waterTimer) * clamp(rainIntensity, 0.0, 1.0);
else else
rainRipple = vec4(0.0); rainRipple = vec4(0.0);
vec3 rippleAdd = rainRipple.xyz * 10.0; vec3 rippleAdd = rainRipple.xyz * 10.0;

@ -35,7 +35,8 @@ float calcSoftParticleFade(
const float nearMult = 300.0; const float nearMult = 300.0;
float viewBias = 1.0; float viewBias = 1.0;
if (fade) { if (fade)
{
float VdotN = dot(viewDir, viewNormal); float VdotN = dot(viewDir, viewNormal);
viewBias = abs(VdotN) * quickstep(euclidianDepth / nearMult) * (1.0 - pow(1.0 + VdotN, 1.3)); viewBias = abs(VdotN) * quickstep(euclidianDepth / nearMult) * (1.0 - pow(1.0 + VdotN, 1.3));
} }

@ -4,11 +4,11 @@
float linearizeDepth(float depth, float near, float far) float linearizeDepth(float depth, float near, float far)
{ {
#if @reverseZ #if @reverseZ
depth = 1.0 - depth; depth = 1.0 - depth;
#endif #endif
float z_n = 2.0 * depth - 1.0; float z_n = 2.0 * depth - 1.0;
depth = 2.0 * near * far / (far + near - z_n * (far - near)); depth = 2.0 * near * far / (far + near - z_n * (far - near));
return depth; return depth;
} }
float getLinearDepth(in float z, in float viewZ) float getLinearDepth(in float z, in float viewZ)

@ -1,23 +1,25 @@
#ifndef LIB_WATER_FRESNEL #ifndef LIB_WATER_FRESNEL
#define LIB_WATER_FRESNEL #define LIB_WATER_FRESNEL
float fresnel_dielectric(vec3 Incoming, vec3 Normal, float eta) float fresnel_dielectric(vec3 incoming, vec3 normal, float eta)
{ {
float c = abs(dot(Incoming, Normal)); float c = abs(dot(incoming, normal));
float g = eta * eta - 1.0 + c * c; float g = eta * eta - 1.0 + c * c;
float result; float result;
if (g > 0.0) { if (g > 0.0)
g = sqrt(g); {
float A =(g - c)/(g + c); g = sqrt(g);
float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0); float A =(g - c)/(g + c);
result = 0.5 * A * A *(1.0 + B * B); float B =(c *(g + c)- 1.0)/(c *(g - c)+ 1.0);
} result = 0.5 * A * A *(1.0 + B * B);
else { }
result = 1.0; /* TIR (no refracted component) */ else
} {
result = 1.0; /* TIR (no refracted component) */
}
return result; return result;
} }
#endif #endif

Loading…
Cancel
Save