mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 11:41:33 +00:00
Merge pull request #2902 from Capostrophic/shaders
Don't deliberately do redundant assignments in shaders
This commit is contained in:
commit
e2a4493fc0
3 changed files with 26 additions and 13 deletions
|
@ -29,25 +29,27 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, float shadowing
|
||||||
vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadowDiffuse)
|
vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadowDiffuse)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
vec4 diffuse = gl_FrontMaterial.diffuse;
|
vec4 diffuse;
|
||||||
vec3 ambient = gl_FrontMaterial.ambient.xyz;
|
vec3 ambient;
|
||||||
vec3 emission = gl_FrontMaterial.emission.xyz;
|
|
||||||
if (colorMode == ColorMode_AmbientAndDiffuse)
|
if (colorMode == ColorMode_AmbientAndDiffuse)
|
||||||
{
|
{
|
||||||
diffuse = vertexColor;
|
diffuse = vertexColor;
|
||||||
ambient = vertexColor.xyz;
|
ambient = vertexColor.xyz;
|
||||||
}
|
}
|
||||||
else if (colorMode == ColorMode_Ambient)
|
|
||||||
{
|
|
||||||
ambient = vertexColor.xyz;
|
|
||||||
}
|
|
||||||
else if (colorMode == ColorMode_Diffuse)
|
else if (colorMode == ColorMode_Diffuse)
|
||||||
{
|
{
|
||||||
diffuse = vertexColor;
|
diffuse = vertexColor;
|
||||||
|
ambient = gl_FrontMaterial.ambient.xyz;
|
||||||
}
|
}
|
||||||
else if (colorMode == ColorMode_Emission)
|
else if (colorMode == ColorMode_Ambient)
|
||||||
{
|
{
|
||||||
emission = vertexColor.xyz;
|
diffuse = gl_FrontMaterial.diffuse;
|
||||||
|
ambient = vertexColor.xyz;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diffuse = gl_FrontMaterial.diffuse;
|
||||||
|
ambient = gl_FrontMaterial.ambient.xyz;
|
||||||
}
|
}
|
||||||
vec4 lightResult = vec4(0.0, 0.0, 0.0, diffuse.a);
|
vec4 lightResult = vec4(0.0, 0.0, 0.0, diffuse.a);
|
||||||
|
|
||||||
|
@ -65,7 +67,12 @@ vec4 doLighting(vec3 viewPos, vec3 viewNormal, vec4 vertexColor, out vec3 shadow
|
||||||
lightResult.xyz += ambientLight + diffuseLight;
|
lightResult.xyz += ambientLight + diffuseLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
lightResult.xyz += gl_LightModel.ambient.xyz * ambient + emission;
|
lightResult.xyz += gl_LightModel.ambient.xyz * ambient;
|
||||||
|
|
||||||
|
if (colorMode == ColorMode_Emission)
|
||||||
|
lightResult.xyz += vertexColor.xyz;
|
||||||
|
else
|
||||||
|
lightResult.xyz += gl_FrontMaterial.emission.xyz;
|
||||||
|
|
||||||
#if @clamp
|
#if @clamp
|
||||||
lightResult = clamp(lightResult, vec4(0.0), vec4(1.0));
|
lightResult = clamp(lightResult, vec4(0.0), vec4(1.0));
|
||||||
|
|
|
@ -176,18 +176,22 @@ void main()
|
||||||
vec3 matSpec = specTex.xyz;
|
vec3 matSpec = specTex.xyz;
|
||||||
#else
|
#else
|
||||||
float shininess = gl_FrontMaterial.shininess;
|
float shininess = gl_FrontMaterial.shininess;
|
||||||
vec3 matSpec = gl_FrontMaterial.specular.xyz;
|
vec3 matSpec;
|
||||||
if (colorMode == ColorMode_Specular)
|
if (colorMode == ColorMode_Specular)
|
||||||
matSpec = passColor.xyz;
|
matSpec = passColor.xyz;
|
||||||
|
else
|
||||||
|
matSpec = gl_FrontMaterial.specular.xyz;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (matSpec != vec3(0.0))
|
if (matSpec != vec3(0.0))
|
||||||
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing;
|
gl_FragData[0].xyz += getSpecular(normalize(viewNormal), normalize(passViewPos.xyz), shininess, matSpec) * shadowing;
|
||||||
#if @radialFog
|
#if @radialFog
|
||||||
float depth = euclideanDepth;
|
float depth;
|
||||||
// For the less detailed mesh of simple water we need to recalculate depth on per-pixel basis
|
// For the less detailed mesh of simple water we need to recalculate depth on per-pixel basis
|
||||||
if (simpleWater)
|
if (simpleWater)
|
||||||
depth = length(passViewPos);
|
depth = length(passViewPos);
|
||||||
|
else
|
||||||
|
depth = euclideanDepth;
|
||||||
float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
float fogValue = clamp((depth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
||||||
#else
|
#else
|
||||||
float fogValue = clamp((linearDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
float fogValue = clamp((linearDepth - gl_Fog.start) * gl_Fog.scale, 0.0, 1.0);
|
||||||
|
|
|
@ -85,9 +85,11 @@ void main()
|
||||||
vec3 matSpec = vec3(diffuseTex.a);
|
vec3 matSpec = vec3(diffuseTex.a);
|
||||||
#else
|
#else
|
||||||
float shininess = gl_FrontMaterial.shininess;
|
float shininess = gl_FrontMaterial.shininess;
|
||||||
vec3 matSpec = gl_FrontMaterial.specular.xyz;
|
vec3 matSpec;
|
||||||
if (colorMode == ColorMode_Specular)
|
if (colorMode == ColorMode_Specular)
|
||||||
matSpec = passColor.xyz;
|
matSpec = passColor.xyz;
|
||||||
|
else
|
||||||
|
matSpec = gl_FrontMaterial.specular.xyz;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (matSpec != vec3(0.0))
|
if (matSpec != vec3(0.0))
|
||||||
|
|
Loading…
Reference in a new issue