work on getting render bin ordering correct

This commit is contained in:
Azaezel 2018-10-24 18:27:43 -05:00
parent ddb431181b
commit 83ef5db910
6 changed files with 31 additions and 17 deletions

View file

@ -31,6 +31,8 @@
#include "math/mPolyhedron.impl.h"
#include "gfx/gfxTransformSaver.h"
#include "gfx/gfxDebugEvent.h"
IMPLEMENT_CONOBJECT(RenderProbeMgr);
ConsoleDocClass( RenderProbeMgr,
@ -205,6 +207,8 @@ void RenderProbeMgr::render( SceneRenderState *state )
GFXTransformSaver saver;
GFXDEBUGEVENT_SCOPE(RenderProbeMgr_render, ColorI::WHITE);
NamedTexTargetRef diffuseLightingTarget = NamedTexTarget::find("diffuseLighting");
if (diffuseLightingTarget.isNull())

View file

@ -92,7 +92,7 @@ new ShaderData( AL_ProbeShader )
singleton PostEffect( AL_PreCapture )
{
renderTime = "PFXBeforeBin";
renderBin = "ProbeBin";
renderBin = "EditorBin";
shader = AL_ProbeShader;
stateBlock = AL_DeferredCaptureState;
texture[0] = "#color";
@ -108,7 +108,7 @@ singleton PostEffect( AL_PreCapture )
singleton PostEffect( AL_DeferredShading )
{
renderTime = "PFXAfterBin";
renderBin = "ProbeBin";
renderBin = "BeginBin";
shader = AL_DeferredShader;
stateBlock = AL_DeferredShadingState;
texture[0] = "#color";

View file

@ -49,9 +49,9 @@ function initRenderManager()
// We really need to fix the sky to render after all the
// meshes... but that causes issues in reflections.
DiffuseRenderPassManager.addManager( new RenderObjectMgr(SkyBin) { bintype = "Sky"; renderOrder = 0.1; processAddOrder = 0.1; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr(SkyBin) { bintype = "Sky"; renderOrder = 0.015; processAddOrder = 0.015; } );
DiffuseRenderPassManager.addManager( new RenderProbeMgr(ProbeBin) { bintype = "Probes"; renderOrder = 0.15; processAddOrder = 0.15; } );
DiffuseRenderPassManager.addManager( new RenderProbeMgr(ProbeBin) { bintype = "Probes"; renderOrder = 0.02; processAddOrder = 0.02; } );
//DiffuseRenderPassManager.addManager( new RenderVistaMgr() { bintype = "Vista"; renderOrder = 0.15; processAddOrder = 0.15; } );
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );

View file

@ -33,22 +33,31 @@ TORQUE_UNIFORM_SAMPLER2D(deferredTex,4);
uniform float radius;
uniform float2 targetSize;
uniform int captureRez;
float4 main( PFXVertToPix IN) : TORQUE_TARGET0
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
{
float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
if (depth>0.9999)
clip(-1);
float3 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb; //albedo
return float4(0,0,0,0);
float3 albedo = TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb; //albedo
float4 matInfo = TORQUE_TEX2D(matInfoTex, IN.uv0); //flags|smoothness|ao|metallic
bool emissive = getFlag(matInfo.r, 0);
if (emissive)
{
return float4(colorBuffer, 1.0);
return float4(albedo, 1.0);
}
float4 diffuseLighting = TORQUE_TEX2D( diffuseLightingBuffer, IN.uv0 ); //shadowmap*specular
colorBuffer *= diffuseLighting.rgb;
float4 diffuse = TORQUE_TEX2D( diffuseLightingBuffer, IN.uv0 ); //shadowmap*specular
float4 specular = TORQUE_TEX2D( specularLightingBuffer, IN.uv0 ); //environment mapping*lightmaps
float metalness = matInfo.a;
float3 diffuseColor = albedo - (albedo * metalness);
float3 specularColor = lerp(float3(0.04,0.04,0.04), albedo, metalness);
float3 light = (diffuseColor * diffuse.rgb) + (specularColor * specular.rgb);
float2 relUV = IN.uv0*targetSize/captureRez;
//we use a 1k depth range in the capture frustum.
@ -56,5 +65,5 @@ float4 main( PFXVertToPix IN) : TORQUE_TARGET0
depth*=2000/radius;
float rLen = length(float3(relUV,depth)-float3(0.5,0.5,0));
return hdrEncode( float4(colorBuffer,rLen));
return hdrEncode( float4(light,rLen));
}

View file

@ -207,7 +207,7 @@ PS_OUTPUT main( ConvexConnectP IN )
float3 surfToEye = normalize(worldPos.xyz-eyePosWorld.xyz);
Output.diffuse = float4(iblBoxDiffuse(wsNormal, worldPos, TORQUE_SAMPLERCUBE_MAKEARG(irradianceCubemap), probeWSPos, bbMin, bbMax), blendVal);
Output.spec = float4(iblBoxSpecular(wsNormal, worldPos, 1.0 - matInfo.b, surfToEye, TORQUE_SAMPLER2D_MAKEARG(BRDFTexture), TORQUE_SAMPLERCUBE_MAKEARG(cubeMap), probeWSPos, bbMin, bbMax), blendVal);
Output.diffuse *= matInfo.g;
Output.spec *= matInfo.g;
Output.diffuse.rgb *= matInfo.g;
Output.spec.rgb *= matInfo.g;
return Output;
}

View file

@ -136,11 +136,12 @@ PS_OUTPUT main( ConvexConnectP IN )
float3 specular = iblSpecular(wsEyeRay, wsNormal, roughness);
float blendVal = 0.0001;
Output.diffuse = float4(irradiance.rgb, 1);
Output.spec = float4(specular.rgb, 1);
Output.diffuse *= matInfo.g;
Output.spec *= matInfo.g;
Output.diffuse = float4(irradiance.rgb, blendVal);
Output.spec = float4(specular.rgb, blendVal);
Output.diffuse.rgb *= matInfo.g;
Output.spec.rgb *= matInfo.g;
return Output;
}