mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-29 16:25:42 +00:00
Merge pull request #719 from rextimmy/dxtnm-parallax-fix
Fix to allow parallax mapping with dxtnm textures via the red channel.
This commit is contained in:
commit
95ab3a33a5
5 changed files with 52 additions and 8 deletions
|
|
@ -151,6 +151,21 @@ float2 parallaxOffset( sampler2D texMap, float2 texCoord, float3 negViewTS, floa
|
|||
return offset;
|
||||
}
|
||||
|
||||
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
|
||||
float2 parallaxOffsetDxtnm(sampler2D texMap, float2 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = tex2D(texMap, texCoord).r;
|
||||
float2 offset = negViewTS.xy * (depth * depthScale);
|
||||
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = (depth + tex2D(texMap, texCoord + offset).r) * 0.5;
|
||||
offset = negViewTS.xy * (depth * depthScale);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/// The maximum value for 16bit per component integer HDR encoding.
|
||||
static const float HDR_RGB16_MAX = 100.0;
|
||||
|
|
|
|||
|
|
@ -151,6 +151,21 @@ float2 parallaxOffset( sampler2D texMap, float2 texCoord, float3 negViewTS, floa
|
|||
return offset;
|
||||
}
|
||||
|
||||
/// Same as parallaxOffset but for dxtnm where depth is stored in the red channel instead of the alpha
|
||||
float2 parallaxOffsetDxtnm(sampler2D texMap, float2 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = tex2D(texMap, texCoord).r;
|
||||
float2 offset = negViewTS.xy * (depth * depthScale);
|
||||
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = (depth + tex2D(texMap, texCoord + offset).r) * 0.5;
|
||||
offset = negViewTS.xy * (depth * depthScale);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/// The maximum value for 16bit per component integer HDR encoding.
|
||||
static const float HDR_RGB16_MAX = 100.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue