Merge branch 'develop' into develop_mirrors

This commit is contained in:
MontyTRC89 2024-12-07 05:03:24 +01:00
commit c4330a777c
3 changed files with 22 additions and 21 deletions

View file

@ -576,7 +576,8 @@ namespace TEN::Renderer
if (intensity <= EPSILON)
return;
if (light.CastShadows && prioritizeShadowLight && intensity >= highestIntensity)
if ((light.Type == LightType::Point || light.Type == LightType::Spot) &&
light.CastShadows && prioritizeShadowLight && intensity >= highestIntensity)
{
highestIntensity = intensity;
brightestLight = &light;
@ -648,7 +649,7 @@ namespace TEN::Renderer
// Put actual lights in provided vector.
outputLights->clear();
// Add brightest ligh, if collecting shadow light is specified, even if it's far in range.
// Add brightest light, if collecting shadow light is specified, even if it's far in range.
if (prioritizeShadowLight && brightestLight)
outputLights->push_back(brightestLight);
@ -670,7 +671,7 @@ namespace TEN::Renderer
std::vector<RendererLight*> lightsToDraw;
CollectLights(Vector3(Camera.pos.x, Camera.pos.y, Camera.pos.z), CAMERA_LIGHT_COLLECTION_RADIUS, Camera.pos.RoomNumber, NO_VALUE, true, false, nullptr, &lightsToDraw);
if (lightsToDraw.size() > 0 && lightsToDraw.front()->CastShadows)
if (!lightsToDraw.empty() && lightsToDraw.front()->CastShadows)
{
_shadowLight = lightsToDraw.front();
}

View file

@ -145,12 +145,13 @@ PixelShaderOutput PS(PixelShaderInput input)
{
float isPointLight = step(0.5f, Light.Type == LT_POINT); // 1.0 if LT_POINT, 0.0 otherwise
float isSpotLight = step(0.5f, Light.Type == LT_SPOT); // 1.0 if LT_SPOT, 0.0 otherwise
float isOtherLight = 1.0 - (isPointLight + isSpotLight); // 1.0 if neither LT_POINT nor LT_SPOT
float3 pointLightShadow = DoPointLightShadow(input.WorldPosition, lighting);
float3 spotLightShadow = DoSpotLightShadow(input.WorldPosition, normal, lighting);
// Blend the shadows based on the light type
lighting = pointLightShadow * isPointLight + spotLightShadow * isSpotLight;
lighting = pointLightShadow * isPointLight + spotLightShadow * isSpotLight + lighting * isOtherLight;
}
lighting = DoBlobShadows(input.WorldPosition, lighting);

View file

@ -310,13 +310,12 @@ float DoFogBulbForSky(float3 pos, ShaderFogBulb bulb)
float DoDistanceFogForVertex(float3 pos)
{
float fog = 0.0f;
float d = length(CamPositionWS.xyz - pos);
float fogRange = FogMaxDistance * 1024 - FogMinDistance * 1024;
if (FogMaxDistance > 0.0f)
{
float d = length(CamPositionWS.xyz - pos);
fog = clamp((d - FogMinDistance * 1024) / (FogMaxDistance * 1024 - FogMinDistance * 1024), 0, 1);
}
float fogEnabled = step(0.0f, FogMaxDistance);
float fogFactor = (d - FogMinDistance * 1024) / fogRange;
float fog = saturate(fogFactor) * fogEnabled;
return fog;
}
@ -324,16 +323,16 @@ float DoDistanceFogForVertex(float3 pos)
float4 DoFogBulbsForVertex(float3 pos)
{
float4 fog = float4(0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < NumFogBulbs; i++)
{
float fogFactor = DoFogBulb(pos, FogBulbs[i]);
fog.xyz += FogBulbs[i].Color.xyz * fogFactor;
float3 fogColor = FogBulbs[i].Color.xyz * fogFactor;
fog.xyz += fogColor;
fog.w += fogFactor;
if (fog.w >= 1.0f)
{
break;
}
fog.w = saturate(fog.w);
}
return fog;
@ -346,12 +345,12 @@ float4 DoFogBulbsForSky(float3 pos)
for (int i = 0; i < NumFogBulbs; i++)
{
float fogFactor = DoFogBulbForSky(pos, FogBulbs[i]);
fog.xyz += FogBulbs[i].Color.xyz * fogFactor;
float3 fogColor = FogBulbs[i].Color.xyz * fogFactor;
fog.xyz += fogColor;
fog.w += fogFactor;
if (fog.w >= 1.0f)
{
break;
}
fog.w = saturate(fog.w);
}
return fog;