mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
commit
0e42172651
4 changed files with 54 additions and 8 deletions
|
|
@ -347,8 +347,16 @@ void ParallaxFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
Var *normalMap = getNormalMapTex();
|
Var *normalMap = getNormalMapTex();
|
||||||
|
|
||||||
// Call the library function to do the rest.
|
// Call the library function to do the rest.
|
||||||
meta->addStatement( new GenOp( " @.xy += parallaxOffset( @, @.xy, @, @ );\r\n",
|
if (fd.features.hasFeature(MFT_IsDXTnm, getProcessIndex()))
|
||||||
texCoord, normalMap, texCoord, negViewTS, parallaxInfo ) );
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @.xy, @, @ );\r\n",
|
||||||
|
texCoord, normalMap, texCoord, negViewTS, parallaxInfo));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, @.xy, @, @ );\r\n",
|
||||||
|
texCoord, normalMap, texCoord, negViewTS, parallaxInfo));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Fix second UV maybe?
|
// TODO: Fix second UV maybe?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -468,8 +468,16 @@ void TerrainDetailMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
Var *normalMap = _getNormalMapTex();
|
Var *normalMap = _getNormalMapTex();
|
||||||
|
|
||||||
// Call the library function to do the rest.
|
// Call the library function to do the rest.
|
||||||
meta->addStatement( new GenOp( " @.xy += parallaxOffset( @, @.xy, @, @.z * @ );\r\n",
|
if (fd.features.hasFeature(MFT_IsDXTnm, detailIndex))
|
||||||
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend ) );
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @.xy, @, @.z * @ );\r\n",
|
||||||
|
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, @.xy, @, @.z * @ );\r\n",
|
||||||
|
inDet, normalMap, inDet, negViewTS, detailInfo, detailBlend));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is a prepass then we skip color.
|
// If this is a prepass then we skip color.
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,27 @@ mat3x3 quatToMat( vec4 quat )
|
||||||
vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale )
|
vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale )
|
||||||
{
|
{
|
||||||
float depth = texture( texMap, texCoord ).a;
|
float depth = texture( texMap, texCoord ).a;
|
||||||
vec2 offset = negViewTS.xy * ( depth * depthScale );
|
vec2 offset = negViewTS.xy * vec2( depth * depthScale );
|
||||||
|
|
||||||
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
||||||
{
|
{
|
||||||
depth = ( depth + texture( texMap, texCoord + offset ).a ) * 0.5;
|
depth = ( depth + texture( texMap, texCoord + offset ).a ) * 0.5;
|
||||||
offset = negViewTS.xy * ( depth * depthScale );
|
offset = negViewTS.xy * vec2( depth * depthScale );
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
|
||||||
|
vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale)
|
||||||
|
{
|
||||||
|
float depth = texture(texMap, texCoord).r;
|
||||||
|
vec2 offset = negViewTS.xy * vec2(depth * depthScale);
|
||||||
|
|
||||||
|
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||||
|
{
|
||||||
|
depth = (depth + texture(texMap, texCoord + offset).r) * 0.5;
|
||||||
|
offset = negViewTS.xy * vec2(depth * depthScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
||||||
|
|
@ -139,12 +139,27 @@ mat3x3 quatToMat( vec4 quat )
|
||||||
vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale )
|
vec2 parallaxOffset( sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale )
|
||||||
{
|
{
|
||||||
float depth = texture( texMap, texCoord ).a;
|
float depth = texture( texMap, texCoord ).a;
|
||||||
vec2 offset = negViewTS.xy * ( depth * depthScale );
|
vec2 offset = negViewTS.xy * vec2( depth * depthScale );
|
||||||
|
|
||||||
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
||||||
{
|
{
|
||||||
depth = ( depth + texture( texMap, texCoord + offset ).a ) * 0.5;
|
depth = ( depth + texture( texMap, texCoord + offset ).a ) * 0.5;
|
||||||
offset = negViewTS.xy * ( depth * depthScale );
|
offset = negViewTS.xy * vec2( depth * depthScale );
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
|
||||||
|
vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float depthScale)
|
||||||
|
{
|
||||||
|
float depth = texture(texMap, texCoord).r;
|
||||||
|
vec2 offset = negViewTS.xy * vec2(depth * depthScale);
|
||||||
|
|
||||||
|
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||||
|
{
|
||||||
|
depth = (depth + texture(texMap, texCoord + offset).r) * 0.5;
|
||||||
|
offset = negViewTS.xy * vec2(depth * depthScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue