The final step (barring any overlooked missing bits, requested refactors, and of course, rolling in dependencies already submitted as PRs) consists of:

renderPrePassMgr.cpp related:
A) shifting .addFeature( MFT_XYZ); calls from ProcessedShaderMaterial::_determineFeatures to ProcessedPrePassMaterial::_determineFeatures
B) mimicking the "// set the XXX if different" entries from RenderMeshMgr::render in RenderPrePassMgr::render
C) fleshing out ProcessedPrePassMaterial::getNumStages() so that it shares a 1:1 correlation with ProcessedShaderMaterial::getNumStages()
D) causing inline void Swizzle<T, mapLength>::ToBuffer( void *destination, const void *source, const dsize_t size )  to silently fail rather than fatally assert if a source or destination buffer is not yet ready to be filled. (support for #customTarget scripted render targets)

Reflections:
A) removing reflectRenderState.disableAdvancedLightingBins(true); entries. this would otherwise early out from prepass and provide no color data whatsoever.
B) removing the fd.features.addFeature( MFT_ForwardShading ); entry forcing all materials to be forward lit when reflected.
C) 2 things best described bluntly as working hacks:
C1) when reflected, a scattersky is rotated PI along it's z then x axis in order to draw properly.
C2) along similar lines, in terraincellmaterial, we shut off culling if it's a prepass material.

Skies: scattersky is given a pair of rotations for reflection purposes, all sky objects are given a z value for depth testing.
This commit is contained in:
Azaezel 2016-02-16 02:50:49 -06:00
parent 5ed06fff9d
commit 8c5810adad
58 changed files with 353 additions and 117 deletions

View file

@ -0,0 +1,49 @@
//--- OBJECT WRITE BEGIN ---
$ThisPrefab = new SimGroup() {
canSave = "1";
canSaveDynamicFields = "1";
new ParticleEmitterNode() {
active = "1";
emitter = "FireEmitter";
velocity = "1";
dataBlock = "EmberNode";
position = "0 0 0";
rotation = "1 0 0 0";
scale = "1 1 1";
canSave = "1";
canSaveDynamicFields = "1";
};
new PointLight() {
radius = "10";
isEnabled = "1";
color = "1 0.603922 0 1";
brightness = "1";
castShadows = "1";
staticRefreshFreq = "250";
dynamicRefreshFreq = "8";
priority = "1";
animate = "1";
animationPeriod = "1";
animationPhase = "1";
flareScale = "1";
attenuationRatio = "0 1 1";
shadowType = "DualParaboloidSinglePass";
texSize = "512";
overDarkFactor = "2000 1000 500 100";
shadowDistance = "400";
shadowSoftness = "0.15";
numSplits = "1";
logWeight = "0.91";
fadeStartDistance = "0";
lastSplitTerrainOnly = "0";
representedInLightmap = "0";
shadowDarkenColor = "0 0 0 -1";
includeLightmappedGeometryInShadow = "0";
position = "0 0 0";
rotation = "1 0 0 0";
canSave = "1";
canSaveDynamicFields = "1";
};
};
//--- OBJECT WRITE END ---

View file

@ -27,7 +27,6 @@ singleton Material(defaultTree_bark_material)
diffuseMap[0] = "art/shapes/trees/defaulttree/defaulttree_bark_diffuse.dds";
normalMap[0] = "art/shapes/trees/defaulttree/defaulttree_bark_normal_specular.dds";
specularMap[0] = "";
diffuseColor[0] = "1 1 1 1";
specular[0] = "0.9 0.9 0.9 1";
@ -37,6 +36,7 @@ singleton Material(defaultTree_bark_material)
translucent = false;
translucentBlendOp = "None";
pixelSpecular[0] = "1";
castDynamicShadows = "0";
};
singleton Material(defaulttree_material)
@ -45,7 +45,6 @@ singleton Material(defaulttree_material)
diffuseMap[0] = "art/shapes/trees/defaulttree/defaulttree_diffuse_transparency.dds";
normalMap[0] = "art/shapes/trees/defaulttree/defaulttree_normal_specular.dds";
specularMap[0] = "";
diffuseColor[0] = "1 1 1 1";
specular[0] = "0.9 0.9 0.9 1";
@ -57,6 +56,7 @@ singleton Material(defaulttree_material)
pixelSpecular[0] = "1";
alphaTest = "1";
alphaRef = "127";
castDynamicShadows = "0";
};
singleton Material(defaultTree_fronds_material)
@ -71,6 +71,7 @@ singleton Material(defaultTree_fronds_material)
alphaTest = "1";
alphaRef = "114";
translucent = "1";
castDynamicShadows = "0";
};
singleton Material(defaulttree_ColorEffectR27G177B88_material)
@ -79,4 +80,6 @@ singleton Material(defaulttree_ColorEffectR27G177B88_material)
diffuseColor[0] = "0.105882 0.694118 0.345098 1";
specularPower[0] = "10";
translucentBlendOp = "None";
castDynamicShadows = "0";
castShadows = "0";
};

View file

@ -34,4 +34,5 @@ singleton Material( DesertSkyMat )
{
cubemap = DesertSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};

View file

@ -34,6 +34,7 @@ singleton Material( NightSkyMat )
{
cubemap = NightCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton Material( Moon_Glow_Mat )
@ -50,4 +51,5 @@ singleton Material( Moon_Mat )
emissive = true;
translucent = true;
vertColor[ 0 ] = true;
isSky = true;
};

View file

@ -34,6 +34,7 @@ singleton Material( BlackSkyMat )
{
cubemap = BlackSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton CubemapData( BlueSkyCubemap )
@ -50,6 +51,7 @@ singleton Material( BlueSkyMat )
{
cubemap = BlueSkyCubemap;
materialTag0 = "Skies";
isSky = true;
};
singleton CubemapData( GreySkyCubemap )
@ -66,4 +68,5 @@ singleton Material( GreySkyMat )
{
cubemap = GreySkyCubemap;
materialTag0 = "Skies";
isSky = true;
};

View file

@ -43,6 +43,7 @@ exec( "./shaders.cs" );
exec( "./lightViz.cs" );
exec( "./shadowViz.cs" );
exec( "./shadowViz.gui" );
exec( "./deferredShading.cs" );
function onActivateAdvancedLM()
{
@ -58,12 +59,18 @@ function onActivateAdvancedLM()
// Enable the offscreen target so that AL will work
// with MSAA back buffers and for HDR rendering.
AL_FormatToken.enable();
// Activate Deferred Shading
AL_DeferredShading.enable();
}
function onDeactivateAdvancedLM()
{
// Disable the offscreen render target.
AL_FormatToken.disable();
// Deactivate Deferred Shading
AL_DeferredShading.disable();
}
function setAdvancedLighting()

View file

@ -51,7 +51,7 @@ singleton ShaderData( PFX_CausticsShader )
singleton PostEffect( CausticsPFX )
{
isEnabled = false;
renderTime = "PFXBeforeBin";
renderTime = "PFXAfterDiffuse";
renderBin = "ObjTranslucentBin";
//renderPriority = 0.1;

View file

@ -172,6 +172,8 @@ singleton ShaderData( HDR_CombineShader )
samplerNames[2] = "$bloomTex";
samplerNames[3] = "$colorCorrectionTex";
samplerNames[4] = "prepassTex";
pixVersion = 3.0;
};
@ -469,6 +471,7 @@ singleton PostEffect( HDRPostFX )
texture[1] = "#adaptedLum";
texture[2] = "#bloomFinal";
texture[3] = $HDRPostFX::colorCorrectionRamp;
texture[4] = "#prepass";
target = "$backBuffer";
};
};

View file

@ -47,7 +47,7 @@ singleton PostEffect( TurbulenceFx )
isEnabled = false;
allowReflectPass = true;
renderTime = "PFXAfterBin";
renderTime = "PFXAfterDiffuse";
renderBin = "GlowBin";
renderPriority = 0.5; // Render after the glows themselves

View file

@ -22,13 +22,13 @@
new GFXStateBlockData( ScatterSkySBData )
{
cullDefined = true;
//cullDefined = true;
cullMode = "GFXCullNone";
zDefined = true;
zEnable = true;
zWriteEnable = false;
zFunc = "GFXCmpLessEqual";
//zFunc = "GFXCmpLessEqual";
samplersDefined = true;
samplerStates[0] = SamplerClampLinear;

View file

@ -46,6 +46,7 @@ ConnectData main( CloudVert IN )
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos.w = OUT.hpos.z;
float2 uv = IN.uv0;
uv += texOffset;

View file

@ -60,8 +60,8 @@ uniform float3 texScale;
ConnectData main( CloudVert IN )
{
ConnectData OUT;
OUT.hpos = mul(modelview, IN.pos);
OUT.hpos.w = OUT.hpos.z;
// Offset the uv so we don't have a seam directly over our head.
float2 uv = IN.uv0 + float2( 0.5, 0.5 );

View file

@ -41,6 +41,7 @@ out vec2 texCoord;
void main()
{
gl_Position = tMul(modelview, IN_pos);
gl_Position.w = gl_Position.z;
vec2 uv = IN_uv0;
uv += texOffset;

View file

@ -62,6 +62,7 @@ void main()
vec2 IN_uv0 = vTexCoord0.st;
gl_Position = modelview * IN_pos;
gl_Position.w = gl_Position.z;
// Offset the uv so we don't have a seam directly over our head.
vec2 uv = IN_uv0 + vec2( 0.5, 0.5 );

View file

@ -73,5 +73,8 @@ void main()
discard;
OUT_col.a = 1;
OUT_col = clamp(OUT_col, 0.0, 1.0);
OUT_col = hdrEncode( OUT_col );
}

View file

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
struct Fragout
{
float4 col : COLOR0;
float4 col1 : COLOR1;
float4 col2 : COLOR2;
};
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
Fragout main( )
{
Fragout OUT;
OUT.col = float4(0.0, 0.0, 0.0, 0.0);
OUT.col1 = float4(1.0, 1.0, 1.0, 1.0);
// Draw on color buffer.
OUT.col2 = float4(1.0, 0.0, 0.0, 1.0);
return OUT;
}

View file

@ -24,13 +24,13 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D prepassBuffer;
uniform sampler2D prepassTex;
uniform sampler1D depthViz;
out vec4 OUT_col;
void main()
{
float depth = prepassUncondition( prepassBuffer, uv0 ).w;
float depth = prepassUncondition( prepassTex, uv0 ).w;
OUT_col = vec4( texture( depthViz, depth ).rgb, 1.0 );
}

View file

@ -24,12 +24,12 @@
#include "shadergen:/autogenConditioners.h"
in vec2 uv0;
uniform sampler2D prepassBuffer;
uniform sampler2D prepassTex;
out vec4 OUT_col;
void main()
{
vec3 normal = prepassUncondition( prepassBuffer, uv0 ).xyz;
vec3 normal = prepassUncondition( prepassTex, uv0 ).xyz;
OUT_col = vec4( ( normal + 1.0 ) * 0.5, 1.0 );
}

View file

@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
layout (location = 0) out vec4 col;
layout (location = 1) out vec4 col1;
layout (location = 2) out vec4 col2;
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main()
{
col = vec4(0.0, 0.0, 0.0, 0.0);
col1 = vec4(1.0, 1.0, 1.0, 1.0);
// Draw on color buffer.
col2 = vec4(1.0, 0.0, 0.0, 1.0);
}

View file

@ -20,6 +20,7 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "shadergen:/autogenConditioners.h"
#include "../../torque.hlsl"
#include "../postFx.hlsl"
@ -27,6 +28,7 @@ uniform sampler2D sceneTex : register( s0 );
uniform sampler2D luminanceTex : register( s1 );
uniform sampler2D bloomTex : register( s2 );
uniform sampler1D colorCorrectionTex : register( s3 );
uniform sampler2D prepassTex : register(S4);
uniform float2 texSize0;
uniform float2 texSize2;
@ -83,13 +85,16 @@ float4 main( PFXVertToPix IN ) : COLOR0
}
// Add the bloom effect.
sample += g_fBloomScale * bloom;
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
if (depth>0.9999)
sample += g_fBloomScale * bloom;
// Apply the color correction.
sample.r = tex1D( colorCorrectionTex, sample.r ).r;
sample.g = tex1D( colorCorrectionTex, sample.g ).g;
sample.b = tex1D( colorCorrectionTex, sample.b ).b;
// Apply gamma correction
sample.rgb = pow( abs(sample.rgb), g_fOneOverGamma );

View file

@ -23,11 +23,13 @@
#include "../../../gl/torque.glsl"
#include "../../../gl/hlslCompat.glsl"
#include "../../gl/postFX.glsl"
#include "shadergen:/autogenConditioners.h"
uniform sampler2D sceneTex;
uniform sampler2D luminanceTex;
uniform sampler2D bloomTex;
uniform sampler1D colorCorrectionTex;
uniform sampler2D prepassTex;
uniform vec2 texSize0;
uniform vec2 texSize2;
@ -86,7 +88,9 @@ void main()
}
// Add the bloom effect.
_sample += g_fBloomScale * bloom;
float depth = prepassUncondition( prepassTex, IN_uv0 ).w;
if (depth>0.9999)
_sample += g_fBloomScale * bloom;
// Apply the color correction.
_sample.r = texture( colorCorrectionTex, _sample.r ).r;

View file

@ -62,6 +62,6 @@ float4 main( Conn In ) : COLOR0
Out = lerp( color, nightSkyColor, nightInterpAndExposure.y );
Out.a = 1;
Out = saturate(Out);
return hdrEncode( Out );
}