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:
parent
f8e4f3fca5
commit
b25b356081
7 changed files with 117 additions and 117 deletions
|
@ -3,12 +3,12 @@
|
|||
void perLight(out vec3 ambientOut, out vec3 diffuseOut, int lightIndex, vec3 viewPos, vec3 viewNormal, vec4 diffuse, vec3 ambient)
|
||||
{
|
||||
vec3 lightDir;
|
||||
float lightDistance;
|
||||
float lightDistance;
|
||||
|
||||
lightDir = gl_LightSource[lightIndex].position.xyz - (viewPos.xyz * gl_LightSource[lightIndex].position.w);
|
||||
lightDistance = length(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;
|
||||
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;
|
||||
#else
|
||||
shadowDiffuse = diffuseLight;
|
||||
lightResult.xyz += ambientLight;
|
||||
lightResult.xyz += ambientLight;
|
||||
#endif
|
||||
for (int i=1; i<MAX_LIGHTS; ++i)
|
||||
{
|
||||
|
|
|
@ -58,10 +58,10 @@ varying vec3 passViewPos;
|
|||
varying vec3 passNormal;
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -122,28 +122,28 @@ void main()
|
|||
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, decalTex.xyz, decalTex.a);
|
||||
#endif
|
||||
|
||||
float shadowing = 1.0;
|
||||
float shadowing = 1.0;
|
||||
#if SHADOWS
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
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))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
#endif // SHADOWS
|
||||
|
||||
#if !PER_PIXEL_LIGHTING
|
||||
|
|
|
@ -49,10 +49,10 @@ varying vec3 passViewPos;
|
|||
varying vec3 passNormal;
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -111,11 +111,11 @@ void main(void)
|
|||
passNormal = gl_Normal.xyz;
|
||||
|
||||
#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.
|
||||
mat4 eyePlaneMat;
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
// 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;
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ varying vec3 passViewPos;
|
|||
varying vec3 passNormal;
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -74,28 +74,28 @@ void main()
|
|||
gl_FragData[0].a *= texture2D(blendMap, blendMapUV).a;
|
||||
#endif
|
||||
|
||||
float shadowing = 1.0;
|
||||
float shadowing = 1.0;
|
||||
#if SHADOWS
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
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))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
#endif // SHADOWS
|
||||
|
||||
#if !PER_PIXEL_LIGHTING
|
||||
|
|
|
@ -17,10 +17,10 @@ varying vec3 passViewPos;
|
|||
varying vec3 passNormal;
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
@ -45,11 +45,11 @@ void main(void)
|
|||
uv = gl_MultiTexCoord0.xy;
|
||||
|
||||
#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.
|
||||
mat4 eyePlaneMat;
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
// 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;
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
}
|
||||
|
|
|
@ -144,10 +144,10 @@ uniform vec3 nodePosition;
|
|||
uniform float rainIntensity;
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform sampler2DShadow shadowTexture@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
float frustumDepth;
|
||||
|
@ -167,31 +167,31 @@ void main(void)
|
|||
UV.y *= -1.0;
|
||||
|
||||
#if SHADOWS
|
||||
float shadowing = 1.0;
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
float shadowing = 1.0;
|
||||
#if @shadowMapsOverlap
|
||||
bool doneShadows = false;
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
if (!doneShadows)
|
||||
{
|
||||
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))))
|
||||
{
|
||||
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))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
if (all(lessThan(shadowXY, vec2(0.95, 0.95))) && all(greaterThan(shadowXY, vec2(0.05, 0.05))))
|
||||
doneShadows = true;
|
||||
}
|
||||
}
|
||||
@endforeach
|
||||
#else
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
shadowing *= shadow2DProj(shadowTexture@shadow_texture_unit_index, shadowSpaceCoords@shadow_texture_unit_index).r;
|
||||
@endforeach
|
||||
#endif
|
||||
|
||||
float shadow = shadowing;
|
||||
float shadow = shadowing;
|
||||
#else // NOT SHADOWS
|
||||
float shadow = 1.0;
|
||||
float shadow = 1.0;
|
||||
#endif // SHADOWS
|
||||
|
||||
vec2 screenCoords = screenCoordsPassthrough.xy / screenCoordsPassthrough.z;
|
||||
|
@ -218,8 +218,8 @@ void main(void)
|
|||
vec3 rippleAdd = rainRipple.xyz * rainRipple.w * 10.0;
|
||||
|
||||
vec3 normal = (normal0 * BIG_WAVES_X + normal1 * BIG_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y +
|
||||
normal2 * MID_WAVES_X + normal3 * MID_WAVES_Y +
|
||||
normal4 * SMALL_WAVES_X + normal5 * SMALL_WAVES_Y +
|
||||
rippleAdd);
|
||||
|
||||
normal = normalize(vec3(normal.x * BUMP, normal.y * BUMP, normal.z));
|
||||
|
@ -228,8 +228,8 @@ void main(void)
|
|||
|
||||
// normal for sunlight scattering
|
||||
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 +
|
||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1 +
|
||||
normal2 * MID_WAVES_X*0.2 + normal3 * MID_WAVES_Y*0.2 +
|
||||
normal4 * SMALL_WAVES_X*0.1 + normal5 * SMALL_WAVES_Y*0.1 +
|
||||
rippleAdd).xyz;
|
||||
|
||||
lNormal = normalize(vec3(lNormal.x * BUMP, lNormal.y * BUMP, lNormal.z));
|
||||
|
|
|
@ -7,10 +7,10 @@ varying float depthPassthrough;
|
|||
#define SHADOWS @shadows_enabled
|
||||
|
||||
#if SHADOWS
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
@foreach shadow_texture_unit_index @shadow_texture_unit_list
|
||||
uniform int shadowTextureUnit@shadow_texture_unit_index;
|
||||
varying vec4 shadowSpaceCoords@shadow_texture_unit_index;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
|
||||
void main(void)
|
||||
|
@ -18,9 +18,9 @@ void main(void)
|
|||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
|
||||
mat4 scalemat = mat4(0.5, 0.0, 0.0, 0.0,
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 0.5, 0.0,
|
||||
0.5, 0.5, 0.5, 1.0);
|
||||
0.0, -0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 0.5, 0.0,
|
||||
0.5, 0.5, 0.5, 1.0);
|
||||
|
||||
vec4 texcoordProj = ((scalemat) * ( gl_Position));
|
||||
screenCoordsPassthrough = vec3(texcoordProj.x, texcoordProj.y, texcoordProj.w);
|
||||
|
@ -29,14 +29,14 @@ void main(void)
|
|||
|
||||
depthPassthrough = gl_Position.z;
|
||||
|
||||
#if SHADOWS
|
||||
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.
|
||||
mat4 eyePlaneMat;
|
||||
#if SHADOWS
|
||||
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.
|
||||
mat4 eyePlaneMat;
|
||||
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
@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]);
|
||||
shadowSpaceCoords@shadow_texture_unit_index = viewPos * eyePlaneMat;
|
||||
@endforeach
|
||||
#endif // SHADOWS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue