Fix sunlight for vid_rendermode 2

This commit is contained in:
Magnus Norddahl 2025-07-23 23:19:28 +02:00
commit 56e796cd3e
6 changed files with 17 additions and 8 deletions

View file

@ -52,12 +52,15 @@ vec4 getLightColor(Material material)
vec4 dynlight = uDynLightColor;
float sunlightAttenuation = 0.0;
if (vLightmapIndex != -1)
{
dynlight.rgb += texture(textures[nonuniformEXT(vLightmapIndex)], vLightmap.xy).rgb;
vec4 lightmap = texture(textures[nonuniformEXT(vLightmapIndex)], vLightmap.xy);
dynlight.rgb += lightmap.rgb;
sunlightAttenuation = lightmap.a;
}
dynlight.rgb += ProcessSWLight(material);
dynlight.rgb += ProcessSWLight(material, sunlightAttenuation);
frag.rgb = PickGamePaletteColor(frag.rgb + matColor * dynlight.rgb);
return frag;

View file

@ -11,7 +11,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color, float sunlightAttenuati
return material.Base.rgb * clamp(color + desaturate(dynlight).rgb, 0.0, 1.4);
}
vec3 ProcessSWLight(Material material)
vec3 ProcessSWLight(Material material, float sunlightAttenuation)
{
return vec3(0.0);
}

View file

@ -130,11 +130,17 @@
return frag;
}
vec3 ProcessSWLight(Material material)
vec3 ProcessSWLight(Material material, float sunlightAttenuation)
{
vec3 normal = material.Normal;
vec3 dynlight = vec3(0.0);
if (sunlightAttenuation > 0.0)
{
sunlightAttenuation *= clamp(dot(normal, SunDir), 0.0, 1.0);
dynlight.rgb += SunColor.rgb * SunIntensity * sunlightAttenuation;
}
#ifndef UBERSHADER
#ifdef SHADE_VERTEX
dynlight.rgb += vLightColor;
@ -171,7 +177,7 @@
return material.Base.rgb;
}
vec3 ProcessSWLight(Material material)
vec3 ProcessSWLight(Material material, float sunlightAttenuation)
{
return vec3(0.0);
}

View file

@ -224,7 +224,7 @@ vec3 ProcessMaterialLight(Material material, vec3 ambientLight, float sunlightAt
return color;
}
vec3 ProcessSWLight(Material material)
vec3 ProcessSWLight(Material material, float sunlightAttenuation)
{
return vec3(0.0);
}

View file

@ -127,7 +127,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color, float sunlightAttenuati
return frag;
}
vec3 ProcessSWLight(Material material)
vec3 ProcessSWLight(Material material, float sunlightAttenuation)
{
return vec3(0.0);
}

View file

@ -21,7 +21,7 @@ struct Material
vec4 Process(vec4 color);
void SetupMaterial(inout Material mat);
vec3 ProcessMaterialLight(Material material, vec3 color, float sunlightAttenuation);
vec3 ProcessSWLight(Material material);
vec3 ProcessSWLight(Material material, float sunlightAttenuation);
vec2 GetTexCoord();
Material CreateMaterial()