mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-20 04:34:48 +00:00
Update core shader libraries to support texture arrays
This commit is contained in:
parent
3c8d07a03e
commit
6f23dd191d
|
|
@ -166,6 +166,35 @@ vec2 parallaxOffsetDxtnm(sampler2D texMap, vec2 texCoord, vec3 negViewTS, float
|
|||
return offset;
|
||||
}
|
||||
|
||||
/// Same as the above but for arrays
|
||||
vec2 parallaxOffset( sampler2DArray texMap, vec3 texCoord, vec3 negViewTS, float depthScale )
|
||||
{
|
||||
float depth = texture( texMap, texCoord ).a/(PARALLAX_REFINE_STEPS*2);
|
||||
vec2 offset = negViewTS.xy * vec2( depth * depthScale )/vec2(PARALLAX_REFINE_STEPS*2);
|
||||
|
||||
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
||||
{
|
||||
depth = ( depth + texture( texMap, texCoord + vec3(offset, 0.0) ).a )/(PARALLAX_REFINE_STEPS*2);
|
||||
offset = negViewTS.xy * vec2( depth * depthScale )/vec2(PARALLAX_REFINE_STEPS*2);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
vec2 parallaxOffsetDxtnm(sampler2DArray texMap, vec3 texCoord, vec3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = texture(texMap, texCoord).r/(PARALLAX_REFINE_STEPS*2);
|
||||
vec2 offset = negViewTS.xy * vec2(depth * depthScale)/vec2(PARALLAX_REFINE_STEPS*2);
|
||||
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = (depth + texture(texMap, texCoord + vec3(offset, 0.0)).r)/(PARALLAX_REFINE_STEPS*2);
|
||||
offset = negViewTS.xy * vec2(depth * depthScale)/vec2(PARALLAX_REFINE_STEPS*2);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/// The maximum value for 10bit per component integer HDR encoding.
|
||||
const float HDR_RGB10_MAX = 4.0;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
//helper if you want to pass sampler/texture in a function
|
||||
//2D
|
||||
#define TORQUE_SAMPLER2D(tex) Texture2D texture_##tex, SamplerState tex
|
||||
#define TORQUE_SAMPLER2DARRAY(tex) Texture2DArray texture_##tex, SamplerState tex
|
||||
#define TORQUE_SAMPLER2D_MAKEARG(tex) texture_##tex, tex
|
||||
// Sampler comparison state - use above MAKEARG with this
|
||||
#define TORQUE_SAMPLER2DCMP(tex) Texture2D texture_##tex, SamplerComparisonState tex
|
||||
|
|
|
|||
|
|
@ -167,6 +167,35 @@ float2 parallaxOffsetDxtnm(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 neg
|
|||
return offset;
|
||||
}
|
||||
|
||||
/// Copy of the above to functions, but for arrays
|
||||
float2 parallaxOffsetTexArray(TORQUE_SAMPLER2DARRAY(texMap), float3 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = TORQUE_TEX2D(texMap, texCoord).a/(PARALLAX_REFINE_STEPS*2);
|
||||
float2 offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS);
|
||||
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = (depth + TORQUE_TEX2D(texMap, texCoord + float3(offset, 0.0)).a)/(PARALLAX_REFINE_STEPS*2);
|
||||
offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
float2 parallaxOffsetDxtnmTexArray(TORQUE_SAMPLER2DARRAY(texMap), float3 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = TORQUE_TEX2D(texMap, texCoord).r/(PARALLAX_REFINE_STEPS*2);
|
||||
float2 offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS*2);
|
||||
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = (depth + TORQUE_TEX2D(texMap, texCoord + float3(offset, 0.0)).r)/(PARALLAX_REFINE_STEPS*2);
|
||||
offset = negViewTS.xy * (depth * depthScale)/(PARALLAX_REFINE_STEPS*2);
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
/// The maximum value for 10bit per component integer HDR encoding.
|
||||
static const float HDR_RGB10_MAX = 4.0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue