mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
work on getting render bin ordering correct
This commit is contained in:
parent
861da2ba2d
commit
0d9cc4cdac
6 changed files with 31 additions and 17 deletions
|
|
@ -31,6 +31,8 @@
|
||||||
#include "math/mPolyhedron.impl.h"
|
#include "math/mPolyhedron.impl.h"
|
||||||
#include "gfx/gfxTransformSaver.h"
|
#include "gfx/gfxTransformSaver.h"
|
||||||
|
|
||||||
|
#include "gfx/gfxDebugEvent.h"
|
||||||
|
|
||||||
IMPLEMENT_CONOBJECT(RenderProbeMgr);
|
IMPLEMENT_CONOBJECT(RenderProbeMgr);
|
||||||
|
|
||||||
ConsoleDocClass( RenderProbeMgr,
|
ConsoleDocClass( RenderProbeMgr,
|
||||||
|
|
@ -205,6 +207,8 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
|
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
|
|
||||||
|
GFXDEBUGEVENT_SCOPE(RenderProbeMgr_render, ColorI::WHITE);
|
||||||
|
|
||||||
NamedTexTargetRef diffuseLightingTarget = NamedTexTarget::find("diffuseLighting");
|
NamedTexTargetRef diffuseLightingTarget = NamedTexTarget::find("diffuseLighting");
|
||||||
|
|
||||||
if (diffuseLightingTarget.isNull())
|
if (diffuseLightingTarget.isNull())
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ new ShaderData( AL_ProbeShader )
|
||||||
singleton PostEffect( AL_PreCapture )
|
singleton PostEffect( AL_PreCapture )
|
||||||
{
|
{
|
||||||
renderTime = "PFXBeforeBin";
|
renderTime = "PFXBeforeBin";
|
||||||
renderBin = "ProbeBin";
|
renderBin = "EditorBin";
|
||||||
shader = AL_ProbeShader;
|
shader = AL_ProbeShader;
|
||||||
stateBlock = AL_DeferredCaptureState;
|
stateBlock = AL_DeferredCaptureState;
|
||||||
texture[0] = "#color";
|
texture[0] = "#color";
|
||||||
|
|
@ -108,7 +108,7 @@ singleton PostEffect( AL_PreCapture )
|
||||||
singleton PostEffect( AL_DeferredShading )
|
singleton PostEffect( AL_DeferredShading )
|
||||||
{
|
{
|
||||||
renderTime = "PFXAfterBin";
|
renderTime = "PFXAfterBin";
|
||||||
renderBin = "ProbeBin";
|
renderBin = "BeginBin";
|
||||||
shader = AL_DeferredShader;
|
shader = AL_DeferredShader;
|
||||||
stateBlock = AL_DeferredShadingState;
|
stateBlock = AL_DeferredShadingState;
|
||||||
texture[0] = "#color";
|
texture[0] = "#color";
|
||||||
|
|
|
||||||
|
|
@ -49,9 +49,9 @@ function initRenderManager()
|
||||||
|
|
||||||
// We really need to fix the sky to render after all the
|
// We really need to fix the sky to render after all the
|
||||||
// meshes... but that causes issues in reflections.
|
// 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 RenderVistaMgr() { bintype = "Vista"; renderOrder = 0.15; processAddOrder = 0.15; } );
|
||||||
|
|
||||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
|
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
|
||||||
|
|
|
||||||
|
|
@ -33,22 +33,31 @@ TORQUE_UNIFORM_SAMPLER2D(deferredTex,4);
|
||||||
uniform float radius;
|
uniform float radius;
|
||||||
uniform float2 targetSize;
|
uniform float2 targetSize;
|
||||||
uniform int captureRez;
|
uniform int captureRez;
|
||||||
float4 main( PFXVertToPix IN) : TORQUE_TARGET0
|
float4 main( PFXVertToPix IN ) : TORQUE_TARGET0
|
||||||
{
|
{
|
||||||
float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
|
float depth = TORQUE_DEFERRED_UNCONDITION( deferredTex, IN.uv0 ).w;
|
||||||
|
|
||||||
if (depth>0.9999)
|
if (depth>0.9999)
|
||||||
clip(-1);
|
return float4(0,0,0,0);
|
||||||
float3 colorBuffer = TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb; //albedo
|
|
||||||
|
float3 albedo = TORQUE_TEX2D( colorBufferTex, IN.uv0 ).rgb; //albedo
|
||||||
float4 matInfo = TORQUE_TEX2D(matInfoTex, IN.uv0); //flags|smoothness|ao|metallic
|
float4 matInfo = TORQUE_TEX2D(matInfoTex, IN.uv0); //flags|smoothness|ao|metallic
|
||||||
|
|
||||||
bool emissive = getFlag(matInfo.r, 0);
|
bool emissive = getFlag(matInfo.r, 0);
|
||||||
if (emissive)
|
if (emissive)
|
||||||
{
|
{
|
||||||
return float4(colorBuffer, 1.0);
|
return float4(albedo, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 diffuseLighting = TORQUE_TEX2D( diffuseLightingBuffer, IN.uv0 ); //shadowmap*specular
|
float4 diffuse = TORQUE_TEX2D( diffuseLightingBuffer, IN.uv0 ); //shadowmap*specular
|
||||||
colorBuffer *= diffuseLighting.rgb;
|
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;
|
float2 relUV = IN.uv0*targetSize/captureRez;
|
||||||
|
|
||||||
//we use a 1k depth range in the capture frustum.
|
//we use a 1k depth range in the capture frustum.
|
||||||
|
|
@ -56,5 +65,5 @@ float4 main( PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
depth*=2000/radius;
|
depth*=2000/radius;
|
||||||
|
|
||||||
float rLen = length(float3(relUV,depth)-float3(0.5,0.5,0));
|
float rLen = length(float3(relUV,depth)-float3(0.5,0.5,0));
|
||||||
return hdrEncode( float4(colorBuffer,rLen));
|
return hdrEncode( float4(light,rLen));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ PS_OUTPUT main( ConvexConnectP IN )
|
||||||
float3 surfToEye = normalize(worldPos.xyz-eyePosWorld.xyz);
|
float3 surfToEye = normalize(worldPos.xyz-eyePosWorld.xyz);
|
||||||
Output.diffuse = float4(iblBoxDiffuse(wsNormal, worldPos, TORQUE_SAMPLERCUBE_MAKEARG(irradianceCubemap), probeWSPos, bbMin, bbMax), blendVal);
|
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.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.diffuse.rgb *= matInfo.g;
|
||||||
Output.spec *= matInfo.g;
|
Output.spec.rgb *= matInfo.g;
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,12 @@ PS_OUTPUT main( ConvexConnectP IN )
|
||||||
|
|
||||||
float3 specular = iblSpecular(wsEyeRay, wsNormal, roughness);
|
float3 specular = iblSpecular(wsEyeRay, wsNormal, roughness);
|
||||||
|
|
||||||
|
float blendVal = 0.0001;
|
||||||
|
|
||||||
Output.diffuse = float4(irradiance.rgb, 1);
|
Output.diffuse = float4(irradiance.rgb, blendVal);
|
||||||
Output.spec = float4(specular.rgb, 1);
|
Output.spec = float4(specular.rgb, blendVal);
|
||||||
Output.diffuse *= matInfo.g;
|
Output.diffuse.rgb *= matInfo.g;
|
||||||
Output.spec *= matInfo.g;
|
Output.spec.rgb *= matInfo.g;
|
||||||
return Output;
|
return Output;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue