本文整理汇总了C++中ITexture::GetNormalDecodeMode方法的典型用法代码示例。如果您正苦于以下问题:C++ ITexture::GetNormalDecodeMode方法的具体用法?C++ ITexture::GetNormalDecodeMode怎么用?C++ ITexture::GetNormalDecodeMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITexture
的用法示例。
在下文中一共展示了ITexture::GetNormalDecodeMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawLightmappedGeneric_DX9_Internal
void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** params, bool hasFlashlight,
IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow,
LightmappedGeneric_DX9_Vars_t &info,
CBasePerMaterialContextData **pContextDataPtr
)
{
CLightmappedGeneric_DX9_Context *pContextData = reinterpret_cast< CLightmappedGeneric_DX9_Context *> ( *pContextDataPtr );
if ( pShaderShadow || ( ! pContextData ) || pContextData->m_bMaterialVarsChanged || hasFlashlight )
{
bool hasBaseTexture = params[info.m_nBaseTexture]->IsTexture();
int nAlphaChannelTextureVar = hasBaseTexture ? (int)info.m_nBaseTexture : (int)info.m_nEnvmapMask;
BlendType_t nBlendType = pShader->EvaluateBlendRequirements( nAlphaChannelTextureVar, hasBaseTexture );
bool bIsAlphaTested = IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) != 0;
bool bFullyOpaqueWithoutAlphaTest = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && (!hasFlashlight || IsX360()); //dest alpha is free for special use
bool bFullyOpaque = bFullyOpaqueWithoutAlphaTest && !bIsAlphaTested;
bool bNeedRegenStaticCmds = (! pContextData ) || pShaderShadow;
if ( ! pContextData ) // make sure allocated
{
pContextData = new CLightmappedGeneric_DX9_Context;
*pContextDataPtr = pContextData;
}
bool hasBump = ( params[info.m_nBumpmap]->IsTexture() ) && ( !g_pHardwareConfig->PreferReducedFillrate() );
bool hasSSBump = hasBump && (info.m_nSelfShadowedBumpFlag != -1) && ( params[info.m_nSelfShadowedBumpFlag]->GetIntValue() );
bool hasBaseTexture2 = hasBaseTexture && params[info.m_nBaseTexture2]->IsTexture();
bool hasLightWarpTexture = params[info.m_nLightWarpTexture]->IsTexture();
bool hasBump2 = hasBump && params[info.m_nBumpmap2]->IsTexture();
bool hasDetailTexture = params[info.m_nDetail]->IsTexture();
bool hasSelfIllum = IS_FLAG_SET( MATERIAL_VAR_SELFILLUM );
bool hasBumpMask = hasBump && hasBump2 && params[info.m_nBumpMask]->IsTexture() && !hasSelfIllum &&
!hasDetailTexture && !hasBaseTexture2 && (params[info.m_nBaseTextureNoEnvmap]->GetIntValue() == 0);
bool bHasBlendModulateTexture =
(info.m_nBlendModulateTexture != -1) &&
(params[info.m_nBlendModulateTexture]->IsTexture() );
bool hasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK );
// Parallax cubemaps
bool hasParallaxCorrection = params[info.m_nEnvmapParallaxObb1]->IsDefined();
if ( hasFlashlight && !IsX360() )
{
// !!speed!! do this in the caller so we don't build struct every time
CBaseVSShader::DrawFlashlight_dx90_Vars_t vars;
vars.m_bBump = hasBump;
vars.m_nBumpmapVar = info.m_nBumpmap;
vars.m_nBumpmapFrame = info.m_nBumpFrame;
vars.m_nBumpTransform = info.m_nBumpTransform;
vars.m_nFlashlightTextureVar = info.m_nFlashlightTexture;
vars.m_nFlashlightTextureFrameVar = info.m_nFlashlightTextureFrame;
vars.m_bLightmappedGeneric = true;
vars.m_bWorldVertexTransition = hasBaseTexture2;
vars.m_nBaseTexture2Var = info.m_nBaseTexture2;
vars.m_nBaseTexture2FrameVar = info.m_nBaseTexture2Frame;
vars.m_nBumpmap2Var = info.m_nBumpmap2;
vars.m_nBumpmap2Frame = info.m_nBumpFrame2;
vars.m_nBump2Transform = info.m_nBumpTransform2;
vars.m_nAlphaTestReference = info.m_nAlphaTestReference;
vars.m_bSSBump = hasSSBump;
vars.m_nDetailVar = info.m_nDetail;
vars.m_nDetailScale = info.m_nDetailScale;
vars.m_nDetailTextureCombineMode = info.m_nDetailTextureCombineMode;
vars.m_nDetailTextureBlendFactor = info.m_nDetailTextureBlendFactor;
vars.m_nDetailTint = info.m_nDetailTint;
if ( ( info.m_nSeamlessMappingScale != -1 ) )
vars.m_fSeamlessScale = params[info.m_nSeamlessMappingScale]->GetFloatValue();
else
vars.m_fSeamlessScale = 0.0;
pShader->DrawFlashlight_dx90( params, pShaderAPI, pShaderShadow, vars );
return;
}
pContextData->m_bFullyOpaque = bFullyOpaque;
pContextData->m_bFullyOpaqueWithoutAlphaTest = bFullyOpaqueWithoutAlphaTest;
NormalDecodeMode_t nNormalDecodeMode = NORMAL_DECODE_NONE;
if ( hasBump && g_pHardwareConfig->SupportsNormalMapCompression() && g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
ITexture *pBumpTex = params[info.m_nBumpmap]->GetTextureValue();
if ( pBumpTex )
{
nNormalDecodeMode = pBumpTex->GetNormalDecodeMode();
if ( hasBump2 ) // Check encoding of secondary normal if there is oneg
{
ITexture *pBumpTex2 = params[info.m_nBumpmap]->GetTextureValue();
if ( pBumpTex2 && ( pBumpTex2->GetNormalDecodeMode() != nNormalDecodeMode ) )
{
DevMsg("LightmappedGeneric: Primary and Secondary normal map compression formats don't match. This is unsupported!\n");
Assert(0);
}
}
}
}
int nNormalMaskDecodeMode = 0;
if ( hasBumpMask && g_pHardwareConfig->SupportsNormalMapCompression() && g_pHardwareConfig->SupportsPixelShaders_2_b() )
{
ITexture *pBumpMaskTex = params[info.m_nBumpMask]->GetTextureValue();
//.........这里部分代码省略.........
示例2: DrawRefract_DX9
void DrawRefract_DX9( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI,
IShaderShadow* pShaderShadow, Refract_DX9_Vars_t &info, VertexCompressionType_t vertexCompression )
{
bool bIsModel = IS_FLAG_SET( MATERIAL_VAR_MODEL );
bool bHasEnvmap = params[info.m_nEnvmap]->IsTexture();
bool bRefractTintTexture = params[info.m_nRefractTintTexture]->IsTexture();
bool bFadeOutOnSilhouette = params[info.m_nFadeOutOnSilhouette]->GetIntValue() != 0;
int blurAmount = params[info.m_nBlurAmount]->GetIntValue();
bool bMasked = (params[info.m_nMasked]->GetIntValue() != 0);
bool bSecondaryNormal = ( ( info.m_nNormalMap2 != -1 ) && ( params[info.m_nNormalMap2]->IsTexture() ) );
bool bColorModulate = ( ( info.m_nVertexColorModulate != -1 ) && ( params[info.m_nVertexColorModulate]->GetIntValue() ) );
bool bWriteZ = params[info.m_nNoWriteZ]->GetIntValue() == 0;
if( blurAmount < 0 )
{
blurAmount = 0;
}
else if( blurAmount > MAXBLUR )
{
blurAmount = MAXBLUR;
}
BlendType_t nBlendType = pShader->EvaluateBlendRequirements( BASETEXTURE, true );
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !IS_FLAG_SET(MATERIAL_VAR_ALPHATEST); //dest alpha is free for special use
bFullyOpaque &= !bMasked;
bool bTranslucentNormal = pShader->TextureIsTranslucent( info.m_nNormalMap, false );
bFullyOpaque &= (! bTranslucentNormal );
NormalDecodeMode_t nNormalDecodeMode = NORMAL_DECODE_NONE;
if ( g_pHardwareConfig->SupportsNormalMapCompression() )
{
ITexture *pBumpTex = params[info.m_nNormalMap]->GetTextureValue();
if ( pBumpTex )
{
nNormalDecodeMode = pBumpTex->GetNormalDecodeMode();
if ( bSecondaryNormal ) // Check encoding of secondary normal if there is one
{
ITexture *pBumpTex2 = params[info.m_nNormalMap2]->GetTextureValue();
if ( pBumpTex2 && ( pBumpTex2->GetNormalDecodeMode() != nNormalDecodeMode ) )
{
DevMsg("Refract: Primary and Secondary normal map compression formats don't match. This is unsupported!\n");
Assert(0);
}
}
}
}
SHADOW_STATE
{
pShader->SetInitialShadowState( );
pShaderShadow->EnableDepthWrites( bWriteZ );
// Alpha test: FIXME: shouldn't this be handled in Shader_t::SetInitialShadowState
pShaderShadow->EnableAlphaTest( IS_FLAG_SET(MATERIAL_VAR_ALPHATEST) );
// If envmap is not specified, the alpha channel is the translucency
// (If envmap *is* specified, alpha channel is the reflection amount)
if ( params[info.m_nNormalMap]->IsTexture() && !bHasEnvmap )
{
pShader->SetDefaultBlendingShadowState( info.m_nNormalMap, false );
}
// source render target that contains the image that we are warping.
pShaderShadow->EnableTexture( SHADER_SAMPLER2, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER2, true );
// normal map
pShaderShadow->EnableTexture( SHADER_SAMPLER3, true );
if ( nNormalDecodeMode == NORMAL_DECODE_ATI2N_ALPHA )
{
pShaderShadow->EnableTexture( SHADER_SAMPLER6, true ); // Normal map alpha, in the compressed normal case
}
if ( bSecondaryNormal )
{
pShaderShadow->EnableTexture( SHADER_SAMPLER1, true );
if ( nNormalDecodeMode == NORMAL_DECODE_ATI2N_ALPHA )
{
pShaderShadow->EnableTexture( SHADER_SAMPLER7, true ); // Secondary normal map alpha, in the compressed normal case
}
}
if( bHasEnvmap )
{
// envmap
pShaderShadow->EnableTexture( SHADER_SAMPLER4, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER4, true );
}
if( bRefractTintTexture )
{
// refract tint texture
pShaderShadow->EnableTexture( SHADER_SAMPLER5, true );
pShaderShadow->EnableSRGBRead( SHADER_SAMPLER5, true );
}
pShaderShadow->EnableSRGBWrite( true );
//.........这里部分代码省略.........