mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-22 12:55:34 +00:00
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:
parent
5ed06fff9d
commit
8c5810adad
58 changed files with 353 additions and 117 deletions
|
|
@ -120,8 +120,7 @@ inline void Swizzle<T, mapLength>::ToBuffer( void *destination, const void *sour
|
|||
{
|
||||
// TODO: OpenMP?
|
||||
AssertFatal( size % ( sizeof( T ) * mapLength ) == 0, "Bad buffer size for swizzle, see docs." );
|
||||
AssertFatal( destination != NULL, "Swizzle::ToBuffer - got a NULL destination pointer!" );
|
||||
AssertFatal( source != NULL, "Swizzle::ToBuffer - got a NULL source pointer!" );
|
||||
if (!destination || !source) return;
|
||||
|
||||
T *dest = reinterpret_cast<T *>( destination );
|
||||
const T *src = reinterpret_cast<const T *>( source );
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ bool BasicClouds::onAdd()
|
|||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( false, false );
|
||||
desc.setZReadWrite( true, false );
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeV = GFXAddressWrap;
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ bool CloudLayer::onAdd()
|
|||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( false, false );
|
||||
desc.setZReadWrite( true, false );
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeV = GFXAddressWrap;
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ void DecalRoad::prepRenderImage( SceneRenderState* state )
|
|||
MathUtils::getZBiasProjectionMatrix( gDecalBias, frustum, tempMat );
|
||||
coreRI.projection = tempMat;
|
||||
|
||||
coreRI.type = RenderPassManager::RIT_Decal;
|
||||
coreRI.type = RenderPassManager::RIT_DecalRoad;
|
||||
coreRI.vertBuff = &mVB;
|
||||
coreRI.primBuff = &mPB;
|
||||
coreRI.matInst = matInst;
|
||||
|
|
|
|||
|
|
@ -955,12 +955,21 @@ void ScatterSky::_render( ObjectRenderInst *ri, SceneRenderState *state, BaseMat
|
|||
|
||||
Point3F camPos2 = state->getCameraPosition();
|
||||
MatrixF xfm(true);
|
||||
xfm.setPosition(camPos2 - Point3F( 0, 0, mZOffset));
|
||||
|
||||
GFX->multWorld(xfm);
|
||||
MatrixF xform(proj);//GFX->getProjectionMatrix());
|
||||
xform *= GFX->getViewMatrix();
|
||||
xform *= GFX->getWorldMatrix();
|
||||
|
||||
if(state->isReflectPass())
|
||||
{
|
||||
static MatrixF rotMat(EulerF(0.0, 0.0, M_PI_F));
|
||||
xform.mul(rotMat);
|
||||
rotMat.set(EulerF(M_PI_F, 0.0, 0.0));
|
||||
xform.mul(rotMat);
|
||||
}
|
||||
xform.setPosition(xform.getPosition() - Point3F(0, 0, mZOffset));
|
||||
|
||||
mShaderConsts->setSafe( mModelViewProjSC, xform );
|
||||
mShaderConsts->setSafe( mMiscSC, miscParams );
|
||||
mShaderConsts->setSafe( mSphereRadiiSC, sphereRadii );
|
||||
|
|
|
|||
|
|
@ -599,7 +599,8 @@ void SkyBox::_initMaterial()
|
|||
|
||||
// We want to disable culling and z write.
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullCW );
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( true, false );
|
||||
mMatInstance->addStateBlockDesc( desc );
|
||||
|
||||
|
|
|
|||
|
|
@ -87,9 +87,11 @@ void GFXD3D9CardProfiler::setupCardCapabilities()
|
|||
bool canDoFourStageDetailBlend = ( caps.TextureOpCaps & D3DTEXOPCAPS_SUBTRACT ) &&
|
||||
( caps.PrimitiveMiscCaps & D3DPMISCCAPS_TSSARGTEMP ) &&
|
||||
( caps.MaxTextureBlendStages > 3 );
|
||||
bool canDoIndependentMrtBitDepth = (caps.PrimitiveMiscCaps & D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS ? 1 : 0 );
|
||||
|
||||
setCapability( "lerpDetailBlend", canDoLERPDetailBlend );
|
||||
setCapability( "fourStageDetailBlend", canDoFourStageDetailBlend );
|
||||
setCapability( "independentMrtBitDepth", canDoIndependentMrtBitDepth);
|
||||
}
|
||||
|
||||
bool GFXD3D9CardProfiler::_queryCardCap(const String &query, U32 &foundResult)
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
#include "gfx/gfxDebugEvent.h"
|
||||
#include "windowManager/win32/win32Window.h"
|
||||
|
||||
#ifndef _GFXDEVICE_H_
|
||||
#include "gfx/gfxDevice.h"
|
||||
#endif
|
||||
|
||||
GFXPCD3D9TextureTarget::GFXPCD3D9TextureTarget()
|
||||
: mTargetSize( Point2I::Zero ),
|
||||
|
|
@ -451,6 +454,7 @@ void GFXPCD3D9WindowTarget::createAdditionalSwapChain()
|
|||
|
||||
void GFXPCD3D9WindowTarget::resetMode()
|
||||
{
|
||||
GFX->beginReset();
|
||||
mWindow->setSuppressReset(true);
|
||||
|
||||
if (mSwapChain)
|
||||
|
|
@ -509,6 +513,7 @@ void GFXPCD3D9WindowTarget::zombify()
|
|||
|
||||
void GFXPCD3D9WindowTarget::resurrect()
|
||||
{
|
||||
GFX->beginReset();
|
||||
if(mImplicit)
|
||||
{
|
||||
setImplicitSwapChain();
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ protected:
|
|||
/// This will allow querying to see if a device is initialized and ready to
|
||||
/// have operations performed on it.
|
||||
bool mInitialized;
|
||||
bool mReset;
|
||||
|
||||
/// This is called before this, or any other device, is deleted in the global destroy()
|
||||
/// method. It allows the device to clean up anything while everything is still valid.
|
||||
|
|
@ -326,6 +327,10 @@ public:
|
|||
/// @see endScene
|
||||
bool canCurrentlyRender() const { return mCanCurrentlyRender; }
|
||||
|
||||
bool recentlyReset(){ return mReset; }
|
||||
void beginReset(){ mReset = true; }
|
||||
void finalizeReset(){ mReset = false; }
|
||||
|
||||
void setAllowRender( bool render ) { mAllowRender = render; }
|
||||
|
||||
inline bool allowRender() const { return mAllowRender; }
|
||||
|
|
|
|||
|
|
@ -107,6 +107,14 @@ void GFXGLStateBlock::activate(const GFXGLStateBlock* oldState)
|
|||
if(STATE_CHANGE(blendOp))
|
||||
glBlendEquation(GFXGLBlendOp[mDesc.blendOp]);
|
||||
|
||||
if (mDesc.separateAlphaBlendEnable == true)
|
||||
{
|
||||
if (STATE_CHANGE(separateAlphaBlendSrc) || STATE_CHANGE(separateAlphaBlendDest))
|
||||
glBlendFuncSeparate(GFXGLBlend[mDesc.blendSrc], GFXGLBlend[mDesc.blendDest], GFXGLBlend[mDesc.separateAlphaBlendSrc], GFXGLBlend[mDesc.separateAlphaBlendDest]);
|
||||
if (STATE_CHANGE(separateAlphaBlendOp))
|
||||
glBlendEquationSeparate(GFXGLBlendOp[mDesc.blendOp], GFXGLBlendOp[mDesc.separateAlphaBlendOp]);
|
||||
}
|
||||
|
||||
// Color write masks
|
||||
if(STATE_CHANGE(colorWriteRed) || STATE_CHANGE(colorWriteBlue) || STATE_CHANGE(colorWriteGreen) || STATE_CHANGE(colorWriteAlpha))
|
||||
glColorMask(mDesc.colorWriteRed, mDesc.colorWriteBlue, mDesc.colorWriteGreen, mDesc.colorWriteAlpha);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,10 @@ void _GFXGLTextureTargetFBOImpl::applyState()
|
|||
PRESERVE_FRAMEBUFFER();
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
|
||||
|
||||
bool drawbufs[16];
|
||||
int bufsize = 0;
|
||||
for (int i = 0; i < 16; i++)
|
||||
drawbufs[i] = false;
|
||||
bool hasColor = false;
|
||||
for(int i = 0; i < GFXGL->getNumRenderTargets(); ++i)
|
||||
{
|
||||
|
|
@ -200,6 +204,20 @@ void _GFXGLTextureTargetFBOImpl::applyState()
|
|||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||
}
|
||||
|
||||
GLenum *buf = new GLenum[bufsize];
|
||||
int count = 0;
|
||||
for (int i = 0; i < bufsize; i++)
|
||||
{
|
||||
if (drawbufs[i])
|
||||
{
|
||||
buf[count] = GL_COLOR_ATTACHMENT0 + i;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
glDrawBuffers(bufsize, buf);
|
||||
|
||||
delete[] buf;
|
||||
CHECK_FRAMEBUFFER_STATUS();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ void GFXGLWindowTarget::resetMode()
|
|||
_teardownCurrentMode();
|
||||
_setupNewMode();
|
||||
}
|
||||
GFX->beginReset();
|
||||
}
|
||||
|
||||
void GFXGLWindowTarget::_onAppSignal(WindowId wnd, S32 event)
|
||||
|
|
|
|||
|
|
@ -156,8 +156,8 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
oneOverTargetSize->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " float id_NL_Att, id_specular;\r\n float3 id_lightcolor;\r\n" ) );
|
||||
meta->addStatement( new GenOp( avar( " %s(tex2D(@, @ + float2(0.0, @.y)), id_lightcolor, id_NL_Att, id_specular);\r\n",
|
||||
meta->addStatement( new GenOp( " float id_NL_Att, id_specular;\r\n vec3 id_lightcolor;\r\n" ) );
|
||||
meta->addStatement( new GenOp( avar( " %s(tex2D(@, @ + vec2(0.0, @.y)), id_lightcolor, id_NL_Att, id_specular);\r\n",
|
||||
unconditionLightInfo.c_str() ), lightInfoBuffer, uvScene, oneOverTargetSize ) );
|
||||
|
||||
meta->addStatement( new GenOp(" @ = lerp(@, id_lightcolor, 0.5);\r\n", d_lightcolor, d_lightcolor ) );
|
||||
|
|
@ -167,7 +167,7 @@ void DeferredRTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
|
||||
// This is kind of weak sauce
|
||||
if( !fd.features[MFT_VertLit] && !fd.features[MFT_ToneMap] && !fd.features[MFT_LightMap] && !fd.features[MFT_SubSurface] )
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(@, 1.0)", d_lightcolor ), Material::Mul ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "vec4(@, 1.0)", d_lightcolor ), Material::Mul ) ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ void DeferredBumpFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
meta->addStatement( new GenOp( " @.xy += @.xy * @;\r\n", bumpNorm, detailBump, detailBumpScale ) );
|
||||
}
|
||||
|
||||
// This var is read from GBufferConditionerHLSL and
|
||||
// This var is read from GBufferConditionerGLSL and
|
||||
// used in the prepass output.
|
||||
//
|
||||
// By using the 'half' type here we get a bunch of partial
|
||||
|
|
@ -533,11 +533,13 @@ void DeferredPixelSpecularGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
specPow->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *specStrength = new Var;
|
||||
specStrength->setType( "float" );
|
||||
specStrength->setName( "specularStrength" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
Var *specStrength = (Var*)LangElement::find( "specularStrength" );
|
||||
if (!specStrength)
|
||||
{
|
||||
specStrength = new Var( "specularStrength", "float" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *lightInfoSamp = (Var *)LangElement::find( "lightInfoSample" );
|
||||
Var *d_specular = (Var*)LangElement::find( "d_specular" );
|
||||
|
|
@ -555,10 +557,10 @@ void DeferredPixelSpecularGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement(new GenOp(" @ = clamp( lerp( @, @ * @, @.a), 0, 1);\r\n", d_specular, d_specular, accuSpecular, d_specular, accuPlc));
|
||||
}
|
||||
// (a^m)^n = a^(m*n)
|
||||
meta->addStatement( new GenOp( " @ = pow( abs(@), max((@ / AL_ConstantSpecularPower),1.0f)) * @;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = pow( abs(@), max((@ / AL_ConstantSpecularPower),1.0f)) * @;\r\n",
|
||||
specDecl, d_specular, specPow, specStrength ) );
|
||||
|
||||
LangElement *specMul = new GenOp( "float4( @.rgb, 0 ) * @", specCol, specular );
|
||||
LangElement *specMul = new GenOp( "vec4( @.rgb, 0 ) * @", specCol, specular );
|
||||
LangElement *final = specMul;
|
||||
|
||||
// We we have a normal map then mask the specular
|
||||
|
|
@ -682,10 +684,10 @@ void DeferredMinnaertGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *d_NL_Att = (Var*)LangElement::find( "d_NL_Att" );
|
||||
|
||||
meta->addStatement( new GenOp( avar( " float4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str() ), prepassBuffer, uvScene ) );
|
||||
meta->addStatement( new GenOp( avar( " vec4 normalDepth = %s(@, @);\r\n", unconditionPrePassMethod.c_str() ), prepassBuffer, uvScene ) );
|
||||
meta->addStatement( new GenOp( " float vDotN = dot(normalDepth.xyz, @);\r\n", wsViewVec ) );
|
||||
meta->addStatement( new GenOp( " float Minnaert = pow( @, @) * pow(vDotN, 1.0 - @);\r\n", d_NL_Att, minnaertConstant, minnaertConstant ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(Minnaert, Minnaert, Minnaert, 1.0)" ), Material::Mul ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "vec4(Minnaert, Minnaert, Minnaert, 1.0)" ), Material::Mul ) ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -713,7 +715,7 @@ void DeferredSubSurfaceGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " float subLamb = smoothstep(-@.a, 1.0, @) - smoothstep(0.0, 1.0, @);\r\n", subSurfaceParams, d_NL_Att, d_NL_Att ) );
|
||||
meta->addStatement( new GenOp( " subLamb = max(0.0, subLamb);\r\n" ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "float4(@ + (subLamb * @.rgb), 1.0)", d_lightcolor, subSurfaceParams ), Material::Mul ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( new GenOp( "vec4(@ + (subLamb * @.rgb), 1.0)", d_lightcolor, subSurfaceParams ), Material::Mul ) ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void GBufferConditionerGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
if ( fd.features[ MFT_IsTranslucentZWrite ] )
|
||||
{
|
||||
alphaVal = new Var( "outAlpha", "float" );
|
||||
meta->addStatement( new GenOp( " @ = col.a; // MFT_IsTranslucentZWrite\r\n", new DecOp( alphaVal ) ) );
|
||||
meta->addStatement( new GenOp( " @ = OUT_col1.a; // MFT_IsTranslucentZWrite\r\n", new DecOp( alphaVal ) ) );
|
||||
}
|
||||
|
||||
// If using interlaced normals, invert the normal
|
||||
|
|
@ -397,7 +397,7 @@ Var* GBufferConditionerGLSL::_unconditionInput( Var *conditionedInput, MultiLine
|
|||
// Recover depth from encoding
|
||||
if(mNormalStorageType != CartesianXYZ)
|
||||
{
|
||||
const U64 maxValPerChannel = 1 << mBitsPerChannel;
|
||||
const U64 maxValPerChannel = (U64)1 << mBitsPerChannel;
|
||||
meta->addStatement( new GenOp( " \r\n // Decode depth\r\n" ) );
|
||||
meta->addStatement( new GenOp( avar( " @.w = dot( @.zw, float2(1.0, 1.0/%llu.0));\r\n", maxValPerChannel - 1 ),
|
||||
retVar, conditionedInput ) );
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ void DeferredBumpFeatHLSL::processVert( Vector<ShaderComponent*> &componentLis
|
|||
|
||||
const bool useTexAnim = fd.features[MFT_TexAnim];
|
||||
// Make sure there are texcoords
|
||||
if( !fd.features[MFT_Parallax] && !fd.features[MFT_DiffuseMap] )
|
||||
if( !fd.features[MFT_Parallax] && !fd.features[MFT_DiffuseMap])
|
||||
{
|
||||
|
||||
getOutTexCoord( "texCoord",
|
||||
|
|
@ -532,11 +532,13 @@ void DeferredPixelSpecularHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
specPow->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *specStrength = new Var;
|
||||
specStrength->setType( "float" );
|
||||
specStrength->setName( "specularStrength" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
Var *specStrength = (Var*)LangElement::find( "specularStrength" );
|
||||
if (!specStrength)
|
||||
{
|
||||
specStrength = new Var( "specularStrength", "float" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *lightInfoSamp = (Var *)LangElement::find( "lightInfoSample" );
|
||||
Var *d_specular = (Var*)LangElement::find( "d_specular" );
|
||||
|
|
@ -556,7 +558,7 @@ void DeferredPixelSpecularHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
|
||||
// (a^m)^n = a^(m*n)
|
||||
meta->addStatement( new GenOp( " @ = pow( abs(@), max((@ / AL_ConstantSpecularPower),1.0f)) * @;\r\n",
|
||||
specDecl, d_specular, specPow, specStrength ) );
|
||||
specDecl, d_specular, specPow, specStrength));
|
||||
|
||||
LangElement *specMul = new GenOp( "float4( @.rgb, 0 ) * @", specCol, specular );
|
||||
LangElement *final = specMul;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void GBufferConditionerHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
if ( fd.features[ MFT_IsTranslucentZWrite ] )
|
||||
{
|
||||
alphaVal = new Var( "outAlpha", "float" );
|
||||
meta->addStatement( new GenOp( " @ = OUT.col.a; // MFT_IsTranslucentZWrite\r\n", new DecOp( alphaVal ) ) );
|
||||
meta->addStatement( new GenOp( " @ = OUT.col1.a; // MFT_IsTranslucentZWrite\r\n", new DecOp( alphaVal ) ) );
|
||||
}
|
||||
|
||||
// If using interlaced normals, invert the normal
|
||||
|
|
|
|||
|
|
@ -47,9 +47,16 @@ bool NamedTexTarget::registerWithName( const String &name )
|
|||
}
|
||||
|
||||
// Make sure the target name isn't empty or already taken.
|
||||
if ( name.isEmpty() || smTargets.contains( name ) )
|
||||
if ( name.isEmpty())
|
||||
{
|
||||
Con::errorf("NamedTexTarget::registerWithName( const String &name ) No name given!");
|
||||
return false;
|
||||
}
|
||||
if (smTargets.contains( name ) )
|
||||
{
|
||||
Con::errorf("NamedTexTarget::registerWithName( %s ) Already used!", name.c_str());
|
||||
return false;
|
||||
|
||||
}
|
||||
mName = name;
|
||||
mIsRegistered = true;
|
||||
smTargets.insert( mName, this );
|
||||
|
|
|
|||
|
|
@ -162,6 +162,9 @@ Material::Material()
|
|||
|
||||
mSeqFramePerSec[i] = 0.0f;
|
||||
mSeqSegSize[i] = 0.0f;
|
||||
|
||||
// Deferred Shading
|
||||
mMatInfoFlags[i] = 0.0f;
|
||||
}
|
||||
|
||||
dMemset(mCellIndex, 0, sizeof(mCellIndex));
|
||||
|
|
@ -170,6 +173,9 @@ Material::Material()
|
|||
dMemset(mNormalMapAtlas, 0, sizeof(mNormalMapAtlas));
|
||||
dMemset(mUseAnisotropic, 0, sizeof(mUseAnisotropic));
|
||||
|
||||
// Deferred Shading : Metalness
|
||||
dMemset(mUseMetalness, 0, sizeof(mUseMetalness));
|
||||
|
||||
mImposterLimits = Point4F::Zero;
|
||||
|
||||
mDoubleSided = false;
|
||||
|
|
@ -204,6 +210,9 @@ Material::Material()
|
|||
|
||||
mDirectSoundOcclusion = 1.f;
|
||||
mReverbSoundOcclusion = 1.0;
|
||||
|
||||
// Deferred Shading
|
||||
mIsSky = false;
|
||||
}
|
||||
|
||||
void Material::initPersistFields()
|
||||
|
|
@ -289,10 +298,7 @@ void Material::initPersistFields()
|
|||
|
||||
addField( "useAnisotropic", TypeBool, Offset(mUseAnisotropic, Material), MAX_STAGES,
|
||||
"Use anisotropic filtering for the textures of this stage." );
|
||||
|
||||
addField("envMap", TypeImageFilename, Offset(mEnvMapFilename, Material), MAX_STAGES,
|
||||
"The name of an environment map cube map to apply to this material." );
|
||||
|
||||
|
||||
addField("vertLit", TypeBool, Offset(mVertLit, Material), MAX_STAGES,
|
||||
"If true the vertex color is used for lighting." );
|
||||
|
||||
|
|
@ -379,9 +385,6 @@ void Material::initPersistFields()
|
|||
addProtectedField("bumpTex", TypeImageFilename, Offset(mNormalMapFilename, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see normalMap\n");
|
||||
addProtectedField("envTex", TypeImageFilename, Offset(mEnvMapFilename, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see envMap\n");
|
||||
addProtectedField("colorMultiply", TypeColorF, Offset(mDiffuse, Material),
|
||||
defaultProtectedSetNotEmptyFn, emptyStringProtectedGetFn, MAX_STAGES,
|
||||
"For backwards compatibility.\n@see diffuseColor\n");
|
||||
|
|
@ -417,6 +420,9 @@ void Material::initPersistFields()
|
|||
addField("dynamicCubemap", TypeBool, Offset(mDynamicCubemap, Material),
|
||||
"Enables the material to use the dynamic cubemap from the ShapeBase object its applied to." );
|
||||
|
||||
addField("isSky", TypeBool, Offset(mIsSky, Material),
|
||||
"Sky support. Alters draw dimensions." );
|
||||
|
||||
addGroup( "Behavioral" );
|
||||
|
||||
addField( "showFootprints", TypeBool, Offset( mShowFootprints, Material ),
|
||||
|
|
|
|||
|
|
@ -221,8 +221,6 @@ public:
|
|||
/// The strength scalar for the detail normal map.
|
||||
F32 mDetailNormalMapStrength[MAX_STAGES];
|
||||
|
||||
FileName mEnvMapFilename[MAX_STAGES];
|
||||
|
||||
/// This color is the diffuse color of the material
|
||||
/// or if it has a texture it is multiplied against
|
||||
/// the diffuse texture color.
|
||||
|
|
@ -287,12 +285,18 @@ public:
|
|||
/// If the stage should use anisotropic filtering.
|
||||
bool mUseAnisotropic[MAX_STAGES];
|
||||
|
||||
// Deferred Shading: Metalness
|
||||
bool mUseMetalness[MAX_STAGES];
|
||||
|
||||
bool mDoubleSided;
|
||||
|
||||
String mCubemapName;
|
||||
CubemapData* mCubemapData;
|
||||
bool mDynamicCubemap;
|
||||
|
||||
// Deferred Shading
|
||||
bool mIsSky;
|
||||
F32 mMatInfoFlags[MAX_STAGES];
|
||||
bool mTranslucent;
|
||||
BlendOp mTranslucentBlendOp;
|
||||
bool mTranslucentZWrite;
|
||||
|
|
|
|||
|
|
@ -455,14 +455,6 @@ void ProcessedMaterial::_setStageData()
|
|||
if(!mStages[i].getTex( MFT_SpecularMap ))
|
||||
mMaterial->logError("Failed to load specular map %s for stage %i", _getTexturePath(mMaterial->mSpecularMapFilename[i]).c_str(), i);
|
||||
}
|
||||
|
||||
// EnironmentMap
|
||||
if( mMaterial->mEnvMapFilename[i].isNotEmpty() )
|
||||
{
|
||||
mStages[i].setTex( MFT_EnvMap, _createTexture( mMaterial->mEnvMapFilename[i], &GFXDefaultStaticDiffuseProfile ) );
|
||||
if(!mStages[i].getTex( MFT_EnvMap ))
|
||||
mMaterial->logError("Failed to load environment map %s for stage %i", _getTexturePath(mMaterial->mEnvMapFilename[i]).c_str(), i);
|
||||
}
|
||||
}
|
||||
|
||||
mMaterial->mCubemapData = dynamic_cast<CubemapData*>(Sim::findObject( mMaterial->mCubemapName ));
|
||||
|
|
|
|||
|
|
@ -106,6 +106,9 @@ void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/
|
|||
for (S32 i = 0; i < Material::MAX_TEX_PER_PASS; ++i)
|
||||
mTexHandlesSC[i] = shader->getShaderConstHandle(mat->mSamplerNames[i]);
|
||||
}
|
||||
|
||||
// Deferred Shading
|
||||
mMatInfoFlagsSC = shader->getShaderConstHandle(ShaderGenVars::matInfoFlags);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
@ -208,28 +211,6 @@ bool ProcessedShaderMaterial::init( const FeatureSet &features,
|
|||
mInstancingState = new InstancingState();
|
||||
mInstancingState->setFormat( &_getRPD( 0 )->shader->mInstancingFormat, mVertexFormat );
|
||||
}
|
||||
|
||||
// Check for a RenderTexTargetBin assignment
|
||||
// *IMPORTANT NOTE*
|
||||
// This is a temporary solution for getting diffuse mapping working with tex targets for standard materials
|
||||
// It should be removed once this is done properly, at that time the sAllowTextureTargetAssignment should also be removed
|
||||
// from Material (it is necessary for catching shadow maps/post effect this shouldn't be applied to)
|
||||
if (Material::sAllowTextureTargetAssignment)
|
||||
if (mMaterial && mMaterial->mDiffuseMapFilename[0].isNotEmpty() && mMaterial->mDiffuseMapFilename[0].substr( 0, 1 ).equal("#"))
|
||||
{
|
||||
String texTargetBufferName = mMaterial->mDiffuseMapFilename[0].substr(1, mMaterial->mDiffuseMapFilename[0].length() - 1);
|
||||
NamedTexTarget *texTarget = NamedTexTarget::find( texTargetBufferName );
|
||||
|
||||
RenderPassData* rpd = getPass(0);
|
||||
|
||||
if (rpd)
|
||||
{
|
||||
rpd->mTexSlot[0].texTarget = texTarget;
|
||||
rpd->mTexType[0] = Material::TexTarget;
|
||||
rpd->mSamplerNames[0] = "diffuseMap";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -353,11 +334,18 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.addFeature( MFT_VertLit );
|
||||
|
||||
// cubemaps only available on stage 0 for now - bramage
|
||||
if ( stageNum < 1 &&
|
||||
if ( stageNum < 1 && mMaterial->isTranslucent() &&
|
||||
( ( mMaterial->mCubemapData && mMaterial->mCubemapData->mCubemap ) ||
|
||||
mMaterial->mDynamicCubemap ) )
|
||||
fd.features.addFeature( MFT_CubeMap );
|
||||
{
|
||||
fd.features.addFeature( MFT_CubeMap );
|
||||
}
|
||||
|
||||
if (mMaterial->mIsSky)
|
||||
{
|
||||
fd.features.addFeature(MFT_CubeMap);
|
||||
fd.features.addFeature(MFT_SkyBox);
|
||||
}
|
||||
fd.features.addFeature( MFT_Visibility );
|
||||
|
||||
if ( lastStage &&
|
||||
|
|
@ -428,7 +416,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
|
||||
if ( mMaterial->mAccuEnabled[stageNum] )
|
||||
{
|
||||
fd.features.addFeature( MFT_AccuMap );
|
||||
mHasAccumulation = true;
|
||||
}
|
||||
|
||||
|
|
@ -441,19 +428,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features.removeFeature( MFT_AccuMap );
|
||||
mHasAccumulation = false;
|
||||
}
|
||||
|
||||
// if we still have the AccuMap feature, we add all accu constant features
|
||||
if ( fd.features[ MFT_AccuMap ] ) {
|
||||
// add the dependencies of the accu map
|
||||
fd.features.addFeature( MFT_AccuScale );
|
||||
fd.features.addFeature( MFT_AccuDirection );
|
||||
fd.features.addFeature( MFT_AccuStrength );
|
||||
fd.features.addFeature( MFT_AccuCoverage );
|
||||
fd.features.addFeature( MFT_AccuSpecular );
|
||||
// now remove some features that are not compatible with this
|
||||
fd.features.removeFeature( MFT_UseInstancing );
|
||||
}
|
||||
|
||||
|
||||
// Without a base texture use the diffuse color
|
||||
// feature to ensure some sort of output.
|
||||
if (!fd.features[MFT_DiffuseMap])
|
||||
|
|
@ -1175,7 +1150,12 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
|
|||
0.0f, 0.0f ); // TODO: Wrap mode flags?
|
||||
shaderConsts->setSafe(handles->mBumpAtlasTileSC, atlasTileParams);
|
||||
}
|
||||
|
||||
|
||||
// Deferred Shading: Determine Material Info Flags
|
||||
S32 matInfoFlags =
|
||||
(mMaterial->mEmissive[stageNum] ? 1 : 0);
|
||||
mMaterial->mMatInfoFlags[stageNum] = matInfoFlags / 255.0f;
|
||||
shaderConsts->setSafe(handles->mMatInfoFlagsSC, mMaterial->mMatInfoFlags[stageNum]);
|
||||
if( handles->mAccuScaleSC->isValid() )
|
||||
shaderConsts->set( handles->mAccuScaleSC, mMaterial->mAccuScale[stageNum] );
|
||||
if( handles->mAccuDirectionSC->isValid() )
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ public:
|
|||
GFXShaderConstHandle *mImposterUVs;
|
||||
GFXShaderConstHandle *mImposterLimits;
|
||||
|
||||
// Deferred Shading : Material Info Flags
|
||||
GFXShaderConstHandle* mMatInfoFlagsSC;
|
||||
|
||||
GFXShaderConstHandle* mTexHandlesSC[Material::MAX_TEX_PER_PASS];
|
||||
GFXShaderConstHandle* mRTParamsSC[TEXTURE_STAGE_COUNT];
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ RenderBinManager::RenderBinManager( const RenderInstType& ritype, F32 renderOrde
|
|||
mRenderInstType( ritype ),
|
||||
mRenderOrder( renderOrder ),
|
||||
mProcessAddOrder( processAddOrder ),
|
||||
mRenderPass( NULL )
|
||||
mRenderPass( NULL ),
|
||||
mBasicOnly ( false )
|
||||
{
|
||||
VECTOR_SET_ASSOCIATION( mElementList );
|
||||
mElementList.reserve( 2048 );
|
||||
|
|
@ -60,6 +61,9 @@ void RenderBinManager::initPersistFields()
|
|||
addField("processAddOrder", TypeF32, Offset(mProcessAddOrder, RenderBinManager),
|
||||
"Defines the order for adding instances in relation to other bins." );
|
||||
|
||||
addField( "basicOnly", TypeBool, Offset(mBasicOnly, RenderBinManager),
|
||||
"Limites the render bin to basic lighting only." );
|
||||
|
||||
Parent::initPersistFields();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ protected:
|
|||
/// RenderInst if available, otherwise, return NULL.
|
||||
inline BaseMatInstance* getMaterial( RenderInst *inst ) const;
|
||||
|
||||
// Limits bin to rendering in basic lighting only.
|
||||
bool mBasicOnly;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -160,6 +162,7 @@ inline BaseMatInstance* RenderBinManager::getMaterial( RenderInst *inst ) const
|
|||
{
|
||||
if ( inst->type == RenderPassManager::RIT_Mesh ||
|
||||
inst->type == RenderPassManager::RIT_Decal ||
|
||||
inst->type == RenderPassManager::RIT_DecalRoad ||
|
||||
inst->type == RenderPassManager::RIT_Translucent )
|
||||
return static_cast<MeshRenderInst*>(inst)->matInst;
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ void RenderGlowMgr::GlowMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
|
|||
// the glow materials.
|
||||
fd.features.removeFeature( MFT_Fog );
|
||||
fd.features.removeFeature( MFT_HDROut );
|
||||
fd.features.addFeature( MFT_Imposter );
|
||||
}
|
||||
|
||||
RenderGlowMgr::RenderGlowMgr()
|
||||
|
|
@ -89,6 +90,7 @@ RenderGlowMgr::RenderGlowMgr()
|
|||
Point2I( 512, 512 ) )
|
||||
{
|
||||
notifyType( RenderPassManager::RIT_Decal );
|
||||
notifyType( RenderPassManager::RIT_DecalRoad );
|
||||
notifyType( RenderPassManager::RIT_Translucent );
|
||||
notifyType( RenderPassManager::RIT_Particle );
|
||||
|
||||
|
|
|
|||
|
|
@ -144,6 +144,14 @@ void RenderMeshMgr::render(SceneRenderState * state)
|
|||
if( !mat )
|
||||
mat = MATMGR->getWarningMatInstance();
|
||||
|
||||
// Check if bin is disabled in advanced lighting.
|
||||
// Allow forward rendering pass on custom materials.
|
||||
|
||||
if ( ( MATMGR->getPrePassEnabled() && mBasicOnly && !mat->isCustomMaterial() ) )
|
||||
{
|
||||
j++;
|
||||
continue;
|
||||
}
|
||||
|
||||
U32 matListEnd = j;
|
||||
lastMiscTex = sgData.miscTex;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include "renderObjectMgr.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "scene/sceneObject.h"
|
||||
#include "materials/materialManager.h"
|
||||
#include "scene/sceneRenderState.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(RenderObjectMgr);
|
||||
|
||||
|
|
@ -66,6 +68,10 @@ void RenderObjectMgr::render( SceneRenderState *state )
|
|||
if(!mElementList.size())
|
||||
return;
|
||||
|
||||
// Check if bin is disabled in advanced lighting.
|
||||
if ( MATMGR->getPrePassEnabled() && mBasicOnly )
|
||||
return;
|
||||
|
||||
for( U32 i=0; i<mElementList.size(); i++ )
|
||||
{
|
||||
ObjectRenderInst *ri = static_cast<ObjectRenderInst*>(mElementList[i].inst);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const RenderInstType RenderPassManager::RIT_Terrain("Terrain");
|
|||
const RenderInstType RenderPassManager::RIT_Object("Object");
|
||||
const RenderInstType RenderPassManager::RIT_ObjectTranslucent("ObjectTranslucent");
|
||||
const RenderInstType RenderPassManager::RIT_Decal("Decal");
|
||||
const RenderInstType RenderPassManager::RIT_DecalRoad("DecalRoad");
|
||||
const RenderInstType RenderPassManager::RIT_Water("Water");
|
||||
const RenderInstType RenderPassManager::RIT_Foliage("Foliage");
|
||||
const RenderInstType RenderPassManager::RIT_VolumetricFog("ObjectVolumetricFog");
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public:
|
|||
static const RenderInstType RIT_Object; // objects that do their own rendering
|
||||
static const RenderInstType RIT_ObjectTranslucent;// self rendering; but sorted with static const RenderInstType RIT_Translucent
|
||||
static const RenderInstType RIT_Decal;
|
||||
static const RenderInstType RIT_DecalRoad;
|
||||
static const RenderInstType RIT_Water;
|
||||
static const RenderInstType RIT_Foliage;
|
||||
static const RenderInstType RIT_VolumetricFog;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#include "terrain/terrCell.h"
|
||||
#include "terrain/terrCellMaterial.h"
|
||||
#include "math/util/matrixSet.h"
|
||||
#include "materials/materialManager.h"
|
||||
|
||||
bool RenderTerrainMgr::smRenderWireframe = false;
|
||||
|
||||
|
|
@ -117,6 +118,10 @@ void RenderTerrainMgr::render( SceneRenderState *state )
|
|||
if ( mInstVector.empty() )
|
||||
return;
|
||||
|
||||
// Check if bin is disabled in advanced lighting.
|
||||
if ( MATMGR->getPrePassEnabled() && mBasicOnly )
|
||||
return;
|
||||
|
||||
PROFILE_SCOPE( RenderTerrainMgr_Render );
|
||||
|
||||
GFXTransformSaver saver;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ MODULE_END;
|
|||
|
||||
GFX_ImplementTextureProfile( ReflectRenderTargetProfile,
|
||||
GFXTextureProfile::DiffuseMap,
|
||||
GFXTextureProfile::PreserveSize | GFXTextureProfile::NoMipmap | GFXTextureProfile::RenderTarget | GFXTextureProfile::Pooled,
|
||||
GFXTextureProfile::PreserveSize | GFXTextureProfile::RenderTarget | GFXTextureProfile::Pooled,
|
||||
GFXTextureProfile::NONE );
|
||||
|
||||
GFX_ImplementTextureProfile( RefractTextureProfile,
|
||||
|
|
|
|||
|
|
@ -89,8 +89,6 @@ void ReflectionMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
|
|||
return;
|
||||
}
|
||||
|
||||
// Forward shading on materials in reflections
|
||||
fd.features.addFeature( MFT_ForwardShading );
|
||||
fd.features.addFeature( MFT_Fog );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -419,7 +419,6 @@ void CubeReflector::updateFace( const ReflectParams ¶ms, U32 faceidx )
|
|||
|
||||
reflectRenderState.getMaterialDelegate().bind( REFLECTMGR, &ReflectionManager::getReflectionMaterial );
|
||||
reflectRenderState.setDiffuseCameraTransform( params.query->cameraMatrix );
|
||||
reflectRenderState.disableAdvancedLightingBins(true);
|
||||
|
||||
// render scene
|
||||
LIGHTMGR->registerGlobalLights( &reflectRenderState.getCullingFrustum(), false );
|
||||
|
|
@ -633,7 +632,6 @@ void PlaneReflector::updateReflection( const ReflectParams ¶ms )
|
|||
renderStateLeft.setSceneRenderField(0);
|
||||
renderStateLeft.getMaterialDelegate().bind( REFLECTMGR, &ReflectionManager::getReflectionMaterial );
|
||||
renderStateLeft.setDiffuseCameraTransform( params.query->eyeTransforms[0] );
|
||||
renderStateLeft.disableAdvancedLightingBins(true);
|
||||
|
||||
gClientSceneGraph->renderSceneNoLights( &renderStateLeft, objTypeFlag );
|
||||
|
||||
|
|
@ -672,7 +670,6 @@ void PlaneReflector::updateReflection( const ReflectParams ¶ms )
|
|||
|
||||
reflectRenderState.getMaterialDelegate().bind( REFLECTMGR, &ReflectionManager::getReflectionMaterial );
|
||||
reflectRenderState.setDiffuseCameraTransform( params.query->cameraMatrix );
|
||||
reflectRenderState.disableAdvancedLightingBins(true);
|
||||
|
||||
gClientSceneGraph->renderSceneNoLights( &reflectRenderState, objTypeFlag );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
@ -144,8 +144,6 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// get the accu pixel color
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
@ -141,8 +141,6 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// get the accu pixel color
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
|
|
|||
|
|
@ -42,10 +42,11 @@ uniform vec3 g_fBlueShiftColor;
|
|||
uniform float g_fBloomScale;
|
||||
|
||||
uniform float g_fOneOverGamma;
|
||||
uniform float Brightness;
|
||||
uniform float Contrast;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 _sample = hdrDecode( texture( sceneTex, IN_uv0 ) );
|
||||
|
|
@ -94,5 +95,11 @@ void main()
|
|||
// Apply gamma correction
|
||||
_sample.rgb = pow( abs(_sample.rgb), vec3(g_fOneOverGamma) );
|
||||
|
||||
// Apply contrast
|
||||
_sample.rgb = ((_sample.rgb - 0.5f) * Contrast) + 0.5f;
|
||||
|
||||
// Apply brightness
|
||||
_sample.rgb += Brightness;
|
||||
|
||||
OUT_col = _sample;
|
||||
}
|
||||
|
|
|
|||
49
Templates/Full/game/art/prefabs/fire.prefab
Normal file
49
Templates/Full/game/art/prefabs/fire.prefab
Normal 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 ---
|
||||
|
|
@ -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";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,4 +34,5 @@ singleton Material( DesertSkyMat )
|
|||
{
|
||||
cubemap = DesertSkyCubemap;
|
||||
materialTag0 = "Skies";
|
||||
isSky = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ singleton ShaderData( PFX_CausticsShader )
|
|||
singleton PostEffect( CausticsPFX )
|
||||
{
|
||||
isEnabled = false;
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderTime = "PFXAfterDiffuse";
|
||||
renderBin = "ObjTranslucentBin";
|
||||
//renderPriority = 0.1;
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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 );
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ float4 main( Conn In ) : COLOR0
|
|||
Out = lerp( color, nightSkyColor, nightInterpAndExposure.y );
|
||||
|
||||
Out.a = 1;
|
||||
|
||||
Out = saturate(Out);
|
||||
return hdrEncode( Out );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue