materialsystem: fix s_NormalizationCubemap generation for ToGL
This commit is contained in:
parent
e1206f5c46
commit
432a6b2297
@ -1117,8 +1117,6 @@ void WriteRemoteVProfGroupData( VProfListenInfo_t &info )
|
|||||||
const char *pName = g_pVProfileForDisplay->GetBudgetGroupName( nIndex );
|
const char *pName = g_pVProfileForDisplay->GetBudgetGroupName( nIndex );
|
||||||
buf.PutString( pName );
|
buf.PutString( pName );
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ServerRemoteAccess.SendVProfData( info.m_nListenerId, true, buf.Base(), buf.TellMaxPut() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ConVar rpt_vprof_time( "rpt_vprof_time","0.25", FCVAR_HIDDEN | FCVAR_DONTRECORD, "" );
|
static ConVar rpt_vprof_time( "rpt_vprof_time","0.25", FCVAR_HIDDEN | FCVAR_DONTRECORD, "" );
|
||||||
@ -1167,7 +1165,6 @@ void WriteRemoteVProfData()
|
|||||||
Assert( nIndex >= 0 );
|
Assert( nIndex >= 0 );
|
||||||
pSentTimes[ nIndex ] = pTimes[j];
|
pSentTimes[ nIndex ] = pTimes[j];
|
||||||
}
|
}
|
||||||
g_ServerRemoteAccess.SendVProfData( s_VProfListeners[i].m_nListenerId, false, pSentTimes, nSentSize );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,16 +201,22 @@ float4 main( PS_INPUT i ) : COLOR
|
|||||||
|
|
||||||
#if NORMALMAP == 0
|
#if NORMALMAP == 0
|
||||||
float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f;
|
float3 worldPosToLightVector = texCUBE( NormalizingCubemapSampler, i.worldPosToLightVector ) * 2.0f - 1.0f;
|
||||||
float nDotL = 0.577350f;
|
float nDotL = dot( worldPosToLightVector, vNormal.xyz );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NORMALMAP == 1
|
#if NORMALMAP == 1
|
||||||
// flashlightfixme: wrap this!
|
// flashlightfixme: wrap this!
|
||||||
float nDotL = 0.577350f;
|
float3 tangentPosToLightVector = texCUBE( NormalizingCubemapSampler, i.tangentPosToLightVector ) * 2.0f - 1.0f;
|
||||||
|
float nDotL = dot( tangentPosToLightVector, vNormal.xyz );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if NORMALMAP == 2
|
#if NORMALMAP == 2
|
||||||
float nDotL = 0.577350f;
|
float3 tangentPosToLightVector = normalize( i.tangentPosToLightVector );
|
||||||
|
|
||||||
|
float nDotL =
|
||||||
|
vNormal.x*dot( tangentPosToLightVector, bumpBasis[0]) +
|
||||||
|
vNormal.y*dot( tangentPosToLightVector, bumpBasis[1]) +
|
||||||
|
vNormal.z*dot( tangentPosToLightVector, bumpBasis[2]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float3 outColor;
|
float3 outColor;
|
||||||
|
@ -250,9 +250,6 @@ static void CreateSolidTexture( ITextureInternal *pTexture, color32 color )
|
|||||||
class CNormalizationCubemap : public ITextureRegenerator
|
class CNormalizationCubemap : public ITextureRegenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// TODO(nillerusr): broken here with togl /= (maybe here)
|
|
||||||
|
|
||||||
virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pSubRect )
|
virtual void RegenerateTextureBits( ITexture *pTexture, IVTFTexture *pVTFTexture, Rect_t *pSubRect )
|
||||||
{
|
{
|
||||||
// Normalization cubemap doesn't make sense on low-end hardware
|
// Normalization cubemap doesn't make sense on low-end hardware
|
||||||
@ -280,7 +277,39 @@ public:
|
|||||||
{
|
{
|
||||||
float u = x * flInvWidth - 1.0f;
|
float u = x * flInvWidth - 1.0f;
|
||||||
float oow = 1.0f / sqrt( 1.0f + u*u + v*v );
|
float oow = 1.0f / sqrt( 1.0f + u*u + v*v );
|
||||||
|
#ifdef DX_TO_GL_ABSTRACTION
|
||||||
|
float flX = (255.0f * 0.5 * (u*oow + 1.0f) + 0.5f);
|
||||||
|
float flY = (255.0f * 0.5 * (v*oow + 1.0f) + 0.5f);
|
||||||
|
float flZ = (255.0f * 0.5 * (oow + 1.0f) + 0.5f);
|
||||||
|
|
||||||
|
flX /= 256.0f;
|
||||||
|
flY /= 256.0f;
|
||||||
|
flZ /= 256.0f;
|
||||||
|
|
||||||
|
switch (iFace)
|
||||||
|
{
|
||||||
|
case CUBEMAP_FACE_RIGHT:
|
||||||
|
pixelWriter.WritePixelF( flZ, 1.f - flY, 1.f - flX, 1.f );
|
||||||
|
break;
|
||||||
|
case CUBEMAP_FACE_LEFT:
|
||||||
|
pixelWriter.WritePixelF( 1.f - flZ, 1.f - flY, flX, 1.f );
|
||||||
|
break;
|
||||||
|
case CUBEMAP_FACE_BACK:
|
||||||
|
pixelWriter.WritePixelF( flX, flZ, flY, 1.f );
|
||||||
|
break;
|
||||||
|
case CUBEMAP_FACE_FRONT:
|
||||||
|
pixelWriter.WritePixelF( flX, 1.f - flZ, 1.f - flY, 1.f );
|
||||||
|
break;
|
||||||
|
case CUBEMAP_FACE_UP:
|
||||||
|
pixelWriter.WritePixelF( flX, 1.f - flY, flZ, 1.f );
|
||||||
|
break;
|
||||||
|
case CUBEMAP_FACE_DOWN:
|
||||||
|
pixelWriter.WritePixelF( 1.f - flX, 1.f - flY, 1.f - flZ, 1.f );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
int ix = (int)(255.0f * 0.5f * (u*oow + 1.0f) + 0.5f);
|
int ix = (int)(255.0f * 0.5f * (u*oow + 1.0f) + 0.5f);
|
||||||
ix = clamp( ix, 0, 255 );
|
ix = clamp( ix, 0, 255 );
|
||||||
int iy = (int)(255.0f * 0.5f * (v*oow + 1.0f) + 0.5f);
|
int iy = (int)(255.0f * 0.5f * (v*oow + 1.0f) + 0.5f);
|
||||||
@ -311,6 +340,7 @@ public:
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1501,13 +1531,16 @@ void CTextureManager::Init( int nFlags )
|
|||||||
color.a = 0;
|
color.a = 0;
|
||||||
CreateSolidTexture( m_pGreyAlphaZeroTexture, color );
|
CreateSolidTexture( m_pGreyAlphaZeroTexture, color );
|
||||||
|
|
||||||
|
int nTextureFlags = TEXTUREFLAGS_ENVMAP | TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_NOLOD | TEXTUREFLAGS_SINGLECOPY | TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT | TEXTUREFLAGS_CLAMPU;
|
||||||
|
|
||||||
if ( HardwareConfig()->GetMaxDXSupportLevel() >= 80 )
|
if ( HardwareConfig()->GetMaxDXSupportLevel() >= 80 )
|
||||||
{
|
{
|
||||||
|
ImageFormat fmt = IsOpenGL() ? IMAGE_FORMAT_RGBA16161616F : IMAGE_FORMAT_BGRX8888;
|
||||||
|
|
||||||
// Create a normalization cubemap
|
// Create a normalization cubemap
|
||||||
m_pNormalizationCubemap = CreateProceduralTexture( "normalize", TEXTURE_GROUP_CUBE_MAP,
|
m_pNormalizationCubemap = CreateProceduralTexture( "normalize", TEXTURE_GROUP_CUBE_MAP,
|
||||||
NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, IMAGE_FORMAT_BGRX8888,
|
NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, fmt,
|
||||||
TEXTUREFLAGS_ENVMAP | TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_SINGLECOPY |
|
nTextureFlags );
|
||||||
TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT | TEXTUREFLAGS_CLAMPU );
|
|
||||||
CreateNormalizationCubemap( m_pNormalizationCubemap );
|
CreateNormalizationCubemap( m_pNormalizationCubemap );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1516,7 +1549,6 @@ void CTextureManager::Init( int nFlags )
|
|||||||
// In GL, we have poor format support, so we ask for signed float
|
// In GL, we have poor format support, so we ask for signed float
|
||||||
ImageFormat fmt = IsOpenGL() ? IMAGE_FORMAT_RGBA16161616F : IMAGE_FORMAT_UVWQ8888;
|
ImageFormat fmt = IsOpenGL() ? IMAGE_FORMAT_RGBA16161616F : IMAGE_FORMAT_UVWQ8888;
|
||||||
|
|
||||||
int nTextureFlags = TEXTUREFLAGS_ENVMAP | TEXTUREFLAGS_NOMIP | TEXTUREFLAGS_NOLOD | TEXTUREFLAGS_SINGLECOPY | TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT | TEXTUREFLAGS_CLAMPU;
|
|
||||||
|
|
||||||
#ifdef OSX
|
#ifdef OSX
|
||||||
// JasonM - ridiculous hack around R500 lameness...we never use this texture on OSX anyways (right?)
|
// JasonM - ridiculous hack around R500 lameness...we never use this texture on OSX anyways (right?)
|
||||||
@ -1528,7 +1560,7 @@ void CTextureManager::Init( int nFlags )
|
|||||||
m_pSignedNormalizationCubemap = CreateProceduralTexture( "normalizesigned", TEXTURE_GROUP_CUBE_MAP,
|
m_pSignedNormalizationCubemap = CreateProceduralTexture( "normalizesigned", TEXTURE_GROUP_CUBE_MAP,
|
||||||
NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, fmt, nTextureFlags );
|
NORMALIZATION_CUBEMAP_SIZE, NORMALIZATION_CUBEMAP_SIZE, 1, fmt, nTextureFlags );
|
||||||
CreateSignedNormalizationCubemap( m_pSignedNormalizationCubemap );
|
CreateSignedNormalizationCubemap( m_pSignedNormalizationCubemap );
|
||||||
|
|
||||||
m_pIdentityLightWarp = FindOrLoadTexture( "dev/IdentityLightWarp", TEXTURE_GROUP_OTHER );
|
m_pIdentityLightWarp = FindOrLoadTexture( "dev/IdentityLightWarp", TEXTURE_GROUP_OTHER );
|
||||||
m_pIdentityLightWarp->IncrementReferenceCount();
|
m_pIdentityLightWarp->IncrementReferenceCount();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user