mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
Merge pull request #1359 from Azaezel/alpha41/IBLBehavingBadly
correct misbehaving ibl
This commit is contained in:
commit
907f2ab5f6
4 changed files with 21 additions and 11 deletions
|
|
@ -394,7 +394,8 @@ void dampen(inout Surface surface, sampler2D WetnessTexture, float accumTime, fl
|
||||||
if (degree<=0.0) return;
|
if (degree<=0.0) return;
|
||||||
vec3 n = abs(surface.N);
|
vec3 n = abs(surface.N);
|
||||||
|
|
||||||
float grav = 2.0-pow(dot(float3(0,0,-1),surface.N),3);
|
float ang = dot(float3(0,0,-1),surface.N);
|
||||||
|
float grav = 2.0-pow(ang,3);
|
||||||
if (grav<0) grav*=-1.0;
|
if (grav<0) grav*=-1.0;
|
||||||
|
|
||||||
float speed = accumTime*(1.0-surface.roughness)*grav;
|
float speed = accumTime*(1.0-surface.roughness)*grav;
|
||||||
|
|
@ -405,8 +406,8 @@ void dampen(inout Surface surface, sampler2D WetnessTexture, float accumTime, fl
|
||||||
wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.2+wetoffset)).b,n.x);
|
wetness = lerp(wetness,texture(WetnessTexture,vec2(surface.P.zy*0.2+wetoffset)).b,n.x);
|
||||||
wetness = pow(wetness,3)*degree;
|
wetness = pow(wetness,3)*degree;
|
||||||
|
|
||||||
surface.roughness = lerp(surface.roughness,(1.0-pow(wetness,2))*surface.roughness*0.92f+0.04f,degree);
|
surface.roughness = lerp(surface.roughness,(1.0-wetness*surface.roughness)*0.92f+0.04f,ang);
|
||||||
surface.baseColor.rgb = lerp(surface.baseColor.rgb,surface.baseColor.rgb*(2.0-wetness)/2,degree);
|
surface.baseColor.rgb = lerp(surface.baseColor.rgb*(2.0-wetness),surface.baseColor.rgb,ang*surface.roughness);
|
||||||
updateSurface(surface);
|
updateSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,6 +417,11 @@ vec4 computeForwardProbes(Surface surface,
|
||||||
vec3 wsEyePos, float skylightCubemapIdx, int SkylightDamp, sampler2D BRDFTexture, sampler2D WetnessTexture, float accumTime, float dampness,
|
vec3 wsEyePos, float skylightCubemapIdx, int SkylightDamp, sampler2D BRDFTexture, sampler2D WetnessTexture, float accumTime, float dampness,
|
||||||
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR)
|
samplerCubeArray irradianceCubemapAR, samplerCubeArray specularCubemapAR)
|
||||||
{
|
{
|
||||||
|
if (getFlag(surface.matFlag, 2))
|
||||||
|
{
|
||||||
|
return vec4(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
float alpha = 1;
|
float alpha = 1;
|
||||||
float wetAmmout = 0;
|
float wetAmmout = 0;
|
||||||
|
|
|
||||||
|
|
@ -396,8 +396,8 @@ void dampen(inout Surface surface, TORQUE_SAMPLER2D(WetnessTexture), float accum
|
||||||
{
|
{
|
||||||
if (degree<=0.0) return;
|
if (degree<=0.0) return;
|
||||||
float3 n = abs(surface.N);
|
float3 n = abs(surface.N);
|
||||||
|
float ang = dot(float3(0,0,-1),surface.N);
|
||||||
float grav = 2.0-pow(dot(float3(0,0,-1),surface.N),3);
|
float grav = 2.0-pow(ang,3);
|
||||||
if (grav<0) grav*=-1.0;
|
if (grav<0) grav*=-1.0;
|
||||||
|
|
||||||
float speed = accumTime*(1.0-surface.roughness)*grav;
|
float speed = accumTime*(1.0-surface.roughness)*grav;
|
||||||
|
|
@ -408,8 +408,8 @@ void dampen(inout Surface surface, TORQUE_SAMPLER2D(WetnessTexture), float accum
|
||||||
wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.2+wetoffset)).b,n.x);
|
wetness = lerp(wetness,TORQUE_TEX2D(WetnessTexture,float2(surface.P.zy*0.2+wetoffset)).b,n.x);
|
||||||
wetness = pow(wetness,3)*degree;
|
wetness = pow(wetness,3)*degree;
|
||||||
|
|
||||||
surface.roughness = lerp(surface.roughness,(1.0-pow(wetness,2))*surface.roughness*0.92f+0.04f,degree);
|
surface.roughness = lerp(surface.roughness,(1.0-wetness*surface.roughness)*0.92f+0.04f,ang);
|
||||||
surface.baseColor.rgb = lerp(surface.baseColor.rgb,surface.baseColor.rgb*(2.0-wetness)/2,degree);
|
surface.baseColor.rgb = lerp(surface.baseColor.rgb*(2.0-wetness),surface.baseColor.rgb,ang*surface.roughness);
|
||||||
surface.Update();
|
surface.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -419,6 +419,11 @@ float4 computeForwardProbes(Surface surface,
|
||||||
float3 wsEyePos, float skylightCubemapIdx, int SkylightDamp, TORQUE_SAMPLER2D(BRDFTexture), TORQUE_SAMPLER2D(WetnessTexture), float accumTime, float dampness,
|
float3 wsEyePos, float skylightCubemapIdx, int SkylightDamp, TORQUE_SAMPLER2D(BRDFTexture), TORQUE_SAMPLER2D(WetnessTexture), float accumTime, float dampness,
|
||||||
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
TORQUE_SAMPLERCUBEARRAY(irradianceCubemapAR), TORQUE_SAMPLERCUBEARRAY(specularCubemapAR))
|
||||||
{
|
{
|
||||||
|
if (getFlag(surface.matFlag, 2))
|
||||||
|
{
|
||||||
|
return float4(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
float alpha = 1;
|
float alpha = 1;
|
||||||
float wetAmmout = 0;
|
float wetAmmout = 0;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ void main()
|
||||||
Surface surface = createSurface(normDepth, colorBuffer, matInfoBuffer, IN_uv0.xy, eyePosWorld, IN_wsEyeRay, cameraToWorld);
|
Surface surface = createSurface(normDepth, colorBuffer, matInfoBuffer, IN_uv0.xy, eyePosWorld, IN_wsEyeRay, cameraToWorld);
|
||||||
if (getFlag(surface.matFlag, 2))
|
if (getFlag(surface.matFlag, 2))
|
||||||
{
|
{
|
||||||
OUT_col = surface.baseColor;
|
OUT_col = vec4(0,0,0,0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef USE_SSAO_MASK
|
#ifdef USE_SSAO_MASK
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,8 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
|
|
||||||
if (getFlag(surface.matFlag, 2))
|
if (getFlag(surface.matFlag, 2))
|
||||||
{
|
{
|
||||||
return surface.baseColor;
|
return float4(0,0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_SSAO_MASK
|
#ifdef USE_SSAO_MASK
|
||||||
float ssao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams7 ) ).r;
|
float ssao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams7 ) ).r;
|
||||||
surface.ao = min(surface.ao, ssao);
|
surface.ao = min(surface.ao, ssao);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue