mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
1) use surface.R(reflection vector), not surface.N(worldspace normal) so we have pov based variation on skylight reflections.
2) use lerp based on the sum contribution of probes for a given pixel as calculated by all non-skylight probes. vs the skylight probe result. (math is currently still wrong, or we wouldn't be needing to use a saturate to get skylights showing) TODO: find out where the attenuation went for a smooth blend. probably the same thing killing unsaturated skylight display..
This commit is contained in:
parent
479959a35b
commit
9f2f8d1d8f
1 changed files with 11 additions and 10 deletions
|
|
@ -133,7 +133,7 @@ float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
||||||
float3 iblSkylightDiffuse(Surface surface, ProbeData probe)
|
float3 iblSkylightDiffuse(Surface surface, ProbeData probe)
|
||||||
{
|
{
|
||||||
float lod = surface.roughness*cubeMips;
|
float lod = surface.roughness*cubeMips;
|
||||||
float3 color = TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.N, probe.probeIdx, lod).xyz;
|
float3 color = TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.R, probe.probeIdx, lod).xyz;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
@ -150,7 +150,7 @@ float3 iblSkylightSpecular(Surface surface, ProbeData probe)
|
||||||
float lod = 0;
|
float lod = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, surface.N, probe.probeIdx, lod).xyz * (brdf.x + brdf.y);
|
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, surface.R, probe.probeIdx, lod).xyz * (brdf.x + brdf.y);
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +175,7 @@ float4 main( PFXVertToPix IN ) : SV_TARGET
|
||||||
float blendSum = 0;
|
float blendSum = 0;
|
||||||
float blendFacSum = 0;
|
float blendFacSum = 0;
|
||||||
float invBlendSum = 0;
|
float invBlendSum = 0;
|
||||||
|
int skyID = 0;
|
||||||
//Set up our struct data
|
//Set up our struct data
|
||||||
ProbeData probes[MAX_PROBES];
|
ProbeData probes[MAX_PROBES];
|
||||||
|
|
||||||
|
|
@ -204,7 +204,8 @@ float4 main( PFXVertToPix IN ) : SV_TARGET
|
||||||
else //skylight
|
else //skylight
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
probes[i].contribution = defineSkylightInfluence(surface, probes[i], IN.wsEyeRay);
|
//probes[i].contribution = defineSkylightInfluence(surface, probes[i], IN.wsEyeRay);
|
||||||
|
skyID = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (probes[i].contribution>1 || probes[i].contribution<0)
|
if (probes[i].contribution>1 || probes[i].contribution<0)
|
||||||
|
|
@ -281,22 +282,22 @@ float4 main( PFXVertToPix IN ) : SV_TARGET
|
||||||
//energy conservation
|
//energy conservation
|
||||||
float3 kD = 1.0.xxx - F;
|
float3 kD = 1.0.xxx - F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0 - surface.metalness;
|
||||||
|
float contrib = 0;
|
||||||
for (i = 0; i < numProbes; ++i)
|
for (i = 0; i < numProbes; ++i)
|
||||||
{
|
{
|
||||||
if (probes[i].contribution == 0)
|
if (probes[i].contribution == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (probes[i].type == 2) //skylight
|
if (probes[i].type < 2) //non-skylight
|
||||||
{
|
|
||||||
irradiance += iblSkylightDiffuse(surface, probes[i]);
|
|
||||||
specular += F*iblSkylightSpecular(surface, probes[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
irradiance += iblBoxDiffuse(surface, probes[i]);
|
irradiance += iblBoxDiffuse(surface, probes[i]);
|
||||||
specular += F*iblBoxSpecular(surface, probes[i]);
|
specular += F*iblBoxSpecular(surface, probes[i]);
|
||||||
|
contrib +=probes[i].contribution;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
contrib = saturate(contrib);
|
||||||
|
irradiance = lerp(iblSkylightDiffuse(surface, probes[skyID]),irradiance,contrib);
|
||||||
|
specular = lerp(F*iblSkylightSpecular(surface, probes[skyID]),specular,contrib);
|
||||||
|
|
||||||
//final diffuse color
|
//final diffuse color
|
||||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue