mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Merge pull request #710 from lukaspj/3-Textures-Blending-Fix
3 textures blending fix
This commit is contained in:
commit
9e4446046f
4 changed files with 15 additions and 6 deletions
|
|
@ -446,7 +446,7 @@ void TerrainDetailMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to the blend total.
|
// Add to the blend total.
|
||||||
meta->addStatement( new GenOp( " @ = max( @, @ );\r\n", blendTotal, blendTotal, detailBlend ) );
|
meta->addStatement( new GenOp( " @ += @;\r\n", blendTotal, detailBlend ) );
|
||||||
|
|
||||||
// If we had a parallax feature... then factor in the parallax
|
// If we had a parallax feature... then factor in the parallax
|
||||||
// amount so that it fades out with the layer blending.
|
// amount so that it fades out with the layer blending.
|
||||||
|
|
|
||||||
|
|
@ -170,9 +170,10 @@ bool TerrainBlock::_initBaseShader()
|
||||||
desc.zDefined = true;
|
desc.zDefined = true;
|
||||||
desc.zWriteEnable = false;
|
desc.zWriteEnable = false;
|
||||||
desc.zEnable = false;
|
desc.zEnable = false;
|
||||||
desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha );
|
desc.setBlend( true, GFXBlendSrcAlpha, GFXBlendOne );
|
||||||
desc.cullDefined = true;
|
desc.cullDefined = true;
|
||||||
desc.cullMode = GFXCullNone;
|
desc.cullMode = GFXCullNone;
|
||||||
|
desc.colorWriteAlpha = false;
|
||||||
mBaseShaderSB = GFX->createStateBlock( desc );
|
mBaseShaderSB = GFX->createStateBlock( desc );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -251,6 +252,8 @@ void TerrainBlock::_updateBaseTexture(bool writeToCache)
|
||||||
mBaseTarget->attachTexture( GFXTextureTarget::Color0, blendTex );
|
mBaseTarget->attachTexture( GFXTextureTarget::Color0, blendTex );
|
||||||
GFX->setActiveRenderTarget( mBaseTarget );
|
GFX->setActiveRenderTarget( mBaseTarget );
|
||||||
|
|
||||||
|
GFX->clear( GFXClearTarget, ColorI(0,0,0,255), 1.0f, 0 );
|
||||||
|
|
||||||
GFX->setTexture( 0, mLayerTex );
|
GFX->setTexture( 0, mLayerTex );
|
||||||
mBaseShaderConsts->setSafe( mBaseLayerSizeConst, (F32)mLayerTex->getWidth() );
|
mBaseShaderConsts->setSafe( mBaseLayerSizeConst, (F32)mLayerTex->getWidth() );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,12 @@ float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSa
|
||||||
float4 diff = saturate( abs( layerSample - texId ) );
|
float4 diff = saturate( abs( layerSample - texId ) );
|
||||||
float noBlend = any( 1 - diff );
|
float noBlend = any( 1 - diff );
|
||||||
|
|
||||||
// Use step to see if any of the layer samples
|
// Check if any of the layer samples
|
||||||
// match the current texture id.
|
// match the current texture id.
|
||||||
float4 factors = step( texId, layerSample );
|
float4 factors = 0;
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
if(layerSample[i] == texId)
|
||||||
|
factors[i] = 1;
|
||||||
|
|
||||||
// This is a custom bilinear filter.
|
// This is a custom bilinear filter.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,12 @@ float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSa
|
||||||
float4 diff = saturate( abs( layerSample - texId ) );
|
float4 diff = saturate( abs( layerSample - texId ) );
|
||||||
float noBlend = any( 1 - diff );
|
float noBlend = any( 1 - diff );
|
||||||
|
|
||||||
// Use step to see if any of the layer samples
|
// Check if any of the layer samples
|
||||||
// match the current texture id.
|
// match the current texture id.
|
||||||
float4 factors = step( texId, layerSample );
|
float4 factors = 0;
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
if(layerSample[i] == texId)
|
||||||
|
factors[i] = 1;
|
||||||
|
|
||||||
// This is a custom bilinear filter.
|
// This is a custom bilinear filter.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue