mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-28 07:45:40 +00:00
Merge branch 'Preview4_0' of https://github.com/Azaezel/Torque3D into Preview4_0
This commit is contained in:
commit
a85bc7bae0
10 changed files with 107 additions and 85 deletions
|
|
@ -447,10 +447,6 @@ AdvancedLightBinManager::LightMaterialInfo* AdvancedLightBinManager::_getLightMa
|
||||||
if ( smPSSMDebugRender )
|
if ( smPSSMDebugRender )
|
||||||
shadowMacros.push_back( GFXShaderMacro( "PSSM_DEBUG_RENDER" ) );
|
shadowMacros.push_back( GFXShaderMacro( "PSSM_DEBUG_RENDER" ) );
|
||||||
|
|
||||||
// If its a vector light see if we can enable SSAO.
|
|
||||||
if ( lightType == LightInfo::Vector && smUseSSAOMask )
|
|
||||||
shadowMacros.push_back( GFXShaderMacro( "USE_SSAO_MASK" ) );
|
|
||||||
|
|
||||||
// Now create the material info object.
|
// Now create the material info object.
|
||||||
info = new LightMaterialInfo( lightMatName, smLightMatVertex[ lightType ], shadowMacros );
|
info = new LightMaterialInfo( lightMatName, smLightMatVertex[ lightType ], shadowMacros );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#include "renderInstance/renderDeferredMgr.h"
|
#include "renderInstance/renderDeferredMgr.h"
|
||||||
#include "math/mPolyhedron.impl.h"
|
#include "math/mPolyhedron.impl.h"
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
|
#include "lighting/advanced/advancedLightBinManager.h" //for ssao
|
||||||
#include "gfx/gfxDebugEvent.h"
|
#include "gfx/gfxDebugEvent.h"
|
||||||
#include "shaderGen/shaderGenVars.h"
|
#include "shaderGen/shaderGenVars.h"
|
||||||
#include "materials/shaderData.h"
|
#include "materials/shaderData.h"
|
||||||
|
|
@ -752,6 +752,24 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
mProbeArrayEffect->setShaderMacro("SKYLIGHT_ONLY", "1");
|
mProbeArrayEffect->setShaderMacro("SKYLIGHT_ONLY", "1");
|
||||||
else
|
else
|
||||||
mProbeArrayEffect->setShaderMacro("SKYLIGHT_ONLY", "0");
|
mProbeArrayEffect->setShaderMacro("SKYLIGHT_ONLY", "0");
|
||||||
|
|
||||||
|
//ssao mask
|
||||||
|
if (AdvancedLightBinManager::smUseSSAOMask)
|
||||||
|
{
|
||||||
|
//find ssaoMask
|
||||||
|
NamedTexTargetRef ssaoTarget = NamedTexTarget::find("ssaoMask");
|
||||||
|
GFXTextureObject* pTexObj = ssaoTarget->getTexture();
|
||||||
|
if (pTexObj)
|
||||||
|
{
|
||||||
|
mProbeArrayEffect->setShaderMacro("USE_SSAO_MASK");
|
||||||
|
mProbeArrayEffect->setTexture(6, pTexObj);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mProbeArrayEffect->setTexture(6, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
mProbeArrayEffect->setTexture(3, mBRDFTexture);
|
mProbeArrayEffect->setTexture(3, mBRDFTexture);
|
||||||
mProbeArrayEffect->setCubemapArrayTexture(4, mPrefilterArray);
|
mProbeArrayEffect->setCubemapArrayTexture(4, mPrefilterArray);
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,7 @@ singleton GFXStateBlockData( AL_VectorLightState )
|
||||||
mSamplerNames[1] = "shadowMap";
|
mSamplerNames[1] = "shadowMap";
|
||||||
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
samplerStates[2] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
||||||
mSamplerNames[2] = "dynamicShadowMap";
|
mSamplerNames[2] = "dynamicShadowMap";
|
||||||
samplerStates[3] = SamplerClampLinear; // SSAO Mask
|
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
||||||
mSamplerNames[3] = "ssaoMask";
|
|
||||||
samplerStates[4] = SamplerWrapPoint; // Random Direction Map
|
|
||||||
|
|
||||||
cullDefined = true;
|
cullDefined = true;
|
||||||
cullMode = GFXCullNone;
|
cullMode = GFXCullNone;
|
||||||
|
|
@ -72,11 +70,10 @@ singleton shaderData( AL_VectorLightShader )
|
||||||
samplerNames[0] = "$deferredBuffer";
|
samplerNames[0] = "$deferredBuffer";
|
||||||
samplerNames[1] = "$shadowMap";
|
samplerNames[1] = "$shadowMap";
|
||||||
samplerNames[2] = "$dynamicShadowMap";
|
samplerNames[2] = "$dynamicShadowMap";
|
||||||
samplerNames[3] = "$ssaoMask";
|
samplerNames[3] = "$gTapRotationTex";
|
||||||
samplerNames[4] = "$gTapRotationTex";
|
samplerNames[4] = "$lightBuffer";
|
||||||
samplerNames[5] = "$lightBuffer";
|
samplerNames[5] = "$colorBuffer";
|
||||||
samplerNames[6] = "$colorBuffer";
|
samplerNames[6] = "$matInfoBuffer";
|
||||||
samplerNames[7] = "$matInfoBuffer";
|
|
||||||
|
|
||||||
pixVersion = 3.0;
|
pixVersion = 3.0;
|
||||||
};
|
};
|
||||||
|
|
@ -89,7 +86,6 @@ new CustomMaterial( AL_VectorLightMaterial )
|
||||||
sampler["deferredBuffer"] = "#deferred";
|
sampler["deferredBuffer"] = "#deferred";
|
||||||
sampler["shadowMap"] = "$dynamiclight";
|
sampler["shadowMap"] = "$dynamiclight";
|
||||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||||
sampler["ssaoMask"] = "#ssaoMask";
|
|
||||||
sampler["lightBuffer"] = "#specularLighting";
|
sampler["lightBuffer"] = "#specularLighting";
|
||||||
sampler["colorBuffer"] = "#color";
|
sampler["colorBuffer"] = "#color";
|
||||||
sampler["matInfoBuffer"] = "#matinfo";
|
sampler["matInfoBuffer"] = "#matinfo";
|
||||||
|
|
@ -322,6 +318,7 @@ singleton ShaderData( PFX_ReflectionProbeArray )
|
||||||
samplerNames[3] = "$BRDFTexture";
|
samplerNames[3] = "$BRDFTexture";
|
||||||
samplerNames[4] = "$specularCubemapAR";
|
samplerNames[4] = "$specularCubemapAR";
|
||||||
samplerNames[5] = "$irradianceCubemapAR";
|
samplerNames[5] = "$irradianceCubemapAR";
|
||||||
|
samplerNames[6] = "$ssaoMask";
|
||||||
|
|
||||||
pixVersion = 2.0;
|
pixVersion = 2.0;
|
||||||
};
|
};
|
||||||
|
|
@ -350,4 +347,5 @@ singleton GFXStateBlockData( PFX_ReflectionProbeArrayStateBlock )
|
||||||
samplerStates[3] = SamplerClampPoint;
|
samplerStates[3] = SamplerClampPoint;
|
||||||
samplerStates[4] = SamplerClampLinear;
|
samplerStates[4] = SamplerClampLinear;
|
||||||
samplerStates[5] = SamplerClampLinear;
|
samplerStates[5] = SamplerClampLinear;
|
||||||
|
samplerStates[6] = SamplerClampPoint;
|
||||||
};
|
};
|
||||||
|
|
@ -81,6 +81,7 @@ struct Surface
|
||||||
|
|
||||||
float NdotV; // cos(angle between normal and view vector)
|
float NdotV; // cos(angle between normal and view vector)
|
||||||
vec3 f0; // fresnel value (rgb)
|
vec3 f0; // fresnel value (rgb)
|
||||||
|
float f90;
|
||||||
vec3 albedo; // diffuse light absorbtion value (rgb)
|
vec3 albedo; // diffuse light absorbtion value (rgb)
|
||||||
vec3 R; // reflection vector
|
vec3 R; // reflection vector
|
||||||
vec3 F; // fresnel term computed from f0, N and V
|
vec3 F; // fresnel term computed from f0, N and V
|
||||||
|
|
@ -93,8 +94,8 @@ void updateSurface(inout Surface surface)
|
||||||
surface.albedo = surface.baseColor.rgb * (1.0 - surface.metalness);
|
surface.albedo = surface.baseColor.rgb * (1.0 - surface.metalness);
|
||||||
surface.f0 = lerp(vec3(0.04f), surface.baseColor.rgb, surface.metalness);
|
surface.f0 = lerp(vec3(0.04f), surface.baseColor.rgb, surface.metalness);
|
||||||
surface.R = -reflect(surface.V, surface.N);
|
surface.R = -reflect(surface.V, surface.N);
|
||||||
float f90 = saturate(50.0 * dot(surface.f0, vec3(0.33,0.33,0.33)));
|
surface.f90 = saturate(50.0 * dot(surface.f0, vec3(0.33,0.33,0.33)));
|
||||||
surface.F = F_Schlick(surface.f0, f90, surface.NdotV);
|
surface.F = F_Schlick(surface.f0, surface.f90, surface.NdotV);
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface createSurface(vec4 normDepth, sampler2D colorBuffer, sampler2D matInfoBuffer, in vec2 uv, in vec3 wsEyePos, in vec3 wsEyeRay, in mat4 invView)
|
Surface createSurface(vec4 normDepth, sampler2D colorBuffer, sampler2D matInfoBuffer, in vec2 uv, in vec3 wsEyePos, in vec3 wsEyeRay, in mat4 invView)
|
||||||
|
|
@ -229,6 +230,11 @@ vec3 getPunctualLight(in Surface surface, in SurfaceToLight surfaceToLight, vec3
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float computeSpecOcclusion( float NdotV , float AO , float roughness )
|
||||||
|
{
|
||||||
|
return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO );
|
||||||
|
}
|
||||||
|
|
||||||
vec4 compute4Lights( Surface surface,
|
vec4 compute4Lights( Surface surface,
|
||||||
vec4 shadowMask,
|
vec4 shadowMask,
|
||||||
vec4 inLightPos[4],
|
vec4 inLightPos[4],
|
||||||
|
|
@ -421,20 +427,18 @@ vec4 computeForwardProbes(Surface surface,
|
||||||
specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha);
|
specular = mix(specular,textureLod(specularCubemapAR, vec4(surface.R, skylightCubemapIdx), lod).xyz, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
|
||||||
|
|
||||||
//energy conservation
|
//energy conservation
|
||||||
vec3 kD = vec3(1.0,1.0,1.0) - F;
|
vec3 kD = 1.0f - surface.F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0f - surface.metalness;
|
||||||
|
|
||||||
//apply brdf
|
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
|
||||||
//Do it once to save on texture samples
|
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
|
||||||
vec2 brdf = textureLod(BRDFTexture, vec2(surface.roughness, 1.0-surface.NdotV),0).xy;
|
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y;
|
||||||
specular *= brdf.x * F + brdf.y;
|
irradiance *= kD * surface.baseColor.rgb;
|
||||||
|
|
||||||
//final diffuse color
|
//AO
|
||||||
vec3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
irradiance *= surface.ao;
|
||||||
vec4 finalColor = vec4(diffuse + specular * surface.ao, 1.0);
|
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
|
||||||
|
|
||||||
return finalColor;
|
return vec4(irradiance + specular, 0);//alpha writes disabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@ struct Surface
|
||||||
float3 albedo; // diffuse light absorbtion value (rgb)
|
float3 albedo; // diffuse light absorbtion value (rgb)
|
||||||
float3 R; // reflection vector
|
float3 R; // reflection vector
|
||||||
float3 F; // fresnel term computed from f0, N and V
|
float3 F; // fresnel term computed from f0, N and V
|
||||||
|
float f90;
|
||||||
|
|
||||||
inline void Update()
|
inline void Update()
|
||||||
{
|
{
|
||||||
|
|
@ -94,7 +95,7 @@ struct Surface
|
||||||
f0 = lerp(0.04.xxx, baseColor.rgb, metalness);
|
f0 = lerp(0.04.xxx, baseColor.rgb, metalness);
|
||||||
|
|
||||||
R = -reflect(V, N);
|
R = -reflect(V, N);
|
||||||
float f90 = saturate(50.0 * dot(f0, 0.33));
|
f90 = saturate(50.0 * dot(f0, 0.33));
|
||||||
F = F_Schlick(f0, f90, NdotV);
|
F = F_Schlick(f0, f90, NdotV);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -235,6 +236,11 @@ inline float3 getPunctualLight(in Surface surface, in SurfaceToLight surfaceToLi
|
||||||
return final;
|
return final;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float computeSpecOcclusion( float NdotV , float AO , float roughness )
|
||||||
|
{
|
||||||
|
return saturate (pow( abs(NdotV + AO) , exp2 ( -16.0f * roughness - 1.0f )) - 1.0f + AO );
|
||||||
|
}
|
||||||
|
|
||||||
float4 compute4Lights( Surface surface,
|
float4 compute4Lights( Surface surface,
|
||||||
float4 shadowMask,
|
float4 shadowMask,
|
||||||
float4 inLightPos[4],
|
float4 inLightPos[4],
|
||||||
|
|
@ -462,19 +468,18 @@ float4 computeForwardProbes(Surface surface,
|
||||||
specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha);
|
specular = lerp(specular,TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, surface.R, skylightCubemapIdx, lod).xyz,alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
|
||||||
|
|
||||||
//energy conservation
|
//energy conservation
|
||||||
float3 kD = 1.0.xxx - F;
|
float3 kD = 1.0f - surface.F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0f - surface.metalness;
|
||||||
|
|
||||||
//apply brdf
|
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
|
||||||
//Do it once to save on texture samples
|
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
|
||||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture,float4(surface.roughness, 1.0-surface.NdotV, 0.0, 0.0)).xy;
|
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y;
|
||||||
specular *= brdf.x * F + brdf.y;
|
irradiance *= kD * surface.baseColor.rgb;
|
||||||
|
|
||||||
//final diffuse color
|
//AO
|
||||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
irradiance *= surface.ao;
|
||||||
float4 finalColor = float4(diffuse* surface.ao + specular * surface.ao, 1.0);
|
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
|
||||||
return finalColor;
|
|
||||||
|
return float4(irradiance + specular, 0);//alpha writes disabled
|
||||||
}
|
}
|
||||||
|
|
@ -24,6 +24,11 @@ uniform int numProbes;
|
||||||
uniform samplerCubeArray specularCubemapAR;
|
uniform samplerCubeArray specularCubemapAR;
|
||||||
uniform samplerCubeArray irradianceCubemapAR;
|
uniform samplerCubeArray irradianceCubemapAR;
|
||||||
|
|
||||||
|
#ifdef USE_SSAO_MASK
|
||||||
|
uniform sampler2D ssaoMask;
|
||||||
|
uniform vec4 rtParams6;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform vec4 inProbePosArray[MAX_PROBES];
|
uniform vec4 inProbePosArray[MAX_PROBES];
|
||||||
uniform vec4 inRefPosArray[MAX_PROBES];
|
uniform vec4 inRefPosArray[MAX_PROBES];
|
||||||
uniform mat4 worldToObjArray[MAX_PROBES];
|
uniform mat4 worldToObjArray[MAX_PROBES];
|
||||||
|
|
@ -52,6 +57,12 @@ void main()
|
||||||
{
|
{
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SSAO_MASK
|
||||||
|
float ssao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams6 ) ).r;
|
||||||
|
surface.ao = min(surface.ao, ssao);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
float alpha = 1;
|
float alpha = 1;
|
||||||
|
|
||||||
|
|
@ -190,20 +201,19 @@ void main()
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
|
||||||
|
|
||||||
//energy conservation
|
//energy conservation
|
||||||
vec3 kD = vec3(1,1,1) - F;
|
vec3 kD = 1.0f - surface.F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0f - surface.metalness;
|
||||||
|
|
||||||
//apply brdf
|
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
|
||||||
//Do it once to save on texture samples
|
vec2 envBRDF = textureLod(BRDFTexture, vec2(dfgNdotV, surface.roughness),0).rg;
|
||||||
vec2 brdf = textureLod(BRDFTexture, vec2(surface.roughness, surface.NdotV),0).xy;
|
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y;
|
||||||
specular *= brdf.x * F + brdf.y;
|
irradiance *= kD * surface.baseColor.rgb;
|
||||||
|
|
||||||
//final diffuse color
|
//AO
|
||||||
vec3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
irradiance *= surface.ao;
|
||||||
vec4 finalColor = vec4(diffuse + specular * surface.ao, 1.0);
|
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
|
||||||
|
|
||||||
OUT_col = finalColor;
|
OUT_col = vec4(irradiance + specular, 0);//alpha writes disabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,11 +37,6 @@ uniform sampler2D deferredBuffer;
|
||||||
uniform sampler2D shadowMap;
|
uniform sampler2D shadowMap;
|
||||||
uniform sampler2D dynamicShadowMap;
|
uniform sampler2D dynamicShadowMap;
|
||||||
|
|
||||||
#ifdef USE_SSAO_MASK
|
|
||||||
uniform sampler2D ssaoMask ;
|
|
||||||
uniform vec4 rtParams3;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uniform sampler2D colorBuffer;
|
uniform sampler2D colorBuffer;
|
||||||
uniform sampler2D matInfoBuffer;
|
uniform sampler2D matInfoBuffer;
|
||||||
uniform float lightBrightness;
|
uniform float lightBrightness;
|
||||||
|
|
@ -245,10 +240,6 @@ void main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //NO_SHADOW
|
#endif //NO_SHADOW
|
||||||
// Sample the AO texture.
|
|
||||||
#ifdef USE_SSAO_MASK
|
|
||||||
surface.ao *= 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( uv0.xy, rtParams3 ) ).r;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//get directional light contribution
|
//get directional light contribution
|
||||||
vec3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);
|
vec3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,11 @@ uniform int numProbes;
|
||||||
TORQUE_UNIFORM_SAMPLERCUBEARRAY(specularCubemapAR, 4);
|
TORQUE_UNIFORM_SAMPLERCUBEARRAY(specularCubemapAR, 4);
|
||||||
TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemapAR, 5);
|
TORQUE_UNIFORM_SAMPLERCUBEARRAY(irradianceCubemapAR, 5);
|
||||||
|
|
||||||
|
#ifdef USE_SSAO_MASK
|
||||||
|
TORQUE_UNIFORM_SAMPLER2D(ssaoMask, 6);
|
||||||
|
uniform float4 rtParams6;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform float4 inProbePosArray[MAX_PROBES];
|
uniform float4 inProbePosArray[MAX_PROBES];
|
||||||
uniform float4 inRefPosArray[MAX_PROBES];
|
uniform float4 inRefPosArray[MAX_PROBES];
|
||||||
uniform float4x4 worldToObjArray[MAX_PROBES];
|
uniform float4x4 worldToObjArray[MAX_PROBES];
|
||||||
|
|
@ -49,6 +54,11 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
return TORQUE_TEX2D(colorBuffer, IN.uv0.xy);
|
return TORQUE_TEX2D(colorBuffer, IN.uv0.xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SSAO_MASK
|
||||||
|
float ssao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams6 ) ).r;
|
||||||
|
surface.ao = min(surface.ao, ssao);
|
||||||
|
#endif
|
||||||
|
|
||||||
float alpha = 1;
|
float alpha = 1;
|
||||||
|
|
||||||
#if SKYLIGHT_ONLY == 0
|
#if SKYLIGHT_ONLY == 0
|
||||||
|
|
@ -182,19 +192,18 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
||||||
return float4(irradiance, 1);
|
return float4(irradiance, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
|
||||||
|
|
||||||
//energy conservation
|
//energy conservation
|
||||||
float3 kD = 1.0.xxx - F;
|
float3 kD = 1.0f - surface.F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0f - surface.metalness;
|
||||||
|
|
||||||
//apply brdf
|
float dfgNdotV = max( surface.NdotV , 0.0009765625f ); //0.5f/512.0f (512 is size of dfg/brdf lookup tex)
|
||||||
//Do it once to save on texture samples
|
float2 envBRDF = TORQUE_TEX2DLOD(BRDFTexture, float4(dfgNdotV, surface.roughness,0,0)).rg;
|
||||||
float2 brdf = TORQUE_TEX2DLOD(BRDFTexture, float4(surface.roughness, 1.0-surface.NdotV, 0.0, 0.0)).xy;
|
specular *= surface.F * envBRDF.x + surface.f90 * envBRDF.y;
|
||||||
specular *= brdf.x * F + brdf.y;
|
irradiance *= kD * surface.baseColor.rgb;
|
||||||
|
|
||||||
//final diffuse color
|
//AO
|
||||||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
irradiance *= surface.ao;
|
||||||
float4 finalColor = float4(diffuse* surface.ao + specular * surface.ao, 1.0);
|
specular *= computeSpecOcclusion(surface.NdotV, surface.ao, surface.roughness);
|
||||||
return finalColor;
|
|
||||||
|
return float4(irradiance + specular, 0);//alpha writes disabled
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ static float2 sNonUniformTaps[NUM_PRE_TAPS] =
|
||||||
|
|
||||||
/// The texture used to do per-pixel pseudorandom
|
/// The texture used to do per-pixel pseudorandom
|
||||||
/// rotations of the filter taps.
|
/// rotations of the filter taps.
|
||||||
TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 4);
|
TORQUE_UNIFORM_SAMPLER2D(gTapRotationTex, 3);
|
||||||
|
|
||||||
float softShadow_sampleTaps( TORQUE_SAMPLER2D(shadowMap1),
|
float softShadow_sampleTaps( TORQUE_SAMPLER2D(shadowMap1),
|
||||||
float2 sinCos,
|
float2 sinCos,
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,8 @@ TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
|
TORQUE_UNIFORM_SAMPLER2D(shadowMap, 1);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
|
TORQUE_UNIFORM_SAMPLER2D(dynamicShadowMap, 2);
|
||||||
|
|
||||||
#ifdef USE_SSAO_MASK
|
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 5);
|
||||||
TORQUE_UNIFORM_SAMPLER2D(ssaoMask, 3);
|
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 6);
|
||||||
uniform float4 rtParams3;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(colorBuffer, 6);
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(matInfoBuffer, 7);
|
|
||||||
|
|
||||||
uniform float lightBrightness;
|
uniform float lightBrightness;
|
||||||
uniform float3 lightDirection;
|
uniform float3 lightDirection;
|
||||||
|
|
@ -234,10 +229,6 @@ float4 main(FarFrustumQuadConnectP IN) : SV_TARGET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //NO_SHADOW
|
#endif //NO_SHADOW
|
||||||
// Sample the AO texture.
|
|
||||||
#ifdef USE_SSAO_MASK
|
|
||||||
surface.ao *= 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams3 ) ).r;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//get directional light contribution
|
//get directional light contribution
|
||||||
float3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);
|
float3 lighting = getDirectionalLight(surface, surfaceToLight, lightingColor.rgb, lightBrightness, shadow);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue