mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
commit
908be4818f
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,190 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "lighting/advanced/glsl/deferredShadingFeaturesGLSL.h"
|
||||
|
||||
#include "lighting/advanced/advancedLightBinManager.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/conditionerFeature.h"
|
||||
#include "renderInstance/renderPrePassMgr.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// Deferred Shading Features
|
||||
//****************************************************************************
|
||||
|
||||
// Specular Map -> Blue of Material Buffer ( greyscaled )
|
||||
// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer.
|
||||
void DeferredSpecMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// Get the texture coord.
|
||||
Var *texCoord = getInTexCoord( "texCoord", "vec2", true, componentList );
|
||||
|
||||
// search for color var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
MultiLine * meta = new MultiLine;
|
||||
if ( !material )
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType( "vec4" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
// create texture var
|
||||
Var *specularMap = new Var;
|
||||
specularMap->setType( "sampler2D" );
|
||||
specularMap->setName( "specularMap" );
|
||||
specularMap->uniform = true;
|
||||
specularMap->sampler = true;
|
||||
specularMap->constNum = Var::getTexUnitNum();
|
||||
LangElement *texOp = new GenOp( "tex2D(@, @)", specularMap, texCoord );
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.b = dot(tex2D(@, @).rgb, vec3(0.3, 0.59, 0.11));\r\n", material, specularMap, texCoord));
|
||||
meta->addStatement(new GenOp(" @.a = tex2D(@, @).a;\r\n", material, specularMap, texCoord));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DeferredSpecMapGLSL::getResources( const MaterialFeatureData &fd )
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
res.numTexReg = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void DeferredSpecMapGLSL::setTexData( Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex )
|
||||
{
|
||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
||||
if ( tex )
|
||||
{
|
||||
passData.mTexType[ texIndex ] = Material::Standard;
|
||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||
}
|
||||
}
|
||||
|
||||
void DeferredSpecMapGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
MultiLine *meta = new MultiLine;
|
||||
getOutTexCoord( "texCoord",
|
||||
"vec2",
|
||||
true,
|
||||
fd.features[MFT_TexAnim],
|
||||
meta,
|
||||
componentList );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
// Material Info Flags -> Red ( Flags ) of Material Info Buffer.
|
||||
void DeferredMatInfoFlagsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "vec4" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
Var *matInfoFlags = new Var;
|
||||
matInfoFlags->setType( "float" );
|
||||
matInfoFlags->setName( "matInfoFlags" );
|
||||
matInfoFlags->uniform = true;
|
||||
matInfoFlags->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
meta->addStatement(output = new GenOp(" @.r = @;\r\n", material, matInfoFlags));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
// Spec Strength -> Blue Channel of Material Info Buffer.
|
||||
// Spec Power -> Alpha Channel ( of Material Info Buffer.
|
||||
void DeferredSpecVarsGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "vec4" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
Var *specStrength = new Var;
|
||||
specStrength->setType( "float" );
|
||||
specStrength->setName( "specularStrength" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *specPower = new Var;
|
||||
specPower->setType("float");
|
||||
specPower->setName("specularPower");
|
||||
specPower->uniform = true;
|
||||
specPower->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.b = @/128;\r\n", material, specStrength));
|
||||
meta->addStatement(new GenOp(" @.a = @/5;\r\n", material, specPower));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
// Black -> Blue and Alpha of Color Buffer (representing no specular)
|
||||
void DeferredEmptySpecGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "vec4" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.ba = vec2(0.0);\r\n", material));
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _DEFERREDSHADINGGLSL_H_
|
||||
#define _DEFERREDSHADINGGLSL_H_
|
||||
|
||||
#include "shaderGen/GLSL/shaderFeatureGLSL.h"
|
||||
#include "shaderGen/GLSL/bumpGLSL.h"
|
||||
#include "shaderGen/GLSL/pixSpecularGLSL.h"
|
||||
|
||||
// Specular Outputs
|
||||
class DeferredSpecMapGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Specular Map"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
// Sets textures and texture flags for current pass
|
||||
virtual void setTexData( Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex );
|
||||
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
|
||||
class DeferredMatInfoFlagsGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Mat Info Flags"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
class DeferredSpecVarsGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
|
||||
class DeferredEmptySpecGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Empty Specular"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,187 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h"
|
||||
|
||||
#include "lighting/advanced/advancedLightBinManager.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
#include "shaderGen/conditionerFeature.h"
|
||||
#include "renderInstance/renderPrePassMgr.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// Deferred Shading Features
|
||||
//****************************************************************************
|
||||
|
||||
// Specular Map -> Blue of Material Buffer ( greyscaled )
|
||||
// Gloss Map (Alpha Channel of Specular Map) -> Alpha ( Spec Power ) of Material Info Buffer.
|
||||
void DeferredSpecMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// Get the texture coord.
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float2", true, componentList );
|
||||
|
||||
// search for color var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
MultiLine * meta = new MultiLine;
|
||||
if ( !material )
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
}
|
||||
|
||||
// create texture var
|
||||
Var *specularMap = new Var;
|
||||
specularMap->setType( "sampler2D" );
|
||||
specularMap->setName( "specularMap" );
|
||||
specularMap->uniform = true;
|
||||
specularMap->sampler = true;
|
||||
specularMap->constNum = Var::getTexUnitNum();
|
||||
LangElement *texOp = new GenOp( "tex2D(@, @)", specularMap, texCoord );
|
||||
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.b = dot(tex2D(@, @).rgb, float3(0.3, 0.59, 0.11));\r\n", material, specularMap, texCoord));
|
||||
meta->addStatement(new GenOp(" @.a = tex2D(@, @).a;\r\n", material, specularMap, texCoord));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DeferredSpecMapHLSL::getResources( const MaterialFeatureData &fd )
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
res.numTexReg = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void DeferredSpecMapHLSL::setTexData( Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex )
|
||||
{
|
||||
GFXTextureObject *tex = stageDat.getTex( MFT_SpecularMap );
|
||||
if ( tex )
|
||||
{
|
||||
passData.mTexType[ texIndex ] = Material::Standard;
|
||||
passData.mSamplerNames[ texIndex ] = "specularMap";
|
||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||
}
|
||||
}
|
||||
|
||||
void DeferredSpecMapHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
MultiLine *meta = new MultiLine;
|
||||
getOutTexCoord( "texCoord",
|
||||
"float2",
|
||||
true,
|
||||
fd.features[MFT_TexAnim],
|
||||
meta,
|
||||
componentList );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
// Material Info Flags -> Red ( Flags ) of Material Info Buffer.
|
||||
void DeferredMatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
}
|
||||
|
||||
Var *matInfoFlags = new Var;
|
||||
matInfoFlags->setType( "float" );
|
||||
matInfoFlags->setName( "matInfoFlags" );
|
||||
matInfoFlags->uniform = true;
|
||||
matInfoFlags->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
output = new GenOp( " @.r = @;\r\n", material, matInfoFlags );
|
||||
}
|
||||
|
||||
// Spec Strength -> Blue Channel of Material Info Buffer.
|
||||
// Spec Power -> Alpha Channel ( of Material Info Buffer.
|
||||
void DeferredSpecVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
}
|
||||
|
||||
Var *specStrength = new Var;
|
||||
specStrength->setType( "float" );
|
||||
specStrength->setName( "specularStrength" );
|
||||
specStrength->uniform = true;
|
||||
specStrength->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *specPower = new Var;
|
||||
specPower->setType( "float" );
|
||||
specPower->setName( "specularPower" );
|
||||
specPower->uniform = true;
|
||||
specPower->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.b = @/128;\r\n", material, specStrength));
|
||||
meta->addStatement(new GenOp(" @.a = @/5;\r\n", material, specPower));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
// Black -> Blue and Alpha of matinfo Buffer (representing no specular), White->G (representing No AO)
|
||||
void DeferredEmptySpecHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
if (!material)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("fragout");
|
||||
material->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.ba = 0.0;\r\n", material));
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _DEFERREDSHADINGHLSL_H_
|
||||
#define _DEFERREDSHADINGHLSL_H_
|
||||
|
||||
#include "shaderGen/HLSL/shaderFeatureHLSL.h"
|
||||
#include "shaderGen/HLSL/bumpHLSL.h"
|
||||
#include "shaderGen/HLSL/pixSpecularHLSL.h"
|
||||
|
||||
// Specular Outputs
|
||||
class DeferredSpecMapHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Specular Map"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
// Sets textures and texture flags for current pass
|
||||
virtual void setTexData( Material::StageData &stageDat,
|
||||
const MaterialFeatureData &fd,
|
||||
RenderPassData &passData,
|
||||
U32 &texIndex );
|
||||
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
|
||||
class DeferredMatInfoFlagsHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Mat Info Flags"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
class DeferredSpecVarsHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Specular Explicit Numbers"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
class DeferredEmptySpecHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Empty Specular"; }
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -56,10 +56,9 @@ ImplementFeatureType( MFT_LightMap, MFG_Lighting, 4.0f, true );
|
|||
ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true );
|
||||
ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false );
|
||||
ImplementFeatureType( MFT_VertLit, MFG_Lighting, 7.0f, true );
|
||||
ImplementFeatureType( MFT_EnvMap, MFG_Lighting, 8.0f, true );
|
||||
ImplementFeatureType( MFT_CubeMap, MFG_Lighting, 9.0f, true );
|
||||
ImplementFeatureType( MFT_PixSpecular, MFG_Lighting, 10.0f, true );
|
||||
ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 12.0f, true );
|
||||
ImplementFeatureType( MFT_PixSpecular, MFG_Lighting, 9.0f, true );
|
||||
ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 10.0f, true );
|
||||
ImplementFeatureType( MFT_CubeMap, MFG_Lighting, 11.0f, true );
|
||||
|
||||
ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true );
|
||||
ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true );
|
||||
|
|
@ -85,6 +84,8 @@ ImplementFeatureType( MFT_NormalsOut, MFG_PreLighting, 1.0f, false );
|
|||
|
||||
ImplementFeatureType( MFT_LightbufferMRT, MFG_PreLighting, 1.0f, false );
|
||||
ImplementFeatureType( MFT_RenderTarget1_Zero, MFG_PreTexture, 1.0f, false );
|
||||
ImplementFeatureType( MFT_RenderTarget2_Zero, MFG_PreTexture, 1.0f, false );
|
||||
ImplementFeatureType( MFT_RenderTarget3_Zero, MFG_PreTexture, 1.0f, false );
|
||||
|
||||
ImplementFeatureType( MFT_Foliage, MFG_PreTransform, 1.0f, false );
|
||||
|
||||
|
|
@ -92,4 +93,13 @@ ImplementFeatureType( MFT_ParticleNormal, MFG_PreTransform, 2.0f, false );
|
|||
|
||||
ImplementFeatureType( MFT_ForwardShading, U32(-1), -1, true );
|
||||
|
||||
ImplementFeatureType( MFT_ImposterVert, MFG_PreTransform, 1.0, false );
|
||||
ImplementFeatureType( MFT_ImposterVert, MFG_PreTransform, 1.0, false );
|
||||
|
||||
// Deferred Shading
|
||||
ImplementFeatureType( MFT_isDeferred, U32(-1), -1, true );
|
||||
ImplementFeatureType( MFT_SkyBox, MFG_Transform, 1.0f, true );
|
||||
ImplementFeatureType( MFT_DeferredEmptySpec, MFG_Texture, 8.01f, false );
|
||||
|
||||
ImplementFeatureType( MFT_DeferredSpecMap, MFG_Texture, 8.2f, false );
|
||||
ImplementFeatureType( MFT_DeferredSpecVars, MFG_Texture, 8.5f, false );
|
||||
ImplementFeatureType( MFT_DeferredMatInfoFlags, MFG_Texture, 8.7f, false );
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ DeclareFeatureType( MFT_ToneMap );
|
|||
DeclareFeatureType( MFT_VertLit );
|
||||
DeclareFeatureType( MFT_VertLitTone );
|
||||
|
||||
DeclareFeatureType( MFT_EnvMap );
|
||||
DeclareFeatureType( MFT_CubeMap );
|
||||
DeclareFeatureType( MFT_PixSpecular );
|
||||
DeclareFeatureType( MFT_SpecularMap );
|
||||
|
|
@ -158,8 +157,10 @@ DeclareFeatureType( MFT_InterlacedPrePass );
|
|||
/// to the second render-target
|
||||
DeclareFeatureType( MFT_LightbufferMRT );
|
||||
|
||||
/// This feature outputs black to RenderTarget1
|
||||
/// This feature outputs black to RenderTarget3
|
||||
DeclareFeatureType( MFT_RenderTarget1_Zero );
|
||||
DeclareFeatureType( MFT_RenderTarget2_Zero );
|
||||
DeclareFeatureType( MFT_RenderTarget3_Zero );
|
||||
|
||||
DeclareFeatureType( MFT_Foliage );
|
||||
|
||||
|
|
@ -179,4 +180,11 @@ DeclareFeatureType( MFT_ForwardShading );
|
|||
DeclareFeatureType( MFT_ImposterVert );
|
||||
|
||||
|
||||
// Deferred Shading
|
||||
DeclareFeatureType( MFT_isDeferred );
|
||||
DeclareFeatureType( MFT_SkyBox );
|
||||
DeclareFeatureType( MFT_DeferredSpecMap );
|
||||
DeclareFeatureType( MFT_DeferredSpecVars );
|
||||
DeclareFeatureType( MFT_DeferredMatInfoFlags );
|
||||
DeclareFeatureType( MFT_DeferredEmptySpec );
|
||||
#endif // _MATERIALFEATURETYPES_H_
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "scene/sceneRenderState.h"
|
||||
#include "gfx/gfxStringEnumTranslate.h"
|
||||
#include "gfx/gfxDebugEvent.h"
|
||||
#include "gfx/gfxCardProfile.h"
|
||||
#include "materials/customMaterialDefinition.h"
|
||||
#include "lighting/advanced/advancedLightManager.h"
|
||||
#include "lighting/advanced/advancedLightBinManager.h"
|
||||
|
|
@ -44,10 +45,17 @@
|
|||
#include "terrain/terrCellMaterial.h"
|
||||
#include "math/mathUtils.h"
|
||||
#include "math/util/matrixSet.h"
|
||||
#include "gfx/gfxTextureManager.h"
|
||||
#include "gfx/primBuilder.h"
|
||||
#include "gfx/gfxDrawUtil.h"
|
||||
#include "materials/shaderData.h"
|
||||
#include "gfx/sim/cubemapData.h"
|
||||
|
||||
const MatInstanceHookType PrePassMatInstanceHook::Type( "PrePass" );
|
||||
const String RenderPrePassMgr::BufferName("prepass");
|
||||
const RenderInstType RenderPrePassMgr::RIT_PrePass("PrePass");
|
||||
const String RenderPrePassMgr::ColorBufferName("color");
|
||||
const String RenderPrePassMgr::MatInfoBufferName("matinfo");
|
||||
|
||||
IMPLEMENT_CONOBJECT(RenderPrePassMgr);
|
||||
|
||||
|
|
@ -79,6 +87,7 @@ RenderPrePassMgr::RenderPrePassMgr( bool gatherDepth,
|
|||
mPrePassMatInstance( NULL )
|
||||
{
|
||||
notifyType( RenderPassManager::RIT_Decal );
|
||||
notifyType( RenderPassManager::RIT_DecalRoad );
|
||||
notifyType( RenderPassManager::RIT_Mesh );
|
||||
notifyType( RenderPassManager::RIT_Terrain );
|
||||
notifyType( RenderPassManager::RIT_Object );
|
||||
|
|
@ -90,6 +99,10 @@ RenderPrePassMgr::RenderPrePassMgr( bool gatherDepth,
|
|||
GFXShader::addGlobalMacro( "TORQUE_LINEAR_DEPTH" );
|
||||
|
||||
mNamedTarget.registerWithName( BufferName );
|
||||
mColorTarget.registerWithName( ColorBufferName );
|
||||
mMatInfoTarget.registerWithName( MatInfoBufferName );
|
||||
|
||||
mClearGBufferShader = NULL;
|
||||
|
||||
_registerFeatures();
|
||||
}
|
||||
|
|
@ -98,6 +111,8 @@ RenderPrePassMgr::~RenderPrePassMgr()
|
|||
{
|
||||
GFXShader::removeGlobalMacro( "TORQUE_LINEAR_DEPTH" );
|
||||
|
||||
mColorTarget.release();
|
||||
mMatInfoTarget.release();
|
||||
_unregisterFeatures();
|
||||
SAFE_DELETE( mPrePassMatInstance );
|
||||
}
|
||||
|
|
@ -119,6 +134,8 @@ bool RenderPrePassMgr::setTargetSize(const Point2I &newTargetSize)
|
|||
{
|
||||
bool ret = Parent::setTargetSize( newTargetSize );
|
||||
mNamedTarget.setViewport( GFX->getViewport() );
|
||||
mColorTarget.setViewport( GFX->getViewport() );
|
||||
mMatInfoTarget.setViewport( GFX->getViewport() );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -135,6 +152,40 @@ bool RenderPrePassMgr::_updateTargets()
|
|||
// reload materials, the conditioner needs to alter the generated shaders
|
||||
}
|
||||
|
||||
GFXFormat colorFormat = mTargetFormat;
|
||||
bool independentMrtBitDepth = GFX->getCardProfiler()->queryProfile("independentMrtBitDepth", false);
|
||||
//If independent bit depth on a MRT is supported than just use 8bit channels for the albedo color.
|
||||
if(independentMrtBitDepth)
|
||||
colorFormat = GFXFormatR8G8B8A8;
|
||||
|
||||
// andrewmac: Deferred Shading Color Buffer
|
||||
if (mColorTex.getFormat() != colorFormat || mColorTex.getWidthHeight() != mTargetSize || GFX->recentlyReset())
|
||||
{
|
||||
mColorTarget.release();
|
||||
mColorTex.set(mTargetSize.x, mTargetSize.y, colorFormat,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - (line %d)", __FUNCTION__, __LINE__),
|
||||
1, GFXTextureManager::AA_MATCH_BACKBUFFER);
|
||||
mColorTarget.setTexture(mColorTex);
|
||||
|
||||
for (U32 i = 0; i < mTargetChainLength; i++)
|
||||
mTargetChain[i]->attachTexture(GFXTextureTarget::Color1, mColorTarget.getTexture());
|
||||
}
|
||||
|
||||
// andrewmac: Deferred Shading Material Info Buffer
|
||||
if (mMatInfoTex.getFormat() != colorFormat || mMatInfoTex.getWidthHeight() != mTargetSize || GFX->recentlyReset())
|
||||
{
|
||||
mMatInfoTarget.release();
|
||||
mMatInfoTex.set(mTargetSize.x, mTargetSize.y, colorFormat,
|
||||
&GFXDefaultRenderTargetProfile, avar("%s() - (line %d)", __FUNCTION__, __LINE__),
|
||||
1, GFXTextureManager::AA_MATCH_BACKBUFFER);
|
||||
mMatInfoTarget.setTexture(mMatInfoTex);
|
||||
|
||||
for (U32 i = 0; i < mTargetChainLength; i++)
|
||||
mTargetChain[i]->attachTexture(GFXTextureTarget::Color2, mMatInfoTarget.getTexture());
|
||||
}
|
||||
|
||||
GFX->finalizeReset();
|
||||
|
||||
// Attach the light info buffer as a second render target, if there is
|
||||
// lightmapped geometry in the scene.
|
||||
AdvancedLightBinManager *lightBin;
|
||||
|
|
@ -154,11 +205,13 @@ bool RenderPrePassMgr::_updateTargets()
|
|||
for ( U32 i = 0; i < mTargetChainLength; i++ )
|
||||
{
|
||||
GFXTexHandle lightInfoTex = lightBin->getTargetTexture(0, i);
|
||||
mTargetChain[i]->attachTexture(GFXTextureTarget::Color1, lightInfoTex);
|
||||
mTargetChain[i]->attachTexture(GFXTextureTarget::Color3, lightInfoTex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_initShaders();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -191,7 +244,7 @@ void RenderPrePassMgr::addElement( RenderInst *inst )
|
|||
return;
|
||||
|
||||
// First what type of render instance is it?
|
||||
const bool isDecalMeshInst = inst->type == RenderPassManager::RIT_Decal;
|
||||
const bool isDecalMeshInst = ((inst->type == RenderPassManager::RIT_Decal)||(inst->type == RenderPassManager::RIT_DecalRoad));
|
||||
|
||||
const bool isMeshInst = inst->type == RenderPassManager::RIT_Mesh;
|
||||
|
||||
|
|
@ -280,9 +333,8 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
|||
// Tell the superclass we're about to render
|
||||
const bool isRenderingToTarget = _onPreRender(state);
|
||||
|
||||
// Clear all the buffers to white so that the
|
||||
// default depth is to the far plane.
|
||||
GFX->clear( GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI::WHITE, 1.0f, 0);
|
||||
// Clear all z-buffer, and g-buffer.
|
||||
clearBuffers();
|
||||
|
||||
// Restore transforms
|
||||
MatrixSet &matrixSet = getRenderPass()->getMatrixSet();
|
||||
|
|
@ -329,7 +381,13 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
|||
GFX->drawPrimitive( ri->prim );
|
||||
}
|
||||
|
||||
|
||||
// init loop data
|
||||
GFXTextureObject *lastLM = NULL;
|
||||
GFXCubemap *lastCubemap = NULL;
|
||||
GFXTextureObject *lastReflectTex = NULL;
|
||||
GFXTextureObject *lastMiscTex = NULL;
|
||||
GFXTextureObject *lastAccuTex = NULL;
|
||||
|
||||
// Next render all the meshes.
|
||||
itr = mElementList.begin();
|
||||
for ( ; itr != mElementList.end(); )
|
||||
|
|
@ -363,12 +421,11 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
|||
|
||||
// Set up SG data for this instance.
|
||||
setupSGData( passRI, sgData );
|
||||
mat->setSceneInfo(state, sgData);
|
||||
|
||||
matrixSet.setWorld(*passRI->objectToWorld);
|
||||
matrixSet.setView(*passRI->worldToCamera);
|
||||
matrixSet.setProjection(*passRI->projection);
|
||||
|
||||
mat->setSceneInfo(state, sgData);
|
||||
mat->setTransforms(matrixSet, state);
|
||||
|
||||
// If we're instanced then don't render yet.
|
||||
|
|
@ -385,6 +442,43 @@ void RenderPrePassMgr::render( SceneRenderState *state )
|
|||
continue;
|
||||
}
|
||||
|
||||
bool dirty = false;
|
||||
|
||||
// set the lightmaps if different
|
||||
if( passRI->lightmap && passRI->lightmap != lastLM )
|
||||
{
|
||||
sgData.lightmap = passRI->lightmap;
|
||||
lastLM = passRI->lightmap;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
// set the cubemap if different.
|
||||
if ( passRI->cubemap != lastCubemap )
|
||||
{
|
||||
sgData.cubemap = passRI->cubemap;
|
||||
lastCubemap = passRI->cubemap;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if ( passRI->reflectTex != lastReflectTex )
|
||||
{
|
||||
sgData.reflectTex = passRI->reflectTex;
|
||||
lastReflectTex = passRI->reflectTex;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
// Update accumulation texture if it changed.
|
||||
// Note: accumulation texture can be NULL, and must be updated.
|
||||
if (passRI->accuTex != lastAccuTex)
|
||||
{
|
||||
sgData.accuTex = passRI->accuTex;
|
||||
lastAccuTex = lastAccuTex;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if ( dirty )
|
||||
mat->setTextureStages( state, sgData );
|
||||
|
||||
// Setup the vertex and index buffers.
|
||||
mat->setBuffers( passRI->vertBuff, passRI->primBuff );
|
||||
|
||||
|
|
@ -525,6 +619,31 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
|||
|
||||
#ifndef TORQUE_DEDICATED
|
||||
|
||||
//tag all materials running through prepass as deferred
|
||||
newFeatures.addFeature(MFT_isDeferred);
|
||||
|
||||
// Deferred Shading : Diffuse
|
||||
if (mStages[stageNum].getTex( MFT_DiffuseMap ))
|
||||
{
|
||||
newFeatures.addFeature(MFT_DiffuseMap);
|
||||
}
|
||||
newFeatures.addFeature( MFT_DiffuseColor );
|
||||
|
||||
// Deferred Shading : Specular
|
||||
if( mStages[stageNum].getTex( MFT_SpecularMap ) )
|
||||
{
|
||||
newFeatures.addFeature( MFT_DeferredSpecMap );
|
||||
}
|
||||
else if ( mMaterial->mPixelSpecular[stageNum] )
|
||||
{
|
||||
newFeatures.addFeature( MFT_DeferredSpecVars );
|
||||
}
|
||||
else
|
||||
newFeatures.addFeature(MFT_DeferredEmptySpec);
|
||||
|
||||
// Deferred Shading : Material Info Flags
|
||||
newFeatures.addFeature( MFT_DeferredMatInfoFlags );
|
||||
|
||||
for ( U32 i=0; i < fd.features.getCount(); i++ )
|
||||
{
|
||||
const FeatureType &type = fd.features.getAt( i );
|
||||
|
|
@ -553,7 +672,10 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
|||
type == MFT_InterlacedPrePass ||
|
||||
type == MFT_Visibility ||
|
||||
type == MFT_UseInstancing ||
|
||||
type == MFT_DiffuseVertColor )
|
||||
type == MFT_DiffuseVertColor ||
|
||||
type == MFT_DetailMap ||
|
||||
type == MFT_DetailNormalMap ||
|
||||
type == MFT_DiffuseMapAtlas)
|
||||
newFeatures.addFeature( type );
|
||||
|
||||
// Add any transform features.
|
||||
|
|
@ -563,11 +685,39 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
|||
newFeatures.addFeature( type );
|
||||
}
|
||||
|
||||
if (mMaterial->mAccuEnabled[stageNum])
|
||||
{
|
||||
newFeatures.addFeature(MFT_AccuMap);
|
||||
mHasAccumulation = true;
|
||||
}
|
||||
|
||||
// we need both diffuse and normal maps + sm3 to have an accu map
|
||||
if (newFeatures[MFT_AccuMap] &&
|
||||
(!newFeatures[MFT_DiffuseMap] ||
|
||||
!newFeatures[MFT_NormalMap] ||
|
||||
GFX->getPixelShaderVersion() < 3.0f)) {
|
||||
AssertWarn(false, "SAHARA: Using an Accu Map requires SM 3.0 and a normal map.");
|
||||
newFeatures.removeFeature(MFT_AccuMap);
|
||||
mHasAccumulation = false;
|
||||
}
|
||||
|
||||
// if we still have the AccuMap feature, we add all accu constant features
|
||||
if (newFeatures[MFT_AccuMap]) {
|
||||
// add the dependencies of the accu map
|
||||
newFeatures.addFeature(MFT_AccuScale);
|
||||
newFeatures.addFeature(MFT_AccuDirection);
|
||||
newFeatures.addFeature(MFT_AccuStrength);
|
||||
newFeatures.addFeature(MFT_AccuCoverage);
|
||||
newFeatures.addFeature(MFT_AccuSpecular);
|
||||
// now remove some features that are not compatible with this
|
||||
newFeatures.removeFeature(MFT_UseInstancing);
|
||||
}
|
||||
|
||||
// If there is lightmapped geometry support, add the MRT light buffer features
|
||||
if(bEnableMRTLightmap)
|
||||
{
|
||||
// If this material has a lightmap, pass it through, and flag it to
|
||||
// send it's output to RenderTarget1
|
||||
// send it's output to RenderTarget3
|
||||
if( fd.features.hasFeature( MFT_ToneMap ) )
|
||||
{
|
||||
newFeatures.addFeature( MFT_ToneMap );
|
||||
|
|
@ -590,10 +740,16 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
|||
else
|
||||
{
|
||||
// If this object isn't lightmapped, add a zero-output feature to it
|
||||
newFeatures.addFeature( MFT_RenderTarget1_Zero );
|
||||
newFeatures.addFeature( MFT_RenderTarget3_Zero );
|
||||
}
|
||||
}
|
||||
|
||||
// cubemaps only available on stage 0 for now - bramage
|
||||
if ( stageNum < 1 &&
|
||||
( ( mMaterial->mCubemapData && mMaterial->mCubemapData->mCubemap ) ||
|
||||
mMaterial->mDynamicCubemap ) )
|
||||
newFeatures.addFeature( MFT_CubeMap );
|
||||
|
||||
#endif
|
||||
|
||||
// Set the new features.
|
||||
|
|
@ -602,8 +758,54 @@ void ProcessedPrePassMaterial::_determineFeatures( U32 stageNum,
|
|||
|
||||
U32 ProcessedPrePassMaterial::getNumStages()
|
||||
{
|
||||
// Return 1 stage so this material gets processed for sure
|
||||
return 1;
|
||||
// Loops through all stages to determine how many
|
||||
// stages we actually use.
|
||||
//
|
||||
// The first stage is always active else we shouldn't be
|
||||
// creating the material to begin with.
|
||||
U32 numStages = 1;
|
||||
|
||||
U32 i;
|
||||
for( i=1; i<Material::MAX_STAGES; i++ )
|
||||
{
|
||||
// Assume stage is inactive
|
||||
bool stageActive = false;
|
||||
|
||||
// Cubemaps only on first stage
|
||||
if( i == 0 )
|
||||
{
|
||||
// If we have a cubemap the stage is active
|
||||
if( mMaterial->mCubemapData || mMaterial->mDynamicCubemap )
|
||||
{
|
||||
numStages++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a texture for the a feature the
|
||||
// stage is active.
|
||||
if ( mStages[i].hasValidTex() )
|
||||
stageActive = true;
|
||||
|
||||
// If this stage has specular lighting, it's active
|
||||
if ( mMaterial->mPixelSpecular[i] )
|
||||
stageActive = true;
|
||||
|
||||
// If this stage has diffuse color, it's active
|
||||
if ( mMaterial->mDiffuse[i].alpha > 0 &&
|
||||
mMaterial->mDiffuse[i] != ColorF::WHITE )
|
||||
stageActive = true;
|
||||
|
||||
// If we have a Material that is vertex lit
|
||||
// then it may not have a texture
|
||||
if( mMaterial->mVertLit[i] )
|
||||
stageActive = true;
|
||||
|
||||
// Increment the number of active stages
|
||||
numStages += stageActive;
|
||||
}
|
||||
|
||||
return numStages;
|
||||
}
|
||||
|
||||
void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
||||
|
|
@ -633,7 +835,7 @@ void ProcessedPrePassMaterial::addStateBlockDesc(const GFXStateBlockDesc& desc)
|
|||
if ( isTranslucent )
|
||||
{
|
||||
prePassStateBlock.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha );
|
||||
prePassStateBlock.setColorWrites( true, true, false, false );
|
||||
prePassStateBlock.setColorWrites(false, false, false, true);
|
||||
}
|
||||
|
||||
// Enable z reads, but only enable zwrites if we're not translucent.
|
||||
|
|
@ -663,7 +865,22 @@ ProcessedMaterial* PrePassMatInstance::getShaderMaterial()
|
|||
bool PrePassMatInstance::init( const FeatureSet &features,
|
||||
const GFXVertexFormat *vertexFormat )
|
||||
{
|
||||
return Parent::init( features, vertexFormat );
|
||||
bool vaild = Parent::init(features, vertexFormat);
|
||||
|
||||
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 vaild;
|
||||
}
|
||||
|
||||
PrePassMatInstanceHook::PrePassMatInstanceHook( MatInstance *baseMatInst,
|
||||
|
|
@ -850,3 +1067,77 @@ Var* LinearEyeDepthConditioner::printMethodHeader( MethodType methodType, const
|
|||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void RenderPrePassMgr::_initShaders()
|
||||
{
|
||||
if ( mClearGBufferShader ) return;
|
||||
|
||||
// Find ShaderData
|
||||
ShaderData *shaderData;
|
||||
mClearGBufferShader = Sim::findObject( "ClearGBufferShader", shaderData ) ? shaderData->getShader() : NULL;
|
||||
if ( !mClearGBufferShader )
|
||||
Con::errorf( "RenderPrePassMgr::_initShaders - could not find ClearGBufferShader" );
|
||||
|
||||
// Create StateBlocks
|
||||
GFXStateBlockDesc desc;
|
||||
desc.setCullMode( GFXCullNone );
|
||||
desc.setBlend( true );
|
||||
desc.setZReadWrite( false, false );
|
||||
desc.samplersDefined = true;
|
||||
desc.samplers[0].addressModeU = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeV = GFXAddressWrap;
|
||||
desc.samplers[0].addressModeW = GFXAddressWrap;
|
||||
desc.samplers[0].magFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].minFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].mipFilter = GFXTextureFilterLinear;
|
||||
desc.samplers[0].textureColorOp = GFXTOPModulate;
|
||||
|
||||
mStateblock = GFX->createStateBlock( desc );
|
||||
|
||||
// Set up shader constants.
|
||||
mShaderConsts = mClearGBufferShader->allocConstBuffer();
|
||||
mSpecularStrengthSC = mClearGBufferShader->getShaderConstHandle( "$specularStrength" );
|
||||
mSpecularPowerSC = mClearGBufferShader->getShaderConstHandle( "$specularPower" );
|
||||
}
|
||||
|
||||
void RenderPrePassMgr::clearBuffers()
|
||||
{
|
||||
// Clear z-buffer.
|
||||
GFX->clear( GFXClearTarget | GFXClearZBuffer | GFXClearStencil, ColorI::ZERO, 1.0f, 0);
|
||||
|
||||
if ( !mClearGBufferShader )
|
||||
return;
|
||||
|
||||
GFXTransformSaver saver;
|
||||
|
||||
// Clear the g-buffer.
|
||||
RectI box(-1, -1, 3, 3);
|
||||
GFX->setWorldMatrix( MatrixF::Identity );
|
||||
GFX->setViewMatrix( MatrixF::Identity );
|
||||
GFX->setProjectionMatrix( MatrixF::Identity );
|
||||
|
||||
GFX->setShader(mClearGBufferShader);
|
||||
GFX->setStateBlock(mStateblock);
|
||||
|
||||
Point2F nw(-0.5,-0.5);
|
||||
Point2F ne(0.5,-0.5);
|
||||
|
||||
GFXVertexBufferHandle<GFXVertexPC> verts(GFX, 4, GFXBufferTypeVolatile);
|
||||
verts.lock();
|
||||
|
||||
F32 ulOffset = 0.5f - GFX->getFillConventionOffset();
|
||||
|
||||
Point2F upperLeft(-1.0, -1.0);
|
||||
Point2F lowerRight(1.0, 1.0);
|
||||
|
||||
verts[0].point.set( upperLeft.x+nw.x+ulOffset, upperLeft.y+nw.y+ulOffset, 0.0f );
|
||||
verts[1].point.set( lowerRight.x+ne.x, upperLeft.y+ne.y+ulOffset, 0.0f );
|
||||
verts[2].point.set( upperLeft.x-ne.x+ulOffset, lowerRight.y-ne.y, 0.0f );
|
||||
verts[3].point.set( lowerRight.x-nw.x, lowerRight.y-nw.y, 0.0f );
|
||||
|
||||
verts.unlock();
|
||||
|
||||
GFX->setVertexBuffer( verts );
|
||||
GFX->drawPrimitive( GFXTriangleStrip, 0, 2 );
|
||||
GFX->setShader(NULL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ public:
|
|||
// registered buffer name
|
||||
static const String BufferName;
|
||||
|
||||
// andremwac: Deferred Rendering
|
||||
static const String ColorBufferName;
|
||||
static const String MatInfoBufferName;
|
||||
|
||||
// Generic PrePass Render Instance Type
|
||||
static const RenderInstType RIT_PrePass;
|
||||
|
||||
|
|
@ -93,6 +97,22 @@ protected:
|
|||
virtual void _createPrePassMaterial();
|
||||
|
||||
bool _lightManagerActivate(bool active);
|
||||
|
||||
// Deferred Shading
|
||||
GFXVertexBufferHandle<GFXVertexPC> mClearGBufferVerts;
|
||||
GFXShaderRef mClearGBufferShader;
|
||||
GFXStateBlockRef mStateblock;
|
||||
NamedTexTarget mColorTarget;
|
||||
NamedTexTarget mMatInfoTarget;
|
||||
GFXTexHandle mColorTex;
|
||||
GFXTexHandle mMatInfoTex;
|
||||
GFXShaderConstBufferRef mShaderConsts;
|
||||
GFXShaderConstHandle *mSpecularStrengthSC;
|
||||
GFXShaderConstHandle *mSpecularPowerSC;
|
||||
|
||||
public:
|
||||
void clearBuffers();
|
||||
void _initShaders();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
|
|
|
|||
|
|
@ -156,10 +156,10 @@ LangElement *ShaderFeatureGLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|||
}
|
||||
else
|
||||
{
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -365,7 +365,7 @@ Var* ShaderFeatureGLSL::getOutTexCoord( const char *name,
|
|||
|
||||
// Statement allows for casting of different types which
|
||||
// eliminates vector truncation problems.
|
||||
String statement = String::ToString( " @ = %s(tMul(@, @));\r\n", type );
|
||||
String statement = String::ToString( " @ = %s(tMul(@, @).xy);\r\n", type );
|
||||
meta->addStatement( new GenOp( statement , texCoord, texMat, inTex ) );
|
||||
}
|
||||
else
|
||||
|
|
@ -708,7 +708,7 @@ void ShaderFeatureGLSL::getWsPosition( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *objTrans = getObjTrans( componentList, useInstancing, meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
wsPosition, objTrans, inPosition ) );
|
||||
}
|
||||
|
||||
|
|
@ -813,7 +813,7 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
texMat->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, @) * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, @).xy * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -847,12 +847,22 @@ void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 DiffuseMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *inTex = getInTexCoord( "texCoord", "vec2", true, componentList );
|
||||
|
||||
//determine output target
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -869,7 +879,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
MultiLine * meta = new MultiLine;
|
||||
output = meta;
|
||||
|
||||
if ( fd.features[MFT_CubeMap] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
|
|
@ -878,9 +887,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
inTex ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement( new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor) );
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
|
||||
output = meta;
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
{
|
||||
|
|
@ -946,8 +954,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
#ifdef DEBUG_ATLASED_UV_COORDS
|
||||
if(!fd.features[MFT_PrePassConditioner])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @ = vec4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -961,20 +969,20 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1089,6 +1097,11 @@ void OverlayTexFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
// Diffuse color
|
||||
//****************************************************************************
|
||||
|
||||
U32 DiffuseFeatureGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -1099,7 +1112,33 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, Material::Mul ) ) );
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
col = new Var;
|
||||
col->setType("vec4");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = vec4(1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
Material::BlendOp op;
|
||||
|
||||
if (fd.features[MFT_DiffuseMap])
|
||||
op = Material::Mul;
|
||||
else
|
||||
op = Material::None;
|
||||
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffuseMaterialColor, op, NULL, targ)));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1231,9 +1270,9 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Lightmap has already been included in the advanced light bin, so
|
||||
// no need to do any sampling or anything
|
||||
if(bPreProcessedLighting)
|
||||
statement = new GenOp( "float4(@, 1.0)", inColor );
|
||||
statement = new GenOp( "vec4(@, 1.0)", inColor );
|
||||
else
|
||||
statement = new GenOp( "tex2D(@, @) + float4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
statement = new GenOp( "tex2D(@, @) + vec4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1245,8 +1284,8 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
||||
|
|
@ -1278,7 +1317,7 @@ void LightmapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 LightmapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1372,8 +1411,8 @@ void TonemapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Assign to proper render target
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
||||
|
|
@ -1406,7 +1445,7 @@ void TonemapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 TonemapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1512,17 +1551,17 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// the dynamic light buffer, and it already has the baked-vertex-color
|
||||
// included in it
|
||||
if(bPreProcessedLighting)
|
||||
outColor = new GenOp( "float4(@.rgb, 1.0)", rtLightingColor );
|
||||
outColor = new GenOp( "vec4(@.rgb, 1.0)", rtLightingColor );
|
||||
else
|
||||
outColor = new GenOp( "float4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
outColor = new GenOp( "vec4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
}
|
||||
}
|
||||
|
||||
// Output the color
|
||||
if ( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
||||
|
|
@ -1532,7 +1571,7 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
U32 VertLitGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1571,7 +1610,10 @@ void DetailFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// and a simple multiplication with the detail map.
|
||||
|
||||
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
if ( fd.features[MFT_isDeferred])
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add, NULL, ShaderFeature::RenderTarget1 ) );
|
||||
else
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DetailFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1630,7 +1672,7 @@ void VertPositionGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *modelview = getModelView( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, float4(@.xyz,1));\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, vec4(@.xyz,1));\r\n",
|
||||
outPosition, modelview, inPosition ) );
|
||||
|
||||
output = meta;
|
||||
|
|
@ -1694,8 +1736,8 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeNormal->setName( "cubeNormal" );
|
||||
cubeNormal->setType( "vec3" );
|
||||
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
||||
|
|
@ -1771,9 +1813,14 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
glossColor = (Var*) LangElement::find( "diffuseColor" );
|
||||
if( !glossColor )
|
||||
glossColor = (Var*) LangElement::find( "bumpNormal" );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
glossColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("specularColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("bumpNormal");
|
||||
}
|
||||
|
||||
// grab connector texcoord register
|
||||
|
|
@ -1786,7 +1833,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// create cubemap var
|
||||
Var *cubeMap = new Var;
|
||||
cubeMap->setType( "samplerCUBE" );
|
||||
cubeMap->setType( "samplerCube" );
|
||||
cubeMap->setName( "cubeMap" );
|
||||
cubeMap->uniform = true;
|
||||
cubeMap->sampler = true;
|
||||
|
|
@ -1800,14 +1847,36 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if ( fd.materialFeatures[MFT_RTLighting] )
|
||||
attn =(Var*)LangElement::find("d_NL_Att");
|
||||
|
||||
LangElement *texCube = new GenOp( "texCUBE( @, @ )", cubeMap, reflectVec );
|
||||
LangElement *texCube = NULL;
|
||||
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
//first try and grab the gbuffer
|
||||
if (fd.features[MFT_isDeferred] && matinfo)
|
||||
{
|
||||
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
texCube = new GenOp("textureLod( @, @, (@.a*5) )", cubeMap, reflectVec, matinfo);
|
||||
else
|
||||
texCube = new GenOp("textureLod( @, @, (@.a/4) )", cubeMap, reflectVec, matinfo);
|
||||
}
|
||||
else if(glossColor) //failing that, rtry and find color data
|
||||
texCube = new GenOp("textureLod( @, @, @.a*5)", cubeMap, reflectVec, glossColor);
|
||||
else
|
||||
texCube = new GenOp("texture( @, @)", cubeMap, reflectVec);
|
||||
|
||||
LangElement *lerpVal = NULL;
|
||||
Material::BlendOp blendOp = Material::LerpAlpha;
|
||||
|
||||
// Note that the lerpVal needs to be a float4 so that
|
||||
// it will work with the LerpAlpha blend.
|
||||
|
||||
if ( glossColor )
|
||||
|
||||
if (matinfo)
|
||||
{
|
||||
if (attn)
|
||||
lerpVal = new GenOp("@ * saturate( @ )", matinfo, attn);
|
||||
else
|
||||
lerpVal = new GenOp("@", matinfo);
|
||||
}
|
||||
else if ( glossColor )
|
||||
{
|
||||
if ( attn )
|
||||
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
||||
|
|
@ -1821,8 +1890,16 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
blendOp = Material::Mul;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b));\r\n", targ, targ, texCube, lerpVal));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b*128/5));\r\n", targ, targ, texCube, lerpVal));
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1967,7 +2044,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
// Transform the normal to world space.
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
}
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
|
@ -2025,7 +2102,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// feature (this is done for BL terrain lightmaps).
|
||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||
if ( !lightMask )
|
||||
lightMask = new GenOp( "float4( 1, 1, 1, 1 )" );
|
||||
lightMask = new GenOp( "vec4( 1, 1, 1, 1 )" );
|
||||
|
||||
// Get all the light constants.
|
||||
Var *inLightPos = new Var( "inLightPos", "vec4" );
|
||||
|
|
@ -2080,7 +2157,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
rtShading, specular ) );
|
||||
|
||||
// Apply the lighting to the diffuse color.
|
||||
LangElement *lighting = new GenOp( "float4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
LangElement *lighting = new GenOp( "vec4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -2351,7 +2428,9 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
if ( !color )
|
||||
color = (Var*)LangElement::find("col");
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2718,3 +2797,16 @@ void ImposterVertFeatureGLSL::determineFeature( Material *material,
|
|||
outFeatureData->features.addFeature( MFT_ImposterVert );
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// Vertex position
|
||||
//****************************************************************************
|
||||
void DeferredSkyGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *outPosition = (Var*)LangElement::find( "gl_Position" );
|
||||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @.w = @.z;\r\n", outPosition, outPosition ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ public:
|
|||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
|
@ -301,6 +303,8 @@ public:
|
|||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::None; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual String getName()
|
||||
{
|
||||
return "Diffuse Color";
|
||||
|
|
@ -656,4 +660,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class DeferredSkyGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Sky"; }
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
#endif // _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
|
||||
|
|
|
|||
|
|
@ -30,8 +30,11 @@
|
|||
|
||||
class ShaderGenPrinterGLSL : public ShaderGenPrinter
|
||||
{
|
||||
bool extraRTs[3];
|
||||
|
||||
public:
|
||||
|
||||
ShaderGenPrinterGLSL() { for (int i = 0; i < 3; i++) extraRTs[i] = false; }
|
||||
|
||||
// ShaderGenPrinter
|
||||
virtual void printShaderHeader(Stream& stream);
|
||||
virtual void printMainComment(Stream& stream);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include "core/module.h"
|
||||
#include "shaderGen/GLSL/accuFeatureGLSL.h"
|
||||
|
||||
// Deferred Shading
|
||||
#include "lighting/advanced/glsl/deferredShadingFeaturesGLSL.h"
|
||||
|
||||
static ShaderGen::ShaderGenInitDelegate sInitDelegate;
|
||||
|
||||
|
|
@ -66,8 +68,13 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
|
||||
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_Fog, new FogFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureGLSL( "Lightbuffer MRT" ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget1 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget2 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget3_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget3 ) );
|
||||
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureGLSL( "Imposter" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_NormalsOut, new NormalsOutFeatGLSL );
|
||||
|
|
@ -80,9 +87,6 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_ParaboloidVertTransform, new ParaboloidVertTransformGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_IsSinglePassParaboloid, new NamedFeatureGLSL( "Single Pass Paraboloid" ) );
|
||||
FEATUREMGR->registerFeature( MFT_UseInstancing, new NamedFeatureGLSL( "Hardware Instancing" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroGLSL
|
||||
( ShaderFeature::RenderTarget1 ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureGLSL( "Diffuse Map Atlas" ) );
|
||||
FEATUREMGR->registerFeature( MFT_NormalMapAtlas, new NamedFeatureGLSL( "Normal Map Atlas" ) );
|
||||
|
|
@ -94,10 +98,13 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
|
||||
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureGLSL );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureGLSL( "Lightbuffer MRT" ) );
|
||||
//FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
|
||||
//FEATUREMGR->registerFeature( MFT_InterlacedPrePass, new NamedFeatureGLSL( "Interlaced Pre Pass" ) );
|
||||
|
||||
// Deferred Shading
|
||||
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_SkyBox, new DeferredSkyGLSL );
|
||||
}
|
||||
|
||||
MODULE_BEGIN( ShaderGenGLSL )
|
||||
|
|
|
|||
|
|
@ -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 ) );
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ Var* ShaderFeatureHLSL::getOutTexCoord( const char *name,
|
|||
|
||||
// Statement allows for casting of different types which
|
||||
// eliminates vector truncation problems.
|
||||
String statement = String::ToString( " @ = (%s)mul(@, @);\r\n", type );
|
||||
String statement = String::ToString( " @ = (%s)mul(@, @).xy;\r\n", type );
|
||||
meta->addStatement( new GenOp( statement, texCoord, texMat, inTex ) );
|
||||
}
|
||||
else
|
||||
|
|
@ -811,7 +811,7 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
texMat->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ = mul(@, @) * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
meta->addStatement( new GenOp( " @ = mul(@, @).xy * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -845,12 +845,22 @@ void DiffuseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 DiffuseMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *inTex = getInTexCoord( "texCoord", "float2", true, componentList );
|
||||
|
||||
//determine output target
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -877,7 +887,7 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
{
|
||||
|
|
@ -944,7 +954,7 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if(!fd.features[MFT_PrePassConditioner])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -962,15 +972,15 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
}
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DiffuseMapFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1087,6 +1097,11 @@ void OverlayTexFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
// Diffuse color
|
||||
//****************************************************************************
|
||||
|
||||
U32 DiffuseFeatureHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseFeatureHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -1096,8 +1111,34 @@ void DiffuseFeatureHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->uniform = true;
|
||||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, Material::Mul ) ) );
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
col = new Var;
|
||||
col->setType("fragout");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = float4(1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
Material::BlendOp op;
|
||||
|
||||
if (fd.features[MFT_DiffuseMap])
|
||||
op = Material::Mul;
|
||||
else
|
||||
op = Material::None;
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, op, NULL, targ ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1243,8 +1284,8 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
||||
|
|
@ -1276,7 +1317,7 @@ void LightmapFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 LightmapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1370,8 +1411,8 @@ void TonemapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Assign to proper render target
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
||||
|
|
@ -1404,7 +1445,7 @@ void TonemapFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 TonemapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1519,8 +1560,8 @@ void VertLitHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Output the color
|
||||
if ( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
||||
|
|
@ -1530,7 +1571,7 @@ void VertLitHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
U32 VertLitHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1569,7 +1610,10 @@ void DetailFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// and a simple multiplication with the detail map.
|
||||
|
||||
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
if ( fd.features[MFT_isDeferred])
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add, NULL, ShaderFeature::RenderTarget1 ) );
|
||||
else
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DetailFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1694,7 +1738,7 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeNormal->setType( "float3" );
|
||||
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = normalize( mul(@, float4(normalize(@),0.0)).xyz );\r\n",
|
||||
meta->addStatement( new GenOp( " @ = normalize( mul(@, float4(normalize(@),0.0)).xyz );\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
// grab the eye position
|
||||
|
|
@ -1767,9 +1811,14 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
glossColor = (Var*) LangElement::find( "diffuseColor" );
|
||||
if( !glossColor )
|
||||
glossColor = (Var*) LangElement::find( "bumpNormal" );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
glossColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("specularColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("bumpNormal");
|
||||
}
|
||||
|
||||
// grab connector texcoord register
|
||||
|
|
@ -1795,15 +1844,41 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
//else
|
||||
if ( fd.materialFeatures[MFT_RTLighting] )
|
||||
attn =(Var*)LangElement::find("d_NL_Att");
|
||||
|
||||
LangElement *texCube = NULL;
|
||||
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
//first try and grab the gbuffer
|
||||
if (fd.features[MFT_isDeferred] && matinfo)
|
||||
{
|
||||
// Cube LOD level = (1.0 - Roughness) * 8
|
||||
// mip_levle = min((1.0 - u_glossiness)*11.0 + 1.0, 8.0)
|
||||
//LangElement *texCube = new GenOp( "texCUBElod( @, float4(@, min((1.0 - (@ / 128.0)) * 11.0 + 1.0, 8.0)) )", cubeMap, reflectVec, specPower );
|
||||
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, (@.a*5)) )", cubeMap, reflectVec, matinfo);
|
||||
else
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, (@.a/4)) )", cubeMap, reflectVec, matinfo);
|
||||
}
|
||||
else
|
||||
if (glossColor) //failing that, rtry and find color data
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, @.a*5))", cubeMap, reflectVec, glossColor);
|
||||
else //failing *that*, just draw the cubemap
|
||||
texCube = new GenOp("texCUBE( @, @)", cubeMap, reflectVec);
|
||||
|
||||
LangElement *texCube = new GenOp( "texCUBE( @, @ )", cubeMap, reflectVec );
|
||||
LangElement *lerpVal = NULL;
|
||||
Material::BlendOp blendOp = Material::LerpAlpha;
|
||||
|
||||
// Note that the lerpVal needs to be a float4 so that
|
||||
// it will work with the LerpAlpha blend.
|
||||
|
||||
if ( glossColor )
|
||||
if (matinfo)
|
||||
{
|
||||
if (attn)
|
||||
lerpVal = new GenOp("@ * saturate( @ )", matinfo, attn);
|
||||
else
|
||||
lerpVal = new GenOp("@", matinfo);
|
||||
}
|
||||
else if ( glossColor )
|
||||
{
|
||||
if ( attn )
|
||||
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
||||
|
|
@ -1817,8 +1892,16 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
blendOp = Material::Mul;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b));\r\n", targ, targ, texCube, lerpVal));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b*128/5));\r\n", targ, targ, texCube, lerpVal));
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1865,9 +1948,9 @@ void ReflectCubeFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
{
|
||||
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( stageDat.getCubemap() )
|
||||
{
|
||||
|
|
@ -2347,7 +2430,9 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
if (!color)
|
||||
color = (Var*)LangElement::find("col");
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2714,3 +2799,16 @@ void ImposterVertFeatureHLSL::determineFeature( Material *material,
|
|||
outFeatureData->features.addFeature( MFT_ImposterVert );
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// Vertex position
|
||||
//****************************************************************************
|
||||
void DeferredSkyHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *outPosition = (Var*)LangElement::find( "hpos" );
|
||||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @.w = @.z;\r\n", outPosition, outPosition ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ public:
|
|||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
|
@ -301,6 +303,7 @@ public:
|
|||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::None; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName()
|
||||
{
|
||||
return "Diffuse Color";
|
||||
|
|
@ -656,4 +659,12 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class DeferredSkyHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Sky"; }
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
|
||||
#endif // _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "shaderGen/HLSL/paraboloidHLSL.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "core/module.h"
|
||||
// Deferred Shading
|
||||
#include "lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h"
|
||||
#include "shaderGen/HLSL/accuFeatureHLSL.h"
|
||||
|
||||
static ShaderGen::ShaderGenInitDelegate sInitDelegate;
|
||||
|
|
@ -70,6 +72,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget2 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget3_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget3 ) );
|
||||
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureHLSL( "Diffuse Map Atlas" ) );
|
||||
|
|
@ -95,6 +99,14 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_ForwardShading, new NamedFeatureHLSL( "Forward Shaded Material" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
|
||||
|
||||
// Deferred Shading
|
||||
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_SkyBox, new DeferredSkyHLSL );
|
||||
}
|
||||
|
||||
MODULE_BEGIN( ShaderGenHLSL )
|
||||
|
|
|
|||
|
|
@ -47,10 +47,24 @@ ShaderFeature::Resources ShaderFeature::getResources( const MaterialFeatureData
|
|||
const char* ShaderFeature::getOutputTargetVarName( OutputTarget target ) const
|
||||
{
|
||||
const char* targName = "col";
|
||||
if ( target != DefaultTarget )
|
||||
|
||||
switch(target)
|
||||
{
|
||||
case DefaultTarget:
|
||||
targName = "col";
|
||||
break;
|
||||
|
||||
case RenderTarget1:
|
||||
targName = "col1";
|
||||
AssertFatal(target == RenderTarget1, "yeah Pat is lame and didn't want to do bit math stuff, TODO");
|
||||
break;
|
||||
|
||||
case RenderTarget2:
|
||||
targName = "col2";
|
||||
break;
|
||||
|
||||
case RenderTarget3:
|
||||
targName = "col3";
|
||||
break;
|
||||
}
|
||||
|
||||
return targName;
|
||||
|
|
|
|||
|
|
@ -80,4 +80,7 @@ const String ShaderGenVars::cubeMap("$cubeMap");
|
|||
const String ShaderGenVars::dLightMap("$dlightMap");
|
||||
const String ShaderGenVars::dLightMapSec("$dlightMapSec");
|
||||
const String ShaderGenVars::dLightMask("$dlightMask");
|
||||
const String ShaderGenVars::toneMap("$toneMap");
|
||||
const String ShaderGenVars::toneMap("$toneMap");
|
||||
|
||||
// Deferred shading
|
||||
const String ShaderGenVars::matInfoFlags("$matInfoFlags");
|
||||
|
|
@ -94,6 +94,9 @@ struct ShaderGenVars
|
|||
const static String dLightMapSec;
|
||||
const static String dLightMask;
|
||||
const static String toneMap;
|
||||
|
||||
// Deferred Shading
|
||||
const static String matInfoFlags;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "terrain/terrFeatureTypes.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
|
|
@ -48,6 +49,10 @@ namespace
|
|||
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureGLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBaseMap, new TerrainBaseMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainMacroMap, new TerrainMacroMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainDetailMap, new TerrainDetailMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatGLSL );
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -250,10 +255,6 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
// grab connector texcoord register
|
||||
Var *texCoord = getInTexCoord( "texCoord", "vec3", true, componentList );
|
||||
|
||||
// We do nothing more if this is a prepass.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -269,7 +270,14 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
baseColor->setName( "baseColor" );
|
||||
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -278,14 +286,16 @@ ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
res.numTexReg = 1;
|
||||
|
||||
// We only sample from the base map during a diffuse pass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
|
||||
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
|
||||
mTerrainDep( "shaders/common/terrain/terrain.glsl" )
|
||||
|
|
@ -386,6 +396,9 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
const S32 detailIndex = getProcessIndex();
|
||||
Var *inTex = getVertTexCoord( "texCoord" );
|
||||
|
||||
// new terrain
|
||||
bool hasNormal = fd.features.hasFeature(MFT_TerrainNormalMap, detailIndex);
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
// We need the negative tangent space view vector
|
||||
|
|
@ -454,6 +467,100 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n",
|
||||
new DecOp( detailBlend ), detailInfo, inTex, layerSize, layerSample ) );
|
||||
|
||||
// New terrain
|
||||
|
||||
Var *lerpBlend = (Var*)LangElement::find("lerpBlend");
|
||||
if (!lerpBlend)
|
||||
{
|
||||
lerpBlend = new Var;
|
||||
lerpBlend->setType("float");
|
||||
lerpBlend->setName("lerpBlend");
|
||||
lerpBlend->uniform = true;
|
||||
lerpBlend->constSortPos = cspPrimitive;
|
||||
}
|
||||
|
||||
|
||||
Var *blendDepth = (Var*)LangElement::find(String::ToString("blendDepth%d", detailIndex));
|
||||
if (!blendDepth)
|
||||
{
|
||||
blendDepth = new Var;
|
||||
blendDepth->setType("float");
|
||||
blendDepth->setName(String::ToString("blendDepth%d", detailIndex));
|
||||
blendDepth->uniform = true;
|
||||
blendDepth->constSortPos = cspPrimitive;
|
||||
}
|
||||
|
||||
Var *baseColor = (Var*)LangElement::find("baseColor");
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature( MFT_DeferredTerrainDetailMap ))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
if (!outColor)
|
||||
{
|
||||
// create color var
|
||||
outColor = new Var;
|
||||
outColor->setType("float4");
|
||||
outColor->setName("col");
|
||||
outColor->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @;\r\n", outColor));
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find("detailColor");
|
||||
if (!detailColor)
|
||||
{
|
||||
detailColor = new Var;
|
||||
detailColor->setType("float4");
|
||||
detailColor->setName("detailColor");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(detailColor)));
|
||||
}
|
||||
|
||||
// Get the detail texture.
|
||||
Var *detailMap = new Var;
|
||||
detailMap->setType("sampler2D");
|
||||
detailMap->setName(String::ToString("detailMap%d", detailIndex));
|
||||
detailMap->uniform = true;
|
||||
detailMap->sampler = true;
|
||||
detailMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// Get the normal map texture.
|
||||
Var *normalMap = _getNormalMapTex();
|
||||
|
||||
// Issue happens somewhere here -----
|
||||
|
||||
// Sample the normal map.
|
||||
//
|
||||
// We take two normal samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
LangElement *texOp;
|
||||
|
||||
// Note that we're doing the standard greyscale detail
|
||||
// map technique here which can darken and lighten the
|
||||
// diffuse texture.
|
||||
//
|
||||
// We take two color samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
//
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, detailIndex))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex));
|
||||
|
||||
texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
|
||||
normalMap, inDet, normalMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet));
|
||||
|
||||
texOp = new GenOp("tex2D(@, @.xy)", normalMap, inDet);
|
||||
}
|
||||
|
||||
// New terrain
|
||||
|
||||
// Get a var and accumulate the blend amount.
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !blendTotal )
|
||||
|
|
@ -487,46 +594,6 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
}
|
||||
}
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, tGetMatrix3Row(@, 2), min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "detailColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
detailColor = new Var;
|
||||
detailColor->setType( "vec4" );
|
||||
detailColor->setName( "detailColor" );
|
||||
meta->addStatement( new GenOp( " @;\r\n", new DecOp( detailColor ) ) );
|
||||
}
|
||||
|
||||
// Get the detail texture.
|
||||
Var *detailMap = new Var;
|
||||
detailMap->setType( "sampler2D" );
|
||||
detailMap->setName( String::ToString( "detailMap%d", detailIndex ) );
|
||||
detailMap->uniform = true;
|
||||
detailMap->sampler = true;
|
||||
detailMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// If we're using SM 3.0 then take advantage of
|
||||
// dynamic branching to skip layers per-pixel.
|
||||
|
||||
|
|
@ -557,9 +624,6 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
|||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @ + @, @ );\r\n",
|
||||
outColor, outColor, baseColor, detailColor, detailBlend ) );
|
||||
|
||||
|
|
@ -585,9 +649,7 @@ ShaderFeature::Resources TerrainDetailMapFeatGLSL::getResources( const MaterialF
|
|||
res.numTexReg += 4;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
// sample from the detail texture for diffuse coloring.
|
||||
res.numTex += 1;
|
||||
|
||||
// If we have parallax for this layer then we'll also
|
||||
|
|
@ -602,6 +664,11 @@ ShaderFeature::Resources TerrainDetailMapFeatGLSL::getResources( const MaterialF
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainDetailMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainDetailMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
|
||||
TerrainMacroMapFeatGLSL::TerrainMacroMapFeatGLSL()
|
||||
: mTorqueDep( "shaders/common/gl/torque.glsl" ),
|
||||
|
|
@ -759,29 +826,6 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
// Add to the blend total.
|
||||
meta->addStatement( new GenOp( " @ = max( @, @ );\r\n", blendTotal, blendTotal, detailBlend ) );
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, tGetMatrix3Row(@, 2), min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
|
|
@ -826,8 +870,12 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
|
||||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
if(fd.features.hasFeature(MFT_DeferredTerrainMacroMap))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @ + @, @ );\r\n",
|
||||
outColor, outColor, outColor, detailColor, detailBlend ) );
|
||||
|
|
@ -850,9 +898,6 @@ ShaderFeature::Resources TerrainMacroMapFeatGLSL::getResources( const MaterialFe
|
|||
res.numTex += 1;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex += 1;
|
||||
|
||||
// Finally we always send the detail texture
|
||||
|
|
@ -862,6 +907,11 @@ ShaderFeature::Resources TerrainMacroMapFeatGLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainMacroMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainMacroMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -881,9 +931,6 @@ void TerrainNormalMapFeatGLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// We only need to process normals during the prepass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
|
|
@ -1023,7 +1070,12 @@ ShaderFeature::Resources TerrainLightMapFeatGLSL::getResources( const MaterialFe
|
|||
void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = NULL;
|
||||
if (fd.features[MFT_DeferredTerrainDetailMap])
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
else
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !color || !blendTotal )
|
||||
return;
|
||||
|
|
@ -1035,3 +1087,40 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
|
||||
//.b = specular strength, a= spec power.
|
||||
//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
|
||||
//we'll most likely revisit that later. possibly several ways...
|
||||
|
||||
U32 TerrainBlankInfoMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
// search for material var
|
||||
Var *material;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!material)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("vec4");
|
||||
material->setName(getOutputTargetVarName(targ));
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,0.0,0.0001);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Base Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -90,6 +92,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Detail Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -113,6 +117,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Macro Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -154,4 +160,15 @@ public:
|
|||
virtual String getName() { return "Terrain Additive"; }
|
||||
};
|
||||
|
||||
class TerrainBlankInfoMapFeatGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
#endif // _TERRFEATUREGLSL_H_
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "terrain/terrFeatureTypes.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "materials/materialFeatureData.h"
|
||||
#include "materials/processedMaterial.h"
|
||||
#include "gfx/gfxDevice.h"
|
||||
#include "shaderGen/langElement.h"
|
||||
#include "shaderGen/shaderOp.h"
|
||||
|
|
@ -47,9 +48,12 @@ namespace
|
|||
FEATUREMGR->registerFeature( MFT_TerrainMacroMap, new TerrainMacroMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureHLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBaseMap, new TerrainBaseMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainMacroMap, new TerrainMacroMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainDetailMap, new TerrainDetailMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatHLSL );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MODULE_BEGIN( TerrainFeatHLSL )
|
||||
|
|
@ -250,10 +254,6 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
// grab connector texcoord register
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float3", true, componentList );
|
||||
|
||||
// We do nothing more if this is a prepass.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -269,8 +269,15 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
baseColor->setName( "baseColor" );
|
||||
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if (fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -278,14 +285,16 @@ ShaderFeature::Resources TerrainBaseMapFeatHLSL::getResources( const MaterialFea
|
|||
{
|
||||
Resources res;
|
||||
res.numTexReg = 1;
|
||||
|
||||
// We only sample from the base map during a diffuse pass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex = 1;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainBaseMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
|
||||
: mTorqueDep( "shaders/common/torque.hlsl" ),
|
||||
mTerrainDep( "shaders/common/terrain/terrain.hlsl" )
|
||||
|
|
@ -477,7 +486,7 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
// Call the library function to do the rest.
|
||||
if(fd.features.hasFeature( MFT_IsDXTnm, detailIndex ) )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @.xy += parallaxOffsetDxtnm( @, @.xy, @, @.z * @ );\r\n",
|
||||
meta->addStatement( new GenOp( " @.xy += parallaxOffsetDxtnm( @, @.xy, @, @.z * @ );\r\n",
|
||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend ) );
|
||||
}
|
||||
else
|
||||
|
|
@ -487,29 +496,6 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
}
|
||||
}
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @[2], min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "detailColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
|
|
@ -543,21 +529,35 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
|||
// We take two color samples and lerp between them for
|
||||
// side projection layers... else a single sample.
|
||||
//
|
||||
|
||||
//Sampled detail texture that is not expanded
|
||||
Var *detailTex = new Var;
|
||||
detailTex->setType("float4");
|
||||
detailTex->setName("detailTex");
|
||||
meta->addStatement( new GenOp( " @;\r\n", new DecOp( detailTex ) ) );
|
||||
|
||||
if ( fd.features.hasFeature( MFT_TerrainSideProject, detailIndex ) )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet, detailMap, inDet, inTex ) );
|
||||
meta->addStatement( new GenOp(" @ = lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z);\r\n",detailTex,detailMap,inDet,detailMap,inDet,inTex));
|
||||
meta->addStatement( new GenOp( " @ = ( @ * 2.0 ) - 1.0;\r\n", detailColor, detailTex) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = ( tex2D( @, @.xy ) * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailMap, inDet ) );
|
||||
meta->addStatement( new GenOp(" @ = tex2D(@,@.xy);\r\n",detailTex,detailMap,inDet));
|
||||
meta->addStatement( new GenOp( " @ = ( @ * 2.0 ) - 1.0;\r\n",
|
||||
detailColor, detailTex) );
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature( MFT_DeferredTerrainDetailMap ))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
|
@ -584,9 +584,7 @@ ShaderFeature::Resources TerrainDetailMapFeatHLSL::getResources( const MaterialF
|
|||
res.numTexReg += 4;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
// sample from the detail texture for diffuse coloring.
|
||||
res.numTex += 1;
|
||||
|
||||
// If we have parallax for this layer then we'll also
|
||||
|
|
@ -601,6 +599,11 @@ ShaderFeature::Resources TerrainDetailMapFeatHLSL::getResources( const MaterialF
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainDetailMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainDetailMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
|
||||
TerrainMacroMapFeatHLSL::TerrainMacroMapFeatHLSL()
|
||||
: mTorqueDep( "shaders/common/torque.hlsl" ),
|
||||
|
|
@ -758,29 +761,6 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
// Add to the blend total.
|
||||
meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) );
|
||||
|
||||
// If this is a prepass then we skip color.
|
||||
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
{
|
||||
// Check to see if we have a gbuffer normal.
|
||||
Var *gbNormal = (Var*)LangElement::find( "gbNormal" );
|
||||
|
||||
// If we have a gbuffer normal and we don't have a
|
||||
// normal map feature then we need to lerp in a
|
||||
// default normal else the normals below this layer
|
||||
// will show thru.
|
||||
if ( gbNormal &&
|
||||
!fd.features.hasFeature( MFT_TerrainNormalMap, detailIndex ) )
|
||||
{
|
||||
Var *viewToTangent = getInViewToTangent( componentList );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @[2], min( @, @.w ) );\r\n",
|
||||
gbNormal, gbNormal, viewToTangent, detailBlend, inDet ) );
|
||||
}
|
||||
|
||||
output = meta;
|
||||
return;
|
||||
}
|
||||
|
||||
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
||||
if ( !detailColor )
|
||||
{
|
||||
|
|
@ -826,8 +806,14 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
meta->addStatement( new GenOp( " @ *= @.y * @.w;\r\n",
|
||||
detailColor, detailInfo, inDet ) );
|
||||
|
||||
//Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
Var *baseColor = (Var*)LangElement::find( "baseColor" );
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
|
||||
if(fd.features.hasFeature(MFT_DeferredTerrainMacroMap))
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
|
||||
Var *outColor = (Var*)LangElement::find( getOutputTargetVarName(target) );
|
||||
|
||||
meta->addStatement(new GenOp(" @ += @ * @;\r\n",
|
||||
outColor, detailColor, detailBlend));
|
||||
|
|
@ -837,8 +823,6 @@ void TerrainMacroMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentL
|
|||
output = meta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
{
|
||||
Resources res;
|
||||
|
|
@ -850,9 +834,6 @@ ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFe
|
|||
res.numTex += 1;
|
||||
}
|
||||
|
||||
// If this isn't the prepass then we sample
|
||||
// from the detail texture for diffuse coloring.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
res.numTex += 1;
|
||||
|
||||
// Finally we always send the detail texture
|
||||
|
|
@ -862,6 +843,11 @@ ShaderFeature::Resources TerrainMacroMapFeatHLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
U32 TerrainMacroMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainMacroMap] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -881,9 +867,6 @@ void TerrainNormalMapFeatHLSL::processVert( Vector<ShaderComponent*> &component
|
|||
void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// We only need to process normals during the prepass.
|
||||
if ( !fd.features.hasFeature( MFT_PrePassConditioner ) )
|
||||
return;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
|
|
@ -1019,11 +1002,15 @@ ShaderFeature::Resources TerrainLightMapFeatHLSL::getResources( const MaterialFe
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = NULL;
|
||||
if (fd.features[MFT_DeferredTerrainDetailMap])
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
else
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
|
||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||
if ( !color || !blendTotal )
|
||||
return;
|
||||
|
|
@ -1033,5 +1020,43 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
||||
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
||||
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
|
||||
//.b = specular strength, a= spec power.
|
||||
//here, it's merely a cutout for now, so that lightmapping (target3) doesn't get mangled.
|
||||
//we'll most likely revisit that later. possibly several ways...
|
||||
|
||||
U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_DeferredTerrainBaseMap] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
// search for material var
|
||||
Var *material;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!material)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("fragout");
|
||||
material->setName(getOutputTargetVarName(targ));
|
||||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,0.0,0.0001);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Base Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -91,6 +93,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Detail Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -114,6 +118,8 @@ public:
|
|||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
||||
virtual String getName() { return "Terrain Macro Texture"; }
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -155,4 +161,15 @@ public:
|
|||
virtual String getName() { return "Terrain Additive"; }
|
||||
};
|
||||
|
||||
class TerrainBlankInfoMapFeatHLSL : public TerrainFeatHLSL
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
#endif // _TERRFEATUREHLSL_H_
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include "gfx/util/screenspace.h"
|
||||
#include "lighting/advanced/advancedLightBinManager.h"
|
||||
|
||||
S32 sgMaxTerrainMaterialsPerPass = 3;
|
||||
|
||||
AFTER_MODULE_INIT( MaterialManager )
|
||||
{
|
||||
|
|
@ -310,12 +311,12 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
if ( GFX->getPixelShaderVersion() < 3.0f )
|
||||
baseOnly = true;
|
||||
|
||||
// NOTE: At maximum we only try to combine 3 materials
|
||||
// NOTE: At maximum we only try to combine sgMaxTerrainMaterialsPerPass materials
|
||||
// into a single pass. This is sub-optimal for the simplest
|
||||
// cases, but the most common case results in much fewer
|
||||
// shader generation failures and permutations leading to
|
||||
// faster load time and less hiccups during gameplay.
|
||||
U32 matCount = getMin( 3, materials->size() );
|
||||
U32 matCount = getMin( sgMaxTerrainMaterialsPerPass, materials->size() );
|
||||
|
||||
Vector<GFXTexHandle> normalMaps;
|
||||
|
||||
|
|
@ -349,24 +350,27 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
{
|
||||
FeatureSet features;
|
||||
features.addFeature( MFT_VertTransform );
|
||||
features.addFeature( MFT_TerrainBaseMap );
|
||||
|
||||
if ( prePassMat )
|
||||
{
|
||||
features.addFeature( MFT_EyeSpaceDepthOut );
|
||||
features.addFeature( MFT_PrePassConditioner );
|
||||
features.addFeature( MFT_DeferredTerrainBaseMap );
|
||||
features.addFeature(MFT_isDeferred);
|
||||
|
||||
if ( advancedLightmapSupport )
|
||||
features.addFeature( MFT_RenderTarget1_Zero );
|
||||
features.addFeature( MFT_RenderTarget3_Zero );
|
||||
}
|
||||
else
|
||||
{
|
||||
features.addFeature( MFT_TerrainBaseMap );
|
||||
features.addFeature( MFT_RTLighting );
|
||||
|
||||
// The HDR feature is always added... it will compile out
|
||||
// if HDR is not enabled in the engine.
|
||||
features.addFeature( MFT_HDROut );
|
||||
}
|
||||
features.addFeature(MFT_DeferredTerrainBlankInfoMap);
|
||||
|
||||
// Enable lightmaps and fogging if we're in BL.
|
||||
if ( reflectMat || useBLM )
|
||||
|
|
@ -405,8 +409,16 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
|
||||
// check for macro detail texture
|
||||
if ( !(mat->getMacroSize() <= 0 || mat->getMacroDistance() <= 0 || mat->getMacroMap().isEmpty() ) )
|
||||
{
|
||||
if(prePassMat)
|
||||
features.addFeature( MFT_DeferredTerrainMacroMap, featureIndex );
|
||||
else
|
||||
features.addFeature( MFT_TerrainMacroMap, featureIndex );
|
||||
}
|
||||
|
||||
if(prePassMat)
|
||||
features.addFeature( MFT_DeferredTerrainDetailMap, featureIndex );
|
||||
else
|
||||
features.addFeature( MFT_TerrainDetailMap, featureIndex );
|
||||
|
||||
pass->materials.push_back( (*materials)[i] );
|
||||
|
|
@ -536,8 +548,8 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
// MFT_TerrainAdditive feature to lerp the
|
||||
// output normal with the previous pass.
|
||||
//
|
||||
if ( prePassMat )
|
||||
desc.setColorWrites( true, true, false, false );
|
||||
//if ( prePassMat )
|
||||
//desc.setColorWrites( true, true, false, false );
|
||||
}
|
||||
|
||||
// We write to the zbuffer if this is a prepass
|
||||
|
|
@ -656,9 +668,9 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
if ( prePassMat )
|
||||
desc.addDesc( RenderPrePassMgr::getOpaqueStenciWriteDesc( false ) );
|
||||
|
||||
// Flip the cull for reflection materials.
|
||||
if ( reflectMat )
|
||||
desc.setCullMode( GFXCullCW );
|
||||
// Shut off culling for prepass materials (reflection support).
|
||||
if ( prePassMat )
|
||||
desc.setCullMode( GFXCullNone );
|
||||
|
||||
pass->stateBlock = GFX->createStateBlock( desc );
|
||||
|
||||
|
|
|
|||
|
|
@ -34,4 +34,8 @@ ImplementFeatureType( MFT_TerrainMacroMap, MFG_Texture, 104.0f, false );
|
|||
ImplementFeatureType( MFT_TerrainLightMap, MFG_Texture, 105.0f, false );
|
||||
ImplementFeatureType( MFT_TerrainSideProject, MFG_Texture, 106.0f, false );
|
||||
ImplementFeatureType( MFT_TerrainAdditive, MFG_PostProcess, 999.0f, false );
|
||||
|
||||
//Deferred Shading
|
||||
ImplementFeatureType( MFT_DeferredTerrainBaseMap, MFG_Texture, 100.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainDetailMap, MFG_Texture, 102.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainMacroMap, MFG_Texture, 104.1f, false );
|
||||
ImplementFeatureType( MFT_DeferredTerrainBlankInfoMap, MFG_Texture, 104.1f, false);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ DeclareFeatureType( MFT_TerrainParallaxMap );
|
|||
DeclareFeatureType( MFT_TerrainLightMap );
|
||||
DeclareFeatureType( MFT_TerrainSideProject );
|
||||
DeclareFeatureType( MFT_TerrainAdditive );
|
||||
//Deferred Shading
|
||||
DeclareFeatureType( MFT_DeferredTerrainBaseMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainDetailMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainMacroMap );
|
||||
DeclareFeatureType( MFT_DeferredTerrainBlankInfoMap );
|
||||
|
||||
|
||||
#endif // _TERRFEATURETYPES_H_
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
singleton ShaderData( ClearGBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredClearGBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredClearGBufferP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton ShaderData( DeferredColorShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredColorShaderP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredColorShaderP.glsl";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
// Primary Deferred Shader
|
||||
new GFXStateBlockData( AL_DeferredShadingState : PFX_DefaultStateBlock )
|
||||
{
|
||||
cullMode = GFXCullNone;
|
||||
|
||||
blendDefined = true;
|
||||
blendEnable = true;
|
||||
blendSrc = GFXBlendSrcAlpha;
|
||||
blendDest = GFXBlendInvSrcAlpha;
|
||||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerWrapLinear;
|
||||
samplerStates[1] = SamplerWrapLinear;
|
||||
samplerStates[2] = SamplerWrapLinear;
|
||||
samplerStates[3] = SamplerWrapLinear;
|
||||
};
|
||||
|
||||
new ShaderData( AL_DeferredShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/lighting/advanced/deferredShadingP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/deferredShadingP.glsl";
|
||||
|
||||
samplerNames[0] = "colorBufferTex";
|
||||
samplerNames[1] = "lightPrePassTex";
|
||||
samplerNames[2] = "matInfoTex";
|
||||
samplerNames[3] = "prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_DeferredShading )
|
||||
{
|
||||
renderTime = "PFXBeforeBin";
|
||||
renderBin = "SkyBin";
|
||||
shader = AL_DeferredShader;
|
||||
stateBlock = AL_DeferredShadingState;
|
||||
texture[0] = "#color";
|
||||
texture[1] = "#lightinfo";
|
||||
texture[2] = "#matinfo";
|
||||
texture[3] = "#prepass";
|
||||
|
||||
target = "$backBuffer";
|
||||
renderPriority = 10000;
|
||||
allowReflectPass = true;
|
||||
};
|
||||
|
||||
// Debug Shaders.
|
||||
new ShaderData( AL_ColorBufferShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgColorBufferP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgColorBufferP.glsl";
|
||||
|
||||
samplerNames[0] = "colorBufferTex";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_ColorBufferVisualize )
|
||||
{
|
||||
shader = AL_ColorBufferShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#color";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleColorBufferViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_ColorBufferShaderVar = AL_ColorBufferVisualize.isEnabled() ? false : true;
|
||||
AL_ColorBufferVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
{
|
||||
AL_DeferredShading.disable();
|
||||
AL_ColorBufferVisualize.enable();
|
||||
}
|
||||
else if ( !%enable )
|
||||
{
|
||||
AL_ColorBufferVisualize.disable();
|
||||
AL_DeferredShading.enable();
|
||||
}
|
||||
}
|
||||
|
||||
new ShaderData( AL_SpecMapShader )
|
||||
{
|
||||
DXVertexShaderFile = "shaders/common/postFx/postFxV.hlsl";
|
||||
DXPixelShaderFile = "shaders/common/lighting/advanced/dbgSpecMapVisualizeP.hlsl";
|
||||
|
||||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgSpecMapVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "matinfoTex";
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
||||
singleton PostEffect( AL_SpecMapVisualize )
|
||||
{
|
||||
shader = AL_SpecMapShader;
|
||||
stateBlock = AL_DefaultVisualizeState;
|
||||
texture[0] = "#matinfo";
|
||||
target = "$backBuffer";
|
||||
renderPriority = 9999;
|
||||
};
|
||||
|
||||
/// Toggles the visualization of the AL lighting specular power buffer.
|
||||
function toggleSpecMapViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_SpecMapShaderVar = AL_SpecMapVisualize.isEnabled() ? false : true;
|
||||
AL_SpecMapVisualize.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_SpecMapVisualize.enable();
|
||||
else if ( !%enable )
|
||||
AL_SpecMapVisualize.disable();
|
||||
}
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ new ShaderData( AL_DepthVisualizeShader )
|
|||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassBuffer";
|
||||
samplerNames[0] = "prepassTex";
|
||||
samplerNames[1] = "depthViz";
|
||||
|
||||
pixVersion = 2.0;
|
||||
|
|
@ -113,7 +113,7 @@ new ShaderData( AL_NormalsVisualizeShader )
|
|||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgNormalVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "prepassBuffer";
|
||||
samplerNames[0] = "prepassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
|
@ -149,7 +149,7 @@ new ShaderData( AL_LightColorVisualizeShader )
|
|||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightColorVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightInfoBuffer";
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
|
@ -184,7 +184,7 @@ new ShaderData( AL_LightSpecularVisualizeShader )
|
|||
OGLVertexShaderFile = "shaders/common/postFx/gl/postFxV.glsl";
|
||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/dbgLightSpecularVisualizeP.glsl";
|
||||
|
||||
samplerNames[0] = "lightInfoBuffer";
|
||||
samplerNames[0] = "lightPrePassTex";
|
||||
|
||||
pixVersion = 2.0;
|
||||
};
|
||||
|
|
@ -280,3 +280,16 @@ function toggleLightSpecularViz( %enable )
|
|||
AL_LightSpecularVisualize.disable();
|
||||
}
|
||||
|
||||
function toggleBackbufferViz( %enable )
|
||||
{
|
||||
if ( %enable $= "" )
|
||||
{
|
||||
$AL_BackbufferVisualizeVar = AL_DeferredShading.isEnabled() ? true : false;
|
||||
AL_DeferredShading.toggle();
|
||||
}
|
||||
else if ( %enable )
|
||||
AL_DeferredShading.disable();
|
||||
else if ( !%enable )
|
||||
AL_DeferredShading.enable();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,11 @@ new GFXStateBlockData( AL_VectorLightState )
|
|||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||
mSamplerNames[0] = "prePassBuffer";
|
||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
|
||||
mSamplerNames[1] = "shadowMap";
|
||||
samplerStates[2] = SamplerClampLinear; // SSAO Mask
|
||||
mSamplerNames[2] = "ssaoMask";
|
||||
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
||||
|
||||
cullDefined = true;
|
||||
|
|
@ -66,7 +69,9 @@ new ShaderData( AL_VectorLightShader )
|
|||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$ssaoMask";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
||||
|
|
@ -78,7 +83,10 @@ new CustomMaterial( AL_VectorLightMaterial )
|
|||
sampler["prePassBuffer"] = "#prepass";
|
||||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["ssaoMask"] = "#ssaoMask";
|
||||
sampler["ssaoMask"] = "#ssaoMask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
|
|
@ -103,7 +111,9 @@ new GFXStateBlockData( AL_ConvexLightState )
|
|||
|
||||
samplersDefined = true;
|
||||
samplerStates[0] = SamplerClampPoint; // G-buffer
|
||||
mSamplerNames[0] = "prePassBuffer";
|
||||
samplerStates[1] = SamplerClampPoint; // Shadow Map (Do not use linear, these are perspective projections)
|
||||
mSamplerNames[1] = "shadowMap";
|
||||
samplerStates[2] = SamplerClampLinear; // Cookie Map
|
||||
samplerStates[3] = SamplerWrapPoint; // Random Direction Map
|
||||
|
||||
|
|
@ -133,6 +143,9 @@ new ShaderData( AL_PointLightShader )
|
|||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$cookieMap";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
|
@ -146,6 +159,9 @@ new CustomMaterial( AL_PointLightMaterial )
|
|||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["cookieMap"] = "$dynamiclightmask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
|
|
@ -166,6 +182,9 @@ new ShaderData( AL_SpotLightShader )
|
|||
samplerNames[2] = "$dynamicShadowMap";
|
||||
samplerNames[3] = "$cookieMap";
|
||||
samplerNames[4] = "$gTapRotationTex";
|
||||
samplerNames[5] = "$lightBuffer";
|
||||
samplerNames[6] = "$colorBuffer";
|
||||
samplerNames[7] = "$matInfoBuffer";
|
||||
|
||||
pixVersion = 3.0;
|
||||
};
|
||||
|
|
@ -179,6 +198,9 @@ new CustomMaterial( AL_SpotLightMaterial )
|
|||
sampler["shadowMap"] = "$dynamiclight";
|
||||
sampler["dynamicShadowMap"] = "$dynamicShadowMap";
|
||||
sampler["cookieMap"] = "$dynamiclightmask";
|
||||
sampler["lightBuffer"] = "#lightinfo";
|
||||
sampler["colorBuffer"] = "#color";
|
||||
sampler["matInfoBuffer"] = "#matinfo";
|
||||
|
||||
target = "lightinfo";
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ function initRenderManager()
|
|||
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(BeginBin) { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );
|
||||
// Normal mesh rendering.
|
||||
DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderTerrainMgr(TerrainBin) { renderOrder = 0.4; processAddOrder = 0.4; basicOnly = true; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(MeshBin) { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; basicOnly = true; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderImposterMgr(ImposterBin) { renderOrder = 0.56; processAddOrder = 0.56; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjectBin) { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );
|
||||
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "./torque.glsl"
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( vec3 wsView,
|
|||
///
|
||||
float AL_CalcSpecular( vec3 toLight, vec3 normal, vec3 toEye )
|
||||
{
|
||||
#ifdef PHONG_SPECULAR
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
#else
|
||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
||||
#endif
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
|
||||
// Return the specular factor.
|
||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||
}
|
||||
|
||||
/// The output for Deferred Lighting
|
||||
///
|
||||
/// @param toLight Normalized vector representing direction from the pixel
|
||||
/// being lit, to the light source, in world space.
|
||||
///
|
||||
/// @param normal Normalized surface normal.
|
||||
///
|
||||
/// @param toEye The normalized vector representing direction from the pixel
|
||||
/// being lit to the camera.
|
||||
///
|
||||
vec4 AL_DeferredOutput(
|
||||
vec3 lightColor,
|
||||
vec3 diffuseColor,
|
||||
vec4 matInfo,
|
||||
vec4 ambient,
|
||||
float specular,
|
||||
float shadowAttenuation)
|
||||
{
|
||||
vec3 specularColor = vec3(specular);
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||
}
|
||||
|
||||
//specular = color * map * spec^gloss
|
||||
float specularOut = (specularColor * matInfo.b * min(pow(max(specular,1.0f), max((matInfo.a / AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||
|
||||
lightColor *= vec3(shadowAttenuation);
|
||||
lightColor += ambient.rgb;
|
||||
return vec4(lightColor.rgb, specularOut);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "./torque.hlsl"
|
||||
|
||||
#ifndef TORQUE_SHADERGEN
|
||||
|
||||
|
|
@ -207,14 +208,42 @@ void compute4Lights( float3 wsView,
|
|||
///
|
||||
float AL_CalcSpecular( float3 toLight, float3 normal, float3 toEye )
|
||||
{
|
||||
#ifdef PHONG_SPECULAR
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
#else
|
||||
// (N.H)^c [Blinn-Phong, TGEA style, default]
|
||||
float specVal = dot( normal, normalize( toLight + toEye ) );
|
||||
#endif
|
||||
// (R.V)^c
|
||||
float specVal = dot( normalize( -reflect( toLight, normal ) ), toEye );
|
||||
|
||||
// Return the specular factor.
|
||||
return pow( max( specVal, 0.00001f ), AL_ConstantSpecularPower );
|
||||
}
|
||||
|
||||
/// The output for Deferred Lighting
|
||||
///
|
||||
/// @param toLight Normalized vector representing direction from the pixel
|
||||
/// being lit, to the light source, in world space.
|
||||
///
|
||||
/// @param normal Normalized surface normal.
|
||||
///
|
||||
/// @param toEye The normalized vector representing direction from the pixel
|
||||
/// being lit to the camera.
|
||||
///
|
||||
float4 AL_DeferredOutput(
|
||||
float3 lightColor,
|
||||
float3 diffuseColor,
|
||||
float4 matInfo,
|
||||
float4 ambient,
|
||||
float specular,
|
||||
float shadowAttenuation)
|
||||
{
|
||||
float3 specularColor = float3(specular, specular, specular);
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
specularColor = 0.04 * (1 - specular) + diffuseColor * specular;
|
||||
}
|
||||
|
||||
//specular = color * map * spec^gloss
|
||||
float specularOut = (specularColor * matInfo.b * min(pow(specular, max(( matInfo.a/ AL_ConstantSpecularPower),1.0f)),matInfo.a)).r;
|
||||
|
||||
lightColor *= shadowAttenuation;
|
||||
lightColor += ambient.rgb;
|
||||
return float4(lightColor.rgb, specularOut);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../postfx/postFx.hlsl"
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D colorBufferTex : register(S0) ) : COLOR0
|
||||
{
|
||||
return float4(tex2D( colorBufferTex, IN.uv0 ).rgb, 1.0);
|
||||
}
|
||||
|
|
@ -27,8 +27,6 @@
|
|||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
||||
{
|
||||
float3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
||||
return float4( lightcolor, 1.0 );
|
||||
float4 lightColor = tex2D( lightPrePassTex, IN.uv0 );
|
||||
return float4( lightColor.rgb, 1.0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D lightPrePassTex : register(S0) ) : COLOR0
|
||||
{
|
||||
float3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( tex2D( lightPrePassTex, IN.uv0 ), lightcolor, nl_Att, specular );
|
||||
float specular = tex2D( lightPrePassTex, IN.uv0 ).a;
|
||||
return float4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../postfx/postFx.hlsl"
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D matinfoTex : register(S0) ) : COLOR0
|
||||
{
|
||||
float specular = tex2D( matinfoTex, IN.uv0 ).b;
|
||||
return float4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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;
|
||||
|
||||
// Clear Prepass Buffer ( Normals/Depth );
|
||||
OUT.col = float4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Clear Color Buffer.
|
||||
OUT.col1 = float4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Clear Material Info Buffer.
|
||||
OUT.col2 = float4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../postfx/postFx.hlsl"
|
||||
#include "shaders/common/torque.hlsl"
|
||||
|
||||
|
||||
float4 main( PFXVertToPix IN,
|
||||
uniform sampler2D colorBufferTex : register(S0),
|
||||
uniform sampler2D lightPrePassTex : register(S1),
|
||||
uniform sampler2D matInfoTex : register(S2),
|
||||
uniform sampler2D prepassTex : register(S3)) : COLOR0
|
||||
{
|
||||
float4 lightBuffer = tex2D( lightPrePassTex, IN.uv0 );
|
||||
float4 colorBuffer = tex2D( colorBufferTex, IN.uv0 );
|
||||
float4 matInfo = tex2D( matInfoTex, IN.uv0 );
|
||||
float specular = saturate(lightBuffer.a);
|
||||
float depth = prepassUncondition( prepassTex, IN.uv0 ).w;
|
||||
|
||||
if (depth>0.9999)
|
||||
return float4(0,0,0,0);
|
||||
|
||||
// Diffuse Color Altered by Metalness
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
colorBuffer *= (1.0 - colorBuffer.a);
|
||||
}
|
||||
|
||||
colorBuffer *= float4(lightBuffer.rgb, 1.0);
|
||||
colorBuffer += float4(specular, specular, specular, 1.0);
|
||||
|
||||
return hdrEncode( float4(colorBuffer.rgb, 1.0) );
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
|
||||
uniform sampler2D colorBufferTex;
|
||||
|
||||
out vec4 OUT_FragColor0;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_FragColor0 = vec4(texture( colorBufferTex, uv0 ).rgb, 1.0);
|
||||
}
|
||||
|
|
@ -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,14 +24,12 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D lightInfoBuffer;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
||||
OUT_col = vec4( lightcolor, 1.0 );
|
||||
vec4 lightColor = texture( lightPrePassTex, uv0 );
|
||||
OUT_col = vec4( lightColor.rgb, 1.0 );
|
||||
}
|
||||
|
|
@ -24,14 +24,12 @@
|
|||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
in vec2 uv0;
|
||||
uniform sampler2D lightInfoBuffer;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 lightcolor;
|
||||
float nl_Att, specular;
|
||||
lightinfoUncondition( texture( lightInfoBuffer, uv0 ), lightcolor, nl_Att, specular );
|
||||
float specular = texture( lightPrePassTex, uv0 ).a;
|
||||
OUT_col = vec4( specular, specular, specular, 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,34 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
|
||||
uniform sampler2D matinfoTex;
|
||||
|
||||
out vec4 OUT_FragColor0;
|
||||
|
||||
void main()
|
||||
{
|
||||
float specular = texture( matinfoTex, uv0 ).a;
|
||||
OUT_FragColor0 = vec4( specular, specular, specular, 1.0 );
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
out vec4 OUT_col;
|
||||
out vec4 OUT_col1;
|
||||
out vec4 OUT_col2;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
void main()
|
||||
{
|
||||
// Clear Prepass Buffer ( Normals/Depth );
|
||||
OUT_col = vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
// Clear Color Buffer.
|
||||
OUT_col1 = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
// Clear Material Info Buffer.
|
||||
OUT_col2 = vec4(0.0, 0.0, 0.0, 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);
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
#include "../../../postfx/gl/postFx.glsl"
|
||||
#include "../../../gl/torque.glsl"
|
||||
|
||||
uniform sampler2D colorBufferTex;
|
||||
uniform sampler2D lightPrePassTex;
|
||||
uniform sampler2D matInfoTex;
|
||||
uniform sampler2D prepassTex;
|
||||
|
||||
out vec4 OUT_col;
|
||||
|
||||
void main()
|
||||
{
|
||||
float depth = prepassUncondition( prepassTex, uv0 ).w;
|
||||
if (depth>0.9999)
|
||||
{
|
||||
OUT_col = vec4(0.0);
|
||||
return;
|
||||
}
|
||||
vec4 lightBuffer = texture( lightPrePassTex, uv0 );
|
||||
vec4 colorBuffer = texture( colorBufferTex, uv0 );
|
||||
vec4 matInfo = texture( matInfoTex, uv0 );
|
||||
float specular = clamp(lightBuffer.a,0.0,1.0);
|
||||
|
||||
// Diffuse Color Altered by Metalness
|
||||
bool metalness = getFlag(matInfo.r, 3);
|
||||
if ( metalness )
|
||||
{
|
||||
colorBuffer *= (1.0 - colorBuffer.a);
|
||||
}
|
||||
|
||||
colorBuffer *= vec4(lightBuffer.rgb, 1.0);
|
||||
colorBuffer += vec4(specular, specular, specular, 1.0);
|
||||
|
||||
OUT_col = hdrEncode( vec4(colorBuffer.rgb, 1.0) );
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@
|
|||
in vec4 wsEyeDir;
|
||||
in vec4 ssPos;
|
||||
in vec4 vsEyeDir;
|
||||
in vec4 color;
|
||||
|
||||
#ifdef USE_COOKIE_TEX
|
||||
|
||||
|
|
@ -111,6 +112,10 @@ uniform sampler2D prePassBuffer;
|
|||
uniform sampler2D dynamicShadowMap;
|
||||
#endif
|
||||
|
||||
uniform sampler2D lightBuffer;
|
||||
uniform sampler2D colorBuffer;
|
||||
uniform sampler2D matInfoBuffer;
|
||||
|
||||
uniform vec4 rtParams0;
|
||||
|
||||
uniform vec3 lightPosition;
|
||||
|
|
@ -133,6 +138,15 @@ void main()
|
|||
vec3 ssPos = ssPos.xyz / ssPos.w;
|
||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||
|
||||
// Emissive.
|
||||
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -244,5 +258,6 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,12 @@
|
|||
in vec4 wsEyeDir;
|
||||
in vec4 ssPos;
|
||||
in vec4 vsEyeDir;
|
||||
in vec4 color;
|
||||
|
||||
#define IN_wsEyeDir wsEyeDir
|
||||
#define IN_ssPos ssPos
|
||||
#define IN_vsEyeDir vsEyeDir
|
||||
#define IN_color color
|
||||
|
||||
#ifdef USE_COOKIE_TEX
|
||||
|
||||
|
|
@ -48,6 +50,10 @@ uniform sampler2D prePassBuffer;
|
|||
uniform sampler2D shadowMap;
|
||||
uniform sampler2D dynamicShadowMap;
|
||||
|
||||
uniform sampler2D lightBuffer;
|
||||
uniform sampler2D colorBuffer;
|
||||
uniform sampler2D matInfoBuffer;
|
||||
|
||||
uniform vec4 rtParams0;
|
||||
|
||||
uniform vec3 lightPosition;
|
||||
|
|
@ -74,6 +80,15 @@ void main()
|
|||
vec3 ssPos = IN_ssPos.xyz / IN_ssPos.w;
|
||||
vec2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||
|
||||
// Emissive.
|
||||
vec4 matInfo = texture( matInfoBuffer, uvScene );
|
||||
bool emissive = getFlag( matInfo.r, 0 );
|
||||
if ( emissive )
|
||||
{
|
||||
OUT_col = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -180,5 +195,6 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
OUT_col = lightinfoCondition( lightColorOut, Sat_NL_Att, specular, addToResult );
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue