mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
Merge branch 'PBR_ProbeArrayWIP' of https://github.com/Areloch/Torque3D into PBR_ProbeArrayWIP
# Conflicts: # Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl
This commit is contained in:
commit
e7c3987fa1
2 changed files with 46 additions and 32 deletions
|
|
@ -148,7 +148,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -163,7 +163,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -178,7 +178,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -193,7 +193,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -208,7 +208,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -223,7 +223,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -238,7 +238,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -310,13 +310,26 @@ new SimGroup(MissionGroup) {
|
||||||
refOffset = "0 0 0";
|
refOffset = "0 0 0";
|
||||||
refScale = "10 10 10";
|
refScale = "10 10 10";
|
||||||
ReflectionMode = "Baked Cubemap";
|
ReflectionMode = "Baked Cubemap";
|
||||||
position = "-22.7696 0.224002 4.70918";
|
position = "-22.7696 0.224002 1.72318";
|
||||||
rotation = "1 0 0 0";
|
rotation = "1 0 0 0";
|
||||||
scale = "10 10 10";
|
scale = "10 10 10";
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "1";
|
canSaveDynamicFields = "1";
|
||||||
persistentId = "d84cbe5b-4f76-11e9-977c-a561a736e3eb";
|
persistentId = "d84cbe5b-4f76-11e9-977c-a561a736e3eb";
|
||||||
attenuation = "0";
|
attenuation = "1";
|
||||||
|
};
|
||||||
|
new BoxEnvironmentProbe() {
|
||||||
|
enabled = "1";
|
||||||
|
refOffset = "0 0 0";
|
||||||
|
refScale = "10 10 10";
|
||||||
|
ReflectionMode = "Baked Cubemap";
|
||||||
|
position = "-23.5985 -8.60824 2.16156";
|
||||||
|
rotation = "0 0 1 37.5292";
|
||||||
|
scale = "10 10 10";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
persistentId = "db05bf42-503b-11e9-8eaf-b5e1839b86e6";
|
||||||
|
attenuation = "1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
//--- OBJECT WRITE END ---
|
//--- OBJECT WRITE END ---
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ float3 iblBoxDiffuse(Surface surface, ProbeData probe)
|
||||||
float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
||||||
{
|
{
|
||||||
// BRDF
|
// BRDF
|
||||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
//float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||||
|
|
||||||
float3 dir = boxProject(surface, probe);
|
float3 dir = boxProject(surface, probe);
|
||||||
|
|
||||||
|
|
@ -122,7 +122,7 @@ float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
||||||
float lod = 0;
|
float lod = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, dir, probe.cubemapIdx, lod).xyz * (brdf.x + brdf.y);
|
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, dir, probe.cubemapIdx, lod).xyz;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ float3 iblSkylightDiffuse(Surface surface)
|
||||||
float3 iblSkylightSpecular(Surface surface)
|
float3 iblSkylightSpecular(Surface surface)
|
||||||
{
|
{
|
||||||
// BRDF
|
// BRDF
|
||||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
//float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||||
|
|
||||||
// Radiance (Specular)
|
// Radiance (Specular)
|
||||||
#if DEBUGVIZ_SPECCUBEMAP == 0
|
#if DEBUGVIZ_SPECCUBEMAP == 0
|
||||||
|
|
@ -144,7 +144,7 @@ float3 iblSkylightSpecular(Surface surface)
|
||||||
float lod = 0;
|
float lod = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float3 color = TORQUE_TEXCUBELOD(skylightPrefilterMap, float4(surface.R, lod)).xyz * (brdf.x + brdf.y);
|
float3 color = TORQUE_TEXCUBELOD(skylightPrefilterMap, float4(surface.R, lod)).xyz;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
{
|
{
|
||||||
blendFactor[i] *= invBlendSumWeighted;
|
blendFactor[i] *= invBlendSumWeighted;
|
||||||
probes[i].contribution *= blendFactor[i];
|
probes[i].contribution *= blendFactor[i];
|
||||||
alpha -= probes[i].contribution;
|
alpha -= probes[i].contribution;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -250,18 +250,16 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
{
|
{
|
||||||
attenVis += probes[i].contribution;
|
attenVis += probes[i].contribution;
|
||||||
}
|
}
|
||||||
return float4(attenVis, attenVis, attenVis, 1);
|
|
||||||
|
//return float4(attenVis, attenVis, attenVis, 1);
|
||||||
|
return float4(blendSum, blendSum, blendSum, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUGVIZ_CONTRIB == 1
|
#if DEBUGVIZ_CONTRIB == 1
|
||||||
|
|
||||||
float3 finalContribColor = float3(0, 0, 0);
|
float3 finalContribColor = float3(0, 0, 0);
|
||||||
for (i = 0; i < numProbes; ++i)
|
for (i = 0; i < numProbes; ++i)
|
||||||
{
|
{
|
||||||
if (probes[i].contribution == 0)
|
finalContribColor += probes[i].contribution *probeContribColors[i].rgb;
|
||||||
continue;
|
|
||||||
|
|
||||||
finalContribColor += probes[i].contribution * probeContribColors[i].rgb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return float4(finalContribColor, 1);
|
return float4(finalContribColor, 1);
|
||||||
|
|
@ -272,32 +270,35 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
|
|
||||||
float3 irradiance = float3(0, 0, 0);
|
float3 irradiance = float3(0, 0, 0);
|
||||||
float3 specular = float3(0, 0, 0);
|
float3 specular = float3(0, 0, 0);
|
||||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
|
||||||
|
|
||||||
//energy conservation
|
|
||||||
float3 kD = 1.0.xxx - F;
|
|
||||||
kD *= 1.0 - surface.metalness;
|
|
||||||
float contrib = 0;
|
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) //skip skylight
|
irradiance += iblBoxDiffuse(surface, probes[i]) * probes[i].contribution;
|
||||||
continue;
|
specular += iblBoxSpecular(surface, probes[i]) * probes[i].contribution;
|
||||||
|
|
||||||
irradiance += iblBoxDiffuse(surface, probes[i])*probes[i].contribution;
|
|
||||||
specular += F*iblBoxSpecular(surface, probes[i])*probes[i].contribution;
|
|
||||||
contrib +=probes[i].contribution;
|
contrib +=probes[i].contribution;
|
||||||
}
|
}
|
||||||
//contrib = saturate(contrib);
|
|
||||||
|
|
||||||
if (hasSkylight && alpha != 0)
|
if (hasSkylight && alpha != 0)
|
||||||
{
|
{
|
||||||
irradiance = lerp(irradiance, iblSkylightDiffuse(surface), alpha);
|
irradiance = lerp(irradiance, iblSkylightDiffuse(surface), alpha);
|
||||||
specular = lerp(specular, F*iblSkylightSpecular(surface), alpha);
|
specular = lerp(specular, iblSkylightSpecular(surface), alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
||||||
|
|
||||||
|
//energy conservation
|
||||||
|
float3 kD = 1.0.xxx - F;
|
||||||
|
kD *= 1.0 - surface.metalness;
|
||||||
|
|
||||||
|
//apply brdf
|
||||||
|
//Do it once to save on texture samples
|
||||||
|
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||||
|
specular *= brdf.x * F + brdf.y;
|
||||||
|
|
||||||
//final diffuse color
|
//final diffuse color
|
||||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||||
float4 finalColor = float4(diffuse + specular * surface.ao, 1.0);
|
float4 finalColor = float4(diffuse + specular * surface.ao, 1.0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue