mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +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
255242db41
7 changed files with 140 additions and 259 deletions
|
|
@ -41,7 +41,7 @@ new SimGroup(MissionGroup) {
|
|||
enabled = "1";
|
||||
ReflectionMode = "Baked Cubemap";
|
||||
StaticCubemap = "sky_day_hdr_cubemap";
|
||||
position = "0 0 -0.0560153";
|
||||
position = "0 0.704113 16.1515";
|
||||
rotation = "1 0 0 0";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
|
|
@ -81,7 +81,7 @@ new SimGroup(MissionGroup) {
|
|||
squareSize = "128";
|
||||
scaleU = "25";
|
||||
scaleV = "25";
|
||||
Material = "Grid512_Grey_Mat";
|
||||
Material = "Floor_Material";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
enabled = "1";
|
||||
|
|
@ -130,32 +130,13 @@ new SimGroup(MissionGroup) {
|
|||
refOffset = "0 0 0";
|
||||
refScale = "10 10 10";
|
||||
ReflectionMode = "Baked Cubemap";
|
||||
position = "0.130544 0.492826 4.70918";
|
||||
position = "0.130544 0.239855 4.8594";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "10 10 10";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
persistentId = "8072e1be-2846-11e7-9f56-abd46b190c60";
|
||||
};
|
||||
new BoxEnvironmentProbe() {
|
||||
enabled = "1";
|
||||
refOffset = "0 0 0";
|
||||
refScale = "10 10 10";
|
||||
ReflectionMode = "Baked Cubemap";
|
||||
position = "-26.7509 2.50947 1.94424";
|
||||
rotation = "0 0 -1 27.2465";
|
||||
scale = "10 5 10";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
persistentId = "f281a5ff-1ae9-11e9-9c9a-df9135416cc7";
|
||||
GroundColor = "0.8 0.7 0.5 1";
|
||||
IndirectLight = "1 1 1 1";
|
||||
IndirectLightMode = "Spherical Harmonics";
|
||||
Intensity = "1";
|
||||
posOffset = "0 0 0";
|
||||
radius = "5";
|
||||
reflectionPath = "levels/probeTest/probes/";
|
||||
SkyColor = "0.5 0.5 1 1";
|
||||
attenuation = "0";
|
||||
};
|
||||
new ConvexShape() {
|
||||
Material = "Grid512_Orange_Mat";
|
||||
|
|
@ -324,114 +305,18 @@ new SimGroup(MissionGroup) {
|
|||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
};
|
||||
new SphereEnvironmentProbe() {
|
||||
new BoxEnvironmentProbe() {
|
||||
enabled = "1";
|
||||
radius = "5";
|
||||
refOffset = "0 0 0";
|
||||
refScale = "10 10 10";
|
||||
ReflectionMode = "Baked Cubemap";
|
||||
StaticCubemap = "HdrSkyCubemap";
|
||||
position = "-25.5075 8.33063 1.52035";
|
||||
position = "-22.7696 0.224002 4.70918";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "10 10 10";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
persistentId = "c4bc9059-3cb4-11e9-933c-d270d89e32b9";
|
||||
};
|
||||
new TSStatic() {
|
||||
shapeName = "art/yorks/chapel/Module_Common/SB_chapel_ext.dae";
|
||||
playAmbient = "1";
|
||||
meshCulling = "0";
|
||||
originSort = "0";
|
||||
CollisionType = "Collision Mesh";
|
||||
DecalType = "Collision Mesh";
|
||||
allowPlayerStep = "0";
|
||||
alphaFadeEnable = "0";
|
||||
alphaFadeStart = "100";
|
||||
alphaFadeEnd = "150";
|
||||
alphaFadeInverse = "0";
|
||||
renderNormals = "0";
|
||||
forceDetail = "-1";
|
||||
ignoreZodiacs = "0";
|
||||
useGradientRange = "0";
|
||||
gradientRange = "0 180";
|
||||
invertGradientRange = "0";
|
||||
position = "0.569034 -19.8511 -0.101853";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
};
|
||||
new TSStatic() {
|
||||
shapeName = "art/yorks/chapel/Module_Common/LMA_chapel_int.dae";
|
||||
playAmbient = "1";
|
||||
meshCulling = "0";
|
||||
originSort = "0";
|
||||
CollisionType = "Collision Mesh";
|
||||
DecalType = "Collision Mesh";
|
||||
allowPlayerStep = "0";
|
||||
alphaFadeEnable = "0";
|
||||
alphaFadeStart = "100";
|
||||
alphaFadeEnd = "150";
|
||||
alphaFadeInverse = "0";
|
||||
renderNormals = "0";
|
||||
forceDetail = "-1";
|
||||
ignoreZodiacs = "0";
|
||||
useGradientRange = "0";
|
||||
gradientRange = "0 180";
|
||||
invertGradientRange = "0";
|
||||
position = "0.569034 -19.8511 -0.101853";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
};
|
||||
new TSStatic() {
|
||||
shapeName = "art/yorks/chapel/Module_Common/LMX_chapel_props.dae";
|
||||
playAmbient = "1";
|
||||
meshCulling = "0";
|
||||
originSort = "0";
|
||||
CollisionType = "Collision Mesh";
|
||||
DecalType = "Collision Mesh";
|
||||
allowPlayerStep = "0";
|
||||
alphaFadeEnable = "0";
|
||||
alphaFadeStart = "100";
|
||||
alphaFadeEnd = "150";
|
||||
alphaFadeInverse = "0";
|
||||
renderNormals = "0";
|
||||
forceDetail = "-1";
|
||||
ignoreZodiacs = "0";
|
||||
useGradientRange = "0";
|
||||
gradientRange = "0 180";
|
||||
invertGradientRange = "0";
|
||||
position = "0.569034 -19.8511 -0.101853";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
};
|
||||
new TSStatic() {
|
||||
shapeName = "art/yorks/chapel/Module_Common/SB_chapel_glass.dae";
|
||||
playAmbient = "1";
|
||||
meshCulling = "0";
|
||||
originSort = "0";
|
||||
CollisionType = "Collision Mesh";
|
||||
DecalType = "Collision Mesh";
|
||||
allowPlayerStep = "0";
|
||||
alphaFadeEnable = "0";
|
||||
alphaFadeStart = "100";
|
||||
alphaFadeEnd = "150";
|
||||
alphaFadeInverse = "0";
|
||||
renderNormals = "0";
|
||||
forceDetail = "-1";
|
||||
ignoreZodiacs = "0";
|
||||
useGradientRange = "0";
|
||||
gradientRange = "0 180";
|
||||
invertGradientRange = "0";
|
||||
position = "0.569034 -19.8511 -0.101853";
|
||||
rotation = "1 0 0 0";
|
||||
scale = "1 1 1";
|
||||
canSave = "1";
|
||||
canSaveDynamicFields = "1";
|
||||
persistentId = "d84cbe5b-4f76-11e9-977c-a561a736e3eb";
|
||||
attenuation = "0";
|
||||
};
|
||||
};
|
||||
//--- OBJECT WRITE END ---
|
||||
|
|
|
|||
|
|
@ -78,8 +78,8 @@ float defineBoxSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeRay)
|
|||
float3 surfPosLS = mul(probe.worldToLocal, float4(surface.P, 1.0)).xyz;
|
||||
float atten = 1.0-probe.attenuation;
|
||||
float baseVal = 0.25;
|
||||
float dist = getDistBoxToPoint(surfPosLS, float3(baseVal, baseVal, baseVal));
|
||||
return saturate(smoothstep(baseVal + 0.0001, atten*baseVal, dist));
|
||||
float dist = getDistBoxToPoint(surfPosLS,float3(baseVal,baseVal,baseVal));
|
||||
return saturate(smoothstep(baseVal+0.0001,atten*baseVal,dist));
|
||||
}
|
||||
|
||||
// Box Projected IBL Lighting
|
||||
|
|
@ -105,10 +105,7 @@ float3 iblBoxDiffuse(Surface surface, ProbeData probe)
|
|||
float3 dir = boxProject(surface, probe);
|
||||
|
||||
float3 color = TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, dir, probe.cubemapIdx, 0).xyz;
|
||||
if (probe.contribution>0)
|
||||
return color;
|
||||
else
|
||||
return float3(0, 0, 0);
|
||||
return color;
|
||||
}
|
||||
|
||||
float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
||||
|
|
@ -126,21 +123,16 @@ float3 iblBoxSpecular(Surface surface, ProbeData probe)
|
|||
#endif
|
||||
|
||||
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, dir, probe.cubemapIdx, lod).xyz * (brdf.x + brdf.y);
|
||||
|
||||
if (probe.contribution>0)
|
||||
return color;
|
||||
else
|
||||
return float3(0, 0, 0);
|
||||
}
|
||||
|
||||
float3 iblSkylightDiffuse(Surface surface, ProbeData probe)
|
||||
{
|
||||
float3 color = TORQUE_TEXCUBEARRAYLOD(irradianceCubemapAR, surface.R, probe.probeIdx, 0).xyz;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float3 iblSkylightSpecular(Surface surface, ProbeData probe)
|
||||
float3 iblSkylightDiffuse(Surface surface)
|
||||
{
|
||||
float3 color = TORQUE_TEXCUBELOD(skylightIrradMap, float4(surface.R, 0)).xyz;
|
||||
return color;
|
||||
}
|
||||
|
||||
float3 iblSkylightSpecular(Surface surface)
|
||||
{
|
||||
// BRDF
|
||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||
|
|
@ -152,8 +144,7 @@ float3 iblSkylightSpecular(Surface surface, ProbeData probe)
|
|||
float lod = 0;
|
||||
#endif
|
||||
|
||||
float3 color = TORQUE_TEXCUBEARRAYLOD(cubeMapAR, surface.R, probe.probeIdx, lod).xyz * (brdf.x + brdf.y);
|
||||
|
||||
float3 color = TORQUE_TEXCUBELOD(skylightPrefilterMap, float4(surface.R, lod)).xyz * (brdf.x + brdf.y);
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
@ -221,24 +212,24 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
}
|
||||
|
||||
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
|
||||
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
|
||||
// respect constraint B.
|
||||
// Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary
|
||||
// and respect constraint A.
|
||||
for (i = 0; i < numProbes; i++)
|
||||
{
|
||||
if (probehits>1.0)
|
||||
{
|
||||
blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1);
|
||||
blendFactor[i] *= ((probes[i].contribution) / invBlendSum);
|
||||
blendFacSum += blendFactor[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
blendFactor[i] = probes[i].contribution;
|
||||
blendFacSum = probes[i].contribution;
|
||||
}
|
||||
}
|
||||
// And as we invert, we need to divide by Num-1 to stay normalized (else sum is > 1).
|
||||
// respect constraint B.
|
||||
// Weight1 = normalized inverted NDF, so we have 1 at center, 0 at boundary
|
||||
// and respect constraint A.
|
||||
for (i = 0; i < numProbes; i++)
|
||||
{
|
||||
if (probehits>1.0)
|
||||
{
|
||||
blendFactor[i] = ((probes[i].contribution / blendSum)) / (probehits - 1);
|
||||
blendFactor[i] *= ((probes[i].contribution) / invBlendSum);
|
||||
blendFacSum += blendFactor[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
blendFactor[i] = probes[i].contribution;
|
||||
blendFacSum = probes[i].contribution;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Normalize blendVal
|
||||
|
|
@ -249,28 +240,25 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
}
|
||||
#endif
|
||||
|
||||
//use probehits for sharp cuts when singular,
|
||||
//blendSum when wanting blend on all edging
|
||||
if (blendSum>1.0)
|
||||
{
|
||||
float invBlendSumWeighted = 1.0f / blendFacSum;
|
||||
for (i = 0; i < numProbes; ++i)
|
||||
{
|
||||
blendFactor[i] *= invBlendSumWeighted;
|
||||
probes[i].contribution = blendFactor[i];
|
||||
if (probehits>1.0)
|
||||
{
|
||||
float invBlendSumWeighted = 1.0f / blendFacSum;
|
||||
for (i = 0; i < numProbes; ++i)
|
||||
{
|
||||
blendFactor[i] *= invBlendSumWeighted;
|
||||
probes[i].contribution = saturate(blendFactor[i]);
|
||||
|
||||
alpha -= probes[i].contribution;
|
||||
}
|
||||
}
|
||||
alpha -= probes[i].contribution;
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUGVIZ_ATTENUATION == 1
|
||||
/*float attenVis = 0;
|
||||
for (i = 0; i < numProbes; ++i)
|
||||
{
|
||||
attenVis += probes[i].contribution;
|
||||
}
|
||||
return float4(attenVis, attenVis, attenVis, 1);*/
|
||||
return float4(alpha, alpha, alpha, 1);
|
||||
float attenVis = 0;
|
||||
for (i = 0; i < numProbes; ++i)
|
||||
{
|
||||
attenVis += probes[i].contribution;
|
||||
}
|
||||
return float4(attenVis, attenVis, attenVis, 1);
|
||||
#endif
|
||||
|
||||
#if DEBUGVIZ_CONTRIB == 1
|
||||
|
|
@ -288,34 +276,6 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
#endif
|
||||
}
|
||||
|
||||
if (hasSkylight && alpha == 1)
|
||||
{
|
||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, surface.NdotV, 0.0, 0.0)).xy;
|
||||
float lod = surface.roughness*cubeMips;
|
||||
#if DEBUGVIZ_SPECCUBEMAP == 0 && DEBUGVIZ_DIFFCUBEMAP == 0
|
||||
float3 specular = TORQUE_TEXCUBELOD(skylightPrefilterMap, float4(surface.R, lod)).xyz * (brdf.x + brdf.y);
|
||||
float3 irradiance = TORQUE_TEXCUBELOD(skylightIrradMap, float4(surface.R, 0)).xyz;
|
||||
|
||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
||||
|
||||
//energy conservation
|
||||
float3 kD = 1.0.xxx - F;
|
||||
kD *= 1.0 - surface.metalness;
|
||||
|
||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||
float4 finalColor = float4(diffuse + specular * surface.ao, alpha);
|
||||
return finalColor;
|
||||
#elif DEBUGVIZ_SPECCUBEMAP == 1 && DEBUGVIZ_DIFFCUBEMAP == 0
|
||||
float3 specular = TORQUE_TEXCUBELOD(skylightPrefilterMap, float4(surface.R, lod)).xyz;
|
||||
float4 finalColor = float4(specular, 1);
|
||||
return finalColor;
|
||||
#elif DEBUGVIZ_DIFFCUBEMAP == 1
|
||||
float3 irradiance = TORQUE_TEXCUBELOD(skylightIrradMap, float4(surface.R, 0)).xyz;
|
||||
float4 finalColor = float4(irradiance, 1);
|
||||
return finalColor;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if DEBUGVIZ_SPECCUBEMAP == 0 && DEBUGVIZ_DIFFCUBEMAP == 0
|
||||
|
||||
float3 irradiance = float3(0, 0, 0);
|
||||
|
|
@ -334,11 +294,17 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
if (probes[i].type == 2) //skip skylight
|
||||
continue;
|
||||
|
||||
irradiance += iblBoxDiffuse(surface, probes[i]);
|
||||
specular += F*iblBoxSpecular(surface, probes[i]);
|
||||
contrib += 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 = saturate(contrib);
|
||||
|
||||
if (hasSkylight && alpha != 0)
|
||||
{
|
||||
irradiance = lerp(irradiance, iblSkylightDiffuse(surface), alpha);
|
||||
specular = lerp(specular, F*iblSkylightSpecular(surface), alpha);
|
||||
}
|
||||
contrib = saturate(contrib);
|
||||
|
||||
//final diffuse color
|
||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||
|
|
@ -381,4 +347,4 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
return float4(cubeColor, 1);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue