1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 06:53:53 +00:00

Sort out shader indentation

This commit is contained in:
AnyOldName3 2018-06-22 01:02:01 +01:00
parent f8e4f3fca5
commit b25b356081
7 changed files with 117 additions and 117 deletions

View file

@ -3,12 +3,12 @@
void perLight(out vec3 ambientOut, out vec3 diffuseOut, int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3 ambient) void perLight(out vec3 ambientOut, out vec3 diffuseOut, int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3 ambient)
{ {
vec3 lightDir; vec3 lightDir;
float lightDistance; float lightDistance;
lightDir = gl_LightSource[lightIndex].position.xyz - (viewPos.xyz * gl_LightSource[lightIndex].position.w); lightDir = gl_LightSource[lightIndex].position.xyz - (viewPos.xyz * gl_LightSource[lightIndex].position.w);
lightDistance = length(lightDir); lightDistance = length(lightDir);
lightDir = normalize(lightDir); lightDir = normalize(lightDir);
float illumination = clamp(1.0 / (gl_LightSource[lightIndex].constantAttenuation + gl_LightSource[lightIndex].linearAttenuation * lightDistance + gl_LightSource[lightIndex].quadraticAttenuation * lightDistance * lightDistance), 0.0, 1.0); float illumination = clamp(1.0 / (gl_LightSource[lightIndex].constantAttenuation + gl_LightSource[lightIndex].linearAttenuation * lightDistance + gl_LightSource[lightIndex].quadraticAttenuation * lightDistance * lightDistance), 0.0, 1.0);
ambientOut = ambient * gl_LightSource[lightIndex].ambient.xyz * illumination; ambientOut = ambient * gl_LightSource[lightIndex].ambient.xyz * illumination;
diffuseOut = diffuse.xyz * gl_LightSource[lightIndex].diffuse.xyz * max(dot(viewNormal.xyz, lightDir), 0.0) * illumination; diffuseOut = diffuse.xyz * gl_LightSource[lightIndex].diffuse.xyz * max(dot(viewNormal.xyz, lightDir), 0.0) * illumination;
@ -38,7 +38,7 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadow
lightResult.xyz += ambientLight + diffuseLight * shadowing; lightResult.xyz += ambientLight + diffuseLight * shadowing;
#else #else
shadowDiffuse = diffuseLight; shadowDiffuse = diffuseLight;
lightResult.xyz += ambientLight; lightResult.xyz += ambientLight;
#endif #endif
for (int i=1; i<MAX_LIGHTS; ++i) for (int i=1; i<MAX_LIGHTS; ++i)
{ {

View file

@ -58,10 +58,10 @@ varying vec3 passViewPos;
varying vec3 passNormal; varying vec3 passNormal;
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index; uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
#include "lighting.glsl" #include "lighting.glsl"
@ -122,28 +122,28 @@ void main()
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, decalTex.xyz, decalTex.a); gl_FragData[0].xyz = mix(gl_FragData[0].xyz, decalTex.xyz, decalTex.a);
#endif #endif
float shadowing = 1.0; float shadowing = 1.0;
#if SHADOWS #if SHADOWS
#if @shadowMapsOverlap #if @shadowMapsOverlap
bool doneShadows = false; bool doneShadows = false;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneShadows) if (!doneShadows)
{ {
vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w; vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w;
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0)))) if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
{ {
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05)))) if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
doneShadows = true; doneShadows = true;
} }
} }
@endforeach @endforeach
#else #else
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
@endforeach @endforeach
#endif #endif
#endif // SHADOWS #endif // SHADOWS
#if !PER_PIXEL_LIGHTING #if !PER_PIXEL_LIGHTING

View file

@ -49,10 +49,10 @@ varying vec3 passViewPos;
varying vec3 passNormal; varying vec3 passNormal;
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform int shadowTextureUnit@shadow_texture_unit_index; uniform int shadowTextureUnit@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
#include "lighting.glsl" #include "lighting.glsl"
@ -111,11 +111,11 @@ void main(void)
passNormal = gl_Normal.xyz; passNormal = gl_Normal.xyz;
#if SHADOWS #if SHADOWS
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner. // This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
mat4 eyePlaneMat; mat4 eyePlaneMat;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]); eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]);
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat; shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
} }

View file

@ -28,10 +28,10 @@ varying vec3 passViewPos;
varying vec3 passNormal; varying vec3 passNormal;
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index; uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
#include "lighting.glsl" #include "lighting.glsl"
@ -74,28 +74,28 @@ void main()
gl_FragData[0].a *= texture2D(blendMap, blendMapUV).a; gl_FragData[0].a *= texture2D(blendMap, blendMapUV).a;
#endif #endif
float shadowing = 1.0; float shadowing = 1.0;
#if SHADOWS #if SHADOWS
#if @shadowMapsOverlap #if @shadowMapsOverlap
bool doneShadows = false; bool doneShadows = false;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneShadows) if (!doneShadows)
{ {
vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w; vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w;
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0)))) if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
{ {
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05)))) if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
doneShadows = true; doneShadows = true;
} }
} }
@endforeach @endforeach
#else #else
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
@endforeach @endforeach
#endif #endif
#endif // SHADOWS #endif // SHADOWS
#if !PER_PIXEL_LIGHTING #if !PER_PIXEL_LIGHTING

View file

@ -17,10 +17,10 @@ varying vec3 passViewPos;
varying vec3 passNormal; varying vec3 passNormal;
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform int shadowTextureUnit@shadow_texture_unit_index; uniform int shadowTextureUnit@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
#include "lighting.glsl" #include "lighting.glsl"
@ -45,11 +45,11 @@ void main(void)
uv = gl_MultiTexCoord0.xy; uv = gl_MultiTexCoord0.xy;
#if SHADOWS #if SHADOWS
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner. // This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
mat4 eyePlaneMat; mat4 eyePlaneMat;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]); eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]);
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat; shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
} }

View file

@ -144,10 +144,10 @@ uniform vec3 nodePosition;
uniform float rainIntensity; uniform float rainIntensity;
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index; uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
float frustumDepth; float frustumDepth;
@ -167,31 +167,31 @@ void main(void)
UV.y *= -1.0; UV.y *= -1.0;
#if SHADOWS #if SHADOWS
float shadowing = 1.0; float shadowing = 1.0;
#if @shadowMapsOverlap #if @shadowMapsOverlap
bool doneShadows = false; bool doneShadows = false;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
if (!doneShadows) if (!doneShadows)
{ {
vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w; vec2 shadowXY = shadowSpaceCoords@shadow_texture_unit_index.xy / shadowSpaceCoords@shadow_texture_unit_index.w;
if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0)))) if (all(lessThan(shadowXY, vec2(1.0, 1.0))) && all(greaterThan(shadowXY, vec2(0.0, 0.0))))
{ {
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05)))) if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
doneShadows = true; doneShadows = true;
} }
} }
@endforeach @endforeach
#else #else
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r; shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
@endforeach @endforeach
#endif #endif
float shadow = shadowing; float shadow = shadowing;
#else // NOT SHADOWS #else // NOT SHADOWS
float shadow = 1.0; float shadow = 1.0;
#endif // SHADOWS #endif // SHADOWS
vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z; vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
@ -218,8 +218,8 @@ void main(void)
vec3 rippleAdd = rainRipple.xyz * rainRipple.w * 10.0; vec3 rippleAdd = rainRipple.xyz * rainRipple.w * 10.0;
vec3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y + vec3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y + normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y + normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y +
rippleAdd); rippleAdd);
normal = normalize(vec3(normal.x * BUMP, normal.y * BUMP, normal.z)); normal = normalize(vec3(normal.x * BUMP, normal.y * BUMP, normal.z));
@ -228,8 +228,8 @@ void main(void)
// normal for sunlight scattering // normal for sunlight scattering
vec3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 + vec3 lNormal = (normal0 * BIG_WAVES_X*0.5 + normal1 * BIG_WAVES_Y*0.5 +
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 + normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1 + normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1 +
rippleAdd).xyz; rippleAdd).xyz;
lNormal = normalize(vec3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z)); lNormal = normalize(vec3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z));

View file

@ -7,10 +7,10 @@ varying float depthPassthrough;
#define SHADOWS @shadows_enabled #define SHADOWS @shadows_enabled
#if SHADOWS #if SHADOWS
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
uniform int shadowTextureUnit@shadow_texture_unit_index; uniform int shadowTextureUnit@shadow_texture_unit_index;
varying vec4 shadowSpaceCoords@shadow_texture_unit_index; varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
void main(void) void main(void)
@ -18,9 +18,9 @@ void main(void)
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0, mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
0.0, -0.5, 0.0, 0.0, 0.0, -0.5, 0.0, 0.0,
0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.5, 0.0,
0.5, 0.5, 0.5, 1.0); 0.5, 0.5, 0.5, 1.0);
vec4 texcoordProj = ((scalemat) * ( gl_Position)); vec4 texcoordProj = ((scalemat) * ( gl_Position));
screenCoordsPassthrough = vec3(texcoordProj.x, texcoordProj.y, texcoordProj.w); screenCoordsPassthrough = vec3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
@ -29,14 +29,14 @@ void main(void)
depthPassthrough = gl_Position.z; depthPassthrough = gl_Position.z;
#if SHADOWS #if SHADOWS
vec4 viewPos = gl_ModelViewMatrix * gl_Vertex; vec4 viewPos = gl_ModelViewMatrix * gl_Vertex;
// This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner. // This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner.
mat4 eyePlaneMat; mat4 eyePlaneMat;
@foreach shadow_texture_unit_index @shadow_texture_unit_list @foreach shadow_texture_unit_index @shadow_texture_unit_list
eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]); eyePlaneMat = mat4(gl_EyePlaneS[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneT[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneR[shadowTextureUnit@shadow_texture_unit_index], gl_EyePlaneQ[shadowTextureUnit@shadow_texture_unit_index]);
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat; shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
@endforeach @endforeach
#endif // SHADOWS #endif // SHADOWS
} }