mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Direct3D11 common shader changes.
This commit is contained in:
parent
1ff6f221fb
commit
3a9b50f702
283 changed files with 3547 additions and 1834 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#ifndef _TORQUE_HLSL_
|
||||
#define _TORQUE_HLSL_
|
||||
|
||||
#include "./shaderModel.hlsl"
|
||||
|
||||
static float M_HALFPI_F = 1.57079632679489661923f;
|
||||
static float M_PI_F = 3.14159265358979323846f;
|
||||
|
|
@ -137,29 +138,29 @@ float3x3 quatToMat( float4 quat )
|
|||
/// @param negViewTS The negative view vector in tangent space.
|
||||
/// @param depthScale The parallax factor used to scale the depth result.
|
||||
///
|
||||
float2 parallaxOffset( sampler2D texMap, float2 texCoord, float3 negViewTS, float depthScale )
|
||||
float2 parallaxOffset(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = tex2D( texMap, texCoord ).a;
|
||||
float2 offset = negViewTS.xy * ( depth * depthScale );
|
||||
float depth = TORQUE_TEX2D(texMap, texCoord).a;
|
||||
float2 offset = negViewTS.xy * (depth * depthScale);
|
||||
|
||||
for ( int i=0; i < PARALLAX_REFINE_STEPS; i++ )
|
||||
for (int i = 0; i < PARALLAX_REFINE_STEPS; i++)
|
||||
{
|
||||
depth = ( depth + tex2D( texMap, texCoord + offset ).a ) * 0.5;
|
||||
offset = negViewTS.xy * ( depth * depthScale );
|
||||
depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).a) * 0.5;
|
||||
offset = negViewTS.xy * (depth * depthScale);
|
||||
}
|
||||
|
||||
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)
|
||||
float2 parallaxOffsetDxtnm(TORQUE_SAMPLER2D(texMap), float2 texCoord, float3 negViewTS, float depthScale)
|
||||
{
|
||||
float depth = tex2D(texMap, texCoord).r;
|
||||
float depth = TORQUE_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;
|
||||
depth = (depth + TORQUE_TEX2D(texMap, texCoord + offset).r) * 0.5;
|
||||
offset = negViewTS.xy * (depth * depthScale);
|
||||
}
|
||||
|
||||
|
|
@ -277,5 +278,37 @@ void fizzle(float2 vpos, float visibility)
|
|||
clip( visibility - frac( determinant( m ) ) );
|
||||
}
|
||||
|
||||
// Deferred Shading: Material Info Flag Check
|
||||
bool getFlag(float flags, int num)
|
||||
{
|
||||
int process = round(flags * 255);
|
||||
int squareNum = pow(2, num);
|
||||
return (fmod(process, pow(2, squareNum)) >= squareNum);
|
||||
}
|
||||
|
||||
// #define TORQUE_STOCK_GAMMA
|
||||
#ifdef TORQUE_STOCK_GAMMA
|
||||
// Sample in linear space. Decodes gamma.
|
||||
float4 toLinear(float4 tex)
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
// Encodes gamma.
|
||||
float4 toLinear(float4 tex)
|
||||
{
|
||||
return tex;
|
||||
}
|
||||
#else
|
||||
// Sample in linear space. Decodes gamma.
|
||||
float4 toLinear(float4 tex)
|
||||
{
|
||||
return float4(pow(abs(tex.rgb), 2.2), tex.a);
|
||||
}
|
||||
// Encodes gamma.
|
||||
float4 toGamma(float4 tex)
|
||||
{
|
||||
return float4(pow(abs(tex.rgb), 1.0/2.2), tex.a);
|
||||
}
|
||||
#endif //
|
||||
|
||||
#endif // _TORQUE_HLSL_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue