Add uniform for specifying the light probe

This commit is contained in:
dpjudas 2025-02-19 02:16:21 +01:00
commit aca088d601
4 changed files with 10 additions and 6 deletions

View file

@ -213,6 +213,7 @@ public:
mSurfaceUniforms.uFogDensity = 0.0f;
mSurfaceUniforms.uLightLevel = -1.0f;
mSurfaceUniforms.uDepthFadeThreshold = 0.0f;
mSurfaceUniforms.uLightProbeIndex = 0;
mSpecialEffect = EFF_NONE;
mLightIndex = -1;
mBoneIndexBase = -1;
@ -560,6 +561,11 @@ public:
mFogballIndex = index;
}
void SetLightProbeIndex(int index)
{
mSurfaceUniforms.uLightProbeIndex = index;
}
void SetRenderStyle(FRenderStyle rs)
{
mRenderStyle = rs;

View file

@ -45,7 +45,7 @@ struct SurfaceUniforms
float uAlphaThreshold;
int uTextureIndex;
float uDepthFadeThreshold;
float padding1;
int uLightProbeIndex;
FVector3 uActorCenter;
float padding2;
};

View file

@ -115,7 +115,7 @@ struct SurfaceUniforms
float uAlphaThreshold;
int uTextureIndex;
float uDepthFadeThreshold;
float padding1;
int uLightProbeIndex;
vec3 uActorCenter;
float padding2;
};

View file

@ -142,8 +142,6 @@ vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
Lo += (kD * albedo / PI + specular) * radiance;
}
float probeIndex = 0.0; // To do: get this from an uniform
vec3 F = fresnelSchlickRoughness(clamp(dot(N, V), 0.0, 1.0), F0, roughness);
vec3 kS = F;
@ -151,13 +149,13 @@ vec3 ProcessMaterialLight(Material material, vec3 ambientLight)
const float environmentScaleFactor = 0.1;
vec3 irradiance = texture(IrradianceMap, vec4(N, probeIndex)).rgb * environmentScaleFactor;
vec3 irradiance = texture(IrradianceMap, vec4(N, uLightProbeIndex)).rgb * environmentScaleFactor;
vec3 diffuse = irradiance * albedo;
kD *= 1.0 - metallic;
const float MAX_REFLECTION_LOD = 4.0;
vec3 R = reflect(-V, N);
vec3 prefilteredColor = textureLod(PrefilterMap, vec4(R, probeIndex), roughness * MAX_REFLECTION_LOD).rgb * environmentScaleFactor;
vec3 prefilteredColor = textureLod(PrefilterMap, vec4(R, uLightProbeIndex), roughness * MAX_REFLECTION_LOD).rgb * environmentScaleFactor;
vec2 envBRDF = texture(textures[BrdfLUT], vec2(clamp(dot(N, V), 0.0, 1.0), roughness)).rg;
vec3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);