mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 23:54:35 +00:00
Merge pull request #147 from Azaezel/alpha40_TranslucentShadows
adds alphatest shadows for translucent objects
This commit is contained in:
commit
0e006b2264
8 changed files with 14 additions and 8 deletions
|
|
@ -704,7 +704,7 @@ void ConvexShape::prepRenderImage( SceneRenderState *state )
|
||||||
|
|
||||||
// Set our Material
|
// Set our Material
|
||||||
ri->matInst = matInst;
|
ri->matInst = matInst;
|
||||||
if (matInst->getMaterial()->isTranslucent())
|
if (matInst->getMaterial()->isTranslucent() && (!(matInst->getMaterial()->isAlphatest() && state->isShadowPass())))
|
||||||
{
|
{
|
||||||
ri->translucentSort = true;
|
ri->translucentSort = true;
|
||||||
ri->type = RenderPassManager::RIT_Translucent;
|
ri->type = RenderPassManager::RIT_Translucent;
|
||||||
|
|
|
||||||
|
|
@ -260,7 +260,7 @@ void ShadowRenderPassManager::addInst( RenderInst *inst )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const BaseMaterialDefinition *mat = meshRI->matInst->getMaterial();
|
const BaseMaterialDefinition *mat = meshRI->matInst->getMaterial();
|
||||||
if ( !mat->castsShadows() || mat->isTranslucent() )
|
if ( !mat->castsShadows() || (mat->isTranslucent() && !mat->isAlphatest()))
|
||||||
{
|
{
|
||||||
// Do not add this instance, return here and avoid the default behavior
|
// Do not add this instance, return here and avoid the default behavior
|
||||||
// of calling up to Parent::addInst()
|
// of calling up to Parent::addInst()
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,8 @@ void ShadowMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
|
||||||
fd.features.removeFeature( MFT_TexAnim );
|
fd.features.removeFeature( MFT_TexAnim );
|
||||||
fd.features.removeFeature( MFT_DiffuseMap );
|
fd.features.removeFeature( MFT_DiffuseMap );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
fd.features.removeFeature(MFT_IsTranslucent);
|
||||||
|
|
||||||
// HACK: Need to figure out how to enable these
|
// HACK: Need to figure out how to enable these
|
||||||
// suckers without this override call!
|
// suckers without this override call!
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public:
|
||||||
virtual bool isDoubleSided() const = 0;
|
virtual bool isDoubleSided() const = 0;
|
||||||
virtual bool isLightmapped() const = 0;
|
virtual bool isLightmapped() const = 0;
|
||||||
virtual bool castsShadows() const = 0;
|
virtual bool castsShadows() const = 0;
|
||||||
|
virtual bool isAlphatest() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BASEMATERIALDEFINITION_H_
|
#endif // _BASEMATERIALDEFINITION_H_
|
||||||
|
|
|
||||||
|
|
@ -396,6 +396,7 @@ public:
|
||||||
/// for freeing the instance
|
/// for freeing the instance
|
||||||
virtual BaseMatInstance* createMatInstance();
|
virtual BaseMatInstance* createMatInstance();
|
||||||
virtual bool isTranslucent() const { return mTranslucent && mTranslucentBlendOp != Material::None; }
|
virtual bool isTranslucent() const { return mTranslucent && mTranslucentBlendOp != Material::None; }
|
||||||
|
virtual bool isAlphatest() const { return mAlphaTest; }
|
||||||
virtual bool isDoubleSided() const { return mDoubleSided; }
|
virtual bool isDoubleSided() const { return mDoubleSided; }
|
||||||
virtual bool isAutoGenerated() const { return mAutoGenerated; }
|
virtual bool isAutoGenerated() const { return mAutoGenerated; }
|
||||||
virtual void setAutoGenerated(bool isAutoGenerated) { mAutoGenerated = isAutoGenerated; }
|
virtual void setAutoGenerated(bool isAutoGenerated) { mAutoGenerated = isAutoGenerated; }
|
||||||
|
|
|
||||||
|
|
@ -2496,9 +2496,10 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
{
|
{
|
||||||
// If we're below SM3 and don't have a depth output
|
// If we're below SM3 and don't have a depth output
|
||||||
// feature then don't waste an instruction here.
|
// feature then don't waste an instruction here.
|
||||||
if ( GFX->getPixelShaderVersion() < 3.0 &&
|
if (( GFX->getPixelShaderVersion() < 3.0 &&
|
||||||
!fd.features[ MFT_EyeSpaceDepthOut ] &&
|
!fd.features[ MFT_EyeSpaceDepthOut ] &&
|
||||||
!fd.features[ MFT_DepthOut ] )
|
!fd.features[ MFT_DepthOut ] ) ||
|
||||||
|
fd.features[MFT_IsTranslucent])
|
||||||
{
|
{
|
||||||
output = NULL;
|
output = NULL;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -2565,9 +2565,10 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
{
|
{
|
||||||
// If we're below SM3 and don't have a depth output
|
// If we're below SM3 and don't have a depth output
|
||||||
// feature then don't waste an instruction here.
|
// feature then don't waste an instruction here.
|
||||||
if ( GFX->getPixelShaderVersion() < 3.0 &&
|
if (( GFX->getPixelShaderVersion() < 3.0 &&
|
||||||
!fd.features[ MFT_EyeSpaceDepthOut ] &&
|
!fd.features[ MFT_EyeSpaceDepthOut ] &&
|
||||||
!fd.features[ MFT_DepthOut ] )
|
!fd.features[ MFT_DepthOut ] ) ||
|
||||||
|
fd.features[MFT_IsTranslucent])
|
||||||
{
|
{
|
||||||
output = NULL;
|
output = NULL;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,7 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata,
|
||||||
ri->primBuffIndex = mPrimBufferOffset + i;
|
ri->primBuffIndex = mPrimBufferOffset + i;
|
||||||
|
|
||||||
// Translucent materials need the translucent type.
|
// Translucent materials need the translucent type.
|
||||||
if ( matInst->getMaterial()->isTranslucent() )
|
if ( matInst->getMaterial()->isTranslucent() && (!(matInst->getMaterial()->isAlphatest() && state->isShadowPass())))
|
||||||
{
|
{
|
||||||
ri->type = RenderPassManager::RIT_Translucent;
|
ri->type = RenderPassManager::RIT_Translucent;
|
||||||
ri->translucentSort = true;
|
ri->translucentSort = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue