mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 07:15:37 +00:00
67 lines
1.8 KiB
HLSL
67 lines
1.8 KiB
HLSL
//*****************************************************************************
|
|
// Torque -- HLSL procedural shader
|
|
//*****************************************************************************
|
|
|
|
// Dependencies:
|
|
#include "core/rendering/shaders/torque.hlsl"
|
|
|
|
// Features:
|
|
// Paraboloid Vert Transform
|
|
// Visibility
|
|
// Depth (Out)
|
|
// Single Pass Paraboloid
|
|
|
|
struct VertData
|
|
{
|
|
float3 position : POSITION;
|
|
float3 normal : NORMAL;
|
|
float3 T : TANGENT;
|
|
float3 B : BINORMAL;
|
|
float2 texCoord : TEXCOORD0;
|
|
};
|
|
|
|
|
|
struct ConnectData
|
|
{
|
|
float4 hpos : SV_Position;
|
|
float isBack : TEXCOORD0;
|
|
float2 posXY : TEXCOORD1;
|
|
float depth : TEXCOORD2;
|
|
};
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Main
|
|
//-----------------------------------------------------------------------------
|
|
ConnectData main( VertData IN,
|
|
uniform float2 atlasScale : register(C4),
|
|
uniform float4x4 worldViewOnly : register(C0),
|
|
uniform float4 lightParams : register(C5)
|
|
)
|
|
{
|
|
ConnectData OUT;
|
|
|
|
// Paraboloid Vert Transform
|
|
OUT.hpos = mul(worldViewOnly, float4(IN.position.xyz,1)).xzyw;
|
|
float L = length(OUT.hpos.xyz);
|
|
bool isBack = OUT.hpos.z < 0.0;
|
|
OUT.isBack = isBack ? -1.0 : 1.0;
|
|
if ( isBack ) OUT.hpos.z = -OUT.hpos.z;
|
|
OUT.hpos /= L;
|
|
OUT.hpos.z = OUT.hpos.z + 1.0;
|
|
OUT.hpos.xy /= OUT.hpos.z;
|
|
OUT.hpos.z = L / lightParams.x;
|
|
OUT.hpos.w = 1.0;
|
|
OUT.posXY = OUT.hpos.xy;
|
|
OUT.hpos.xy *= atlasScale.xy;
|
|
OUT.hpos.x += isBack ? 0.5 : -0.5;
|
|
|
|
// Visibility
|
|
|
|
// Depth (Out)
|
|
OUT.depth = OUT.hpos.z / OUT.hpos.w;
|
|
|
|
// Single Pass Paraboloid
|
|
|
|
return OUT;
|
|
}
|