aboutsummaryrefslogtreecommitdiff
path: root/samples/VolumetricLightingTest/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'samples/VolumetricLightingTest/shaders')
-rw-r--r--samples/VolumetricLightingTest/shaders/post_PS.hlsl56
-rw-r--r--samples/VolumetricLightingTest/shaders/quad_VS.hlsl47
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_GS.hlsl141
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_PS.hlsl177
-rw-r--r--samples/VolumetricLightingTest/shaders/scene_VS.hlsl117
5 files changed, 538 insertions, 0 deletions
diff --git a/samples/VolumetricLightingTest/shaders/post_PS.hlsl b/samples/VolumetricLightingTest/shaders/post_PS.hlsl
new file mode 100644
index 0000000..d0e5a4c
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/post_PS.hlsl
@@ -0,0 +1,56 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+struct VS_QUAD_OUTPUT
+{
+ float4 vPos : SV_POSITION;
+ sample float2 vTex : TEXCOORD0;
+};
+
+float3 tonemap(float3 C)
+{
+ // Filmic -- model film properties
+ C = max(0, C - 0.004);
+ return (C*(6.2*C+0.5))/(C*(6.2*C+1.7)+0.06);
+}
+
+Texture2DMS<float4> tScene : register(t0);
+
+float4 main(VS_QUAD_OUTPUT input, uint sampleID : SV_SAMPLEINDEX) : SV_Target0
+{
+ float3 output = float3(0, 0, 0);
+ float3 s_hdr = tScene.Load(int2(input.vPos.xy), sampleID).rgb;
+ output = tonemap(s_hdr);
+ return float4(output, 1);
+}
diff --git a/samples/VolumetricLightingTest/shaders/quad_VS.hlsl b/samples/VolumetricLightingTest/shaders/quad_VS.hlsl
new file mode 100644
index 0000000..b8f666a
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/quad_VS.hlsl
@@ -0,0 +1,47 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+struct VS_QUAD_OUTPUT
+{
+ float4 vPos : SV_POSITION;
+ sample float2 vTex : TEXCOORD0;
+};
+
+VS_QUAD_OUTPUT main(uint id : SV_VERTEXID)
+{
+ VS_QUAD_OUTPUT output;
+ output.vTex = float2((id << 1) & 2, id & 2);
+ output.vPos = float4(output.vTex * float2(2,-2) + float2(-1,1), 1, 1);
+ return output;
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_GS.hlsl b/samples/VolumetricLightingTest/shaders/scene_GS.hlsl
new file mode 100644
index 0000000..3315a79
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_GS.hlsl
@@ -0,0 +1,141 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+
+%% MUX_END %%
+
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZNFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+struct GS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL;
+ uint Target : SV_RenderTargetArrayIndex;
+ float Wz : SV_ClipDistance0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Geometry Shader
+
+float3 ParaboloidProject(float3 P, float zNear, float zFar)
+{
+ float3 outP;
+ float lenP = length(P.xyz);
+ outP.xyz = P.xyz/lenP;
+ outP.x = outP.x / (outP.z + 1);
+ outP.y = outP.y / (outP.z + 1);
+ outP.z = (lenP - zNear) / (zFar - zNear);
+ return outP;
+}
+
+void GenerateOmniTriangle(uint target, VS_OUTPUT vA, VS_OUTPUT vB, VS_OUTPUT vC, inout TriangleStream<GS_OUTPUT> output)
+{
+ GS_OUTPUT outValue;
+ outValue.Target = target;
+ outValue.ScreenP = float4(ParaboloidProject(vA.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vA.P;
+ outValue.N = vA.N;
+ outValue.Wz = vA.ScreenP.z;
+ output.Append(outValue);
+ outValue.ScreenP = float4(ParaboloidProject(vB.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vB.P;
+ outValue.N = vB.N;
+ outValue.Wz = vB.ScreenP.z;
+ output.Append(outValue);
+ outValue.ScreenP = float4(ParaboloidProject(vC.ScreenP.xyz, c_fZNear, c_fZFar), 1);
+ outValue.P = vC.P;
+ outValue.N = vC.N;
+ outValue.Wz = vC.ScreenP.z;
+ output.Append(outValue);
+ output.RestartStrip();
+}
+
+[maxvertexcount(6)]
+void main(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> output)
+{
+ float minZ = min(input[0].ScreenP.z, min(input[1].ScreenP.z, input[2].ScreenP.z));
+ float maxZ = max(input[0].ScreenP.z, max(input[1].ScreenP.z, input[2].ScreenP.z));
+
+ if (maxZ >= 0)
+ {
+ GenerateOmniTriangle(0, input[0], input[1], input[2], output);
+ }
+
+ if (minZ <= 0)
+ {
+ input[0].ScreenP.z *= -1;
+ input[1].ScreenP.z *= -1;
+ input[2].ScreenP.z *= -1;
+ GenerateOmniTriangle(1, input[2], input[1], input[0], output);
+ }
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_PS.hlsl b/samples/VolumetricLightingTest/shaders/scene_PS.hlsl
new file mode 100644
index 0000000..66b7e9d
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_PS.hlsl
@@ -0,0 +1,177 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+- LIGHTMODE:
+ - LIGHTMODE_DIRECTIONAL
+ - LIGHTMODE_SPOTLIGHT
+ - LIGHTMODE_OMNI
+%% MUX_END %%
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Resources
+
+SamplerComparisonState sampShadowmap : register(s0);
+
+#if (LIGHTMODE == LIGHTMODE_DIRECTIONAL || LIGHTMODE == LIGHTMODE_SPOTLIGHT)
+ Texture2D<float> tShadowmap : register(t0);
+#elif (LIGHTMODE == LIGHTMODE_OMNI)
+ Texture2DArray <float1> tShadowmapArray : register(t0);
+#endif
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Pixel Shader
+
+float3 ParaboloidProject(float3 P, float zNear, float zFar)
+{
+ float3 outP;
+ float lenP = length(P.xyz);
+ outP.xyz = P.xyz/lenP;
+ outP.x = outP.x / (outP.z + 1);
+ outP.y = outP.y / (outP.z + 1);
+ outP.z = (lenP - zNear) / (zFar - zNear);
+ return outP;
+}
+
+float4 main(VS_OUTPUT input) : SV_Target0
+{
+ float3 P = input.P.xyz / input.P.w;
+ float3 N = normalize(input.N);
+ float3 Kd = c_vObjectColor;
+
+ //return float4(0.5*(N+1), 1);
+
+ const float SHADOW_BIAS = -0.001f;
+ float4 shadow_clip = mul(c_mLightViewProj, float4(P,1));
+ shadow_clip = shadow_clip / shadow_clip.w;
+ uint hemisphereID = (shadow_clip.z > 0) ? 0 : 1;
+ if (LIGHTMODE == LIGHTMODE_OMNI)
+ {
+ shadow_clip.z = abs(shadow_clip.z);
+ shadow_clip.xyz = ParaboloidProject(shadow_clip.xyz, c_fLightZNear, c_fLightZFar);
+ }
+ float2 shadow_tc = float2(0.5f, -0.5f)*shadow_clip.xy + 0.5f;
+ float receiver_depth = shadow_clip.z+SHADOW_BIAS;
+
+ float total_light = 0;
+ const int SHADOW_KERNEL = 2;
+ [unroll]
+ for (int ox=-SHADOW_KERNEL; ox<=SHADOW_KERNEL; ++ox)
+ {
+ [unroll]
+ for (int oy=-SHADOW_KERNEL; oy<=SHADOW_KERNEL; ++oy)
+ {
+#if (LIGHTMODE == LIGHTMODE_OMNI)
+ total_light += tShadowmapArray.SampleCmpLevelZero(sampShadowmap, float3(shadow_tc, hemisphereID), receiver_depth, int2(ox, oy)).x;
+#else
+ total_light += tShadowmap.SampleCmpLevelZero(sampShadowmap, shadow_tc, receiver_depth, int2(ox, oy)).x;
+#endif
+ }
+ }
+ float shadow_term = total_light / ((2*SHADOW_KERNEL+1) * (2*SHADOW_KERNEL+1));
+
+ float3 output = float3(0,0,0);
+ float3 L = -c_vLightDirection;
+ if (LIGHTMODE == LIGHTMODE_DIRECTIONAL)
+ {
+ float3 attenuation = shadow_term*dot(N, L);
+ float3 ambient = 0.001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient);
+
+ }
+ else if (LIGHTMODE == LIGHTMODE_SPOTLIGHT)
+ {
+ float light_to_world = length(P - c_vLightPos);
+ float3 W = (c_vLightPos - P)/light_to_world;
+
+ float distance_attenuation = 1.0f/(c_vLightAttenuationFactors.x + c_vLightAttenuationFactors.y*light_to_world + c_vLightAttenuationFactors.z*light_to_world*light_to_world) + c_vLightAttenuationFactors.w;
+
+ const float ANGLE_EPSILON = 0.00001f;
+ float angle_factor = saturate((dot(N, L)-c_fLightFalloffCosTheta)/(1-c_fLightFalloffCosTheta));
+ float spot_attenuation = (angle_factor > ANGLE_EPSILON) ? pow(angle_factor, c_fLightFalloffPower) : 0.0f;
+
+ float3 attenuation = distance_attenuation*spot_attenuation*shadow_term*dot(N, W);
+ float3 ambient = 0.00001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient)*exp(-c_vSigmaExtinction*light_to_world);
+ }
+ else if (LIGHTMODE == LIGHTMODE_OMNI)
+ {
+ float light_to_world = length(P - c_vLightPos);
+ float3 W = (c_vLightPos - P)/light_to_world;
+ float distance_attenuation = 1.0f/(c_vLightAttenuationFactors.x + c_vLightAttenuationFactors.y*light_to_world + c_vLightAttenuationFactors.z*light_to_world*light_to_world) + c_vLightAttenuationFactors.w;
+
+ float3 attenuation = distance_attenuation*shadow_term*dot(N, W);
+ float3 ambient = 0.00001f*saturate(0.5f*(dot(N, L)+1.0f));
+ output += c_vLightColor*max(attenuation, ambient)*exp(-c_vSigmaExtinction*light_to_world);
+ }
+
+ return float4(output, 1);
+}
diff --git a/samples/VolumetricLightingTest/shaders/scene_VS.hlsl b/samples/VolumetricLightingTest/shaders/scene_VS.hlsl
new file mode 100644
index 0000000..630b87c
--- /dev/null
+++ b/samples/VolumetricLightingTest/shaders/scene_VS.hlsl
@@ -0,0 +1,117 @@
+// This code contains NVIDIA Confidential Information and is disclosed
+// under the Mutual Non-Disclosure Agreement.
+//
+// Notice
+// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
+// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
+//
+// NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. No third party distribution is allowed unless
+// expressly authorized by NVIDIA. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2003 - 2016 NVIDIA Corporation. All rights reserved.
+//
+// NVIDIA Corporation and its licensors retain all intellectual property and proprietary
+// rights in and to this software and related documentation and any modifications thereto.
+// Any use, reproduction, disclosure or distribution of this software and related
+// documentation without an express license agreement from NVIDIA Corporation is
+// strictly prohibited.
+//
+
+/*
+Define the shader permutations for code generation
+%% MUX_BEGIN %%
+%% MUX_END %%
+*/
+
+////////////////////////////////////////////////////////////////////////////////
+// Constant Buffers
+
+cbuffer CameraCB : register( b0 )
+{
+ column_major float4x4 c_mViewProj : packoffset(c0);
+ float3 c_vEyePos : packoffset(c4);
+ float c_fZNear : packoffset(c5);
+ float c_fZFar : packoffset(c5.y);
+};
+
+cbuffer ObjectCB : register( b1 )
+{
+ column_major float4x4 c_mObject : packoffset(c0);
+ float3 c_vObjectColor : packoffset(c4);
+};
+
+cbuffer LightCB : register( b2 )
+{
+ column_major float4x4 c_mLightViewProj : packoffset(c0);
+ float3 c_vLightDirection : packoffset(c4);
+ float c_fLightFalloffCosTheta : packoffset(c4.w);
+ float3 c_vLightPos : packoffset(c5);
+ float c_fLightFalloffPower : packoffset(c5.w);
+ float3 c_vLightColor : packoffset(c6);
+ float4 c_vLightAttenuationFactors : packoffset(c7);
+ float c_fLightZNear : packoffset(c8);
+ float c_fLightZNFar : packoffset(c8.y);
+ float3 c_vSigmaExtinction : packoffset(c9);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// IO Structures
+
+struct VS_OUTPUT
+{
+ float4 ScreenP : SV_POSITION;
+ float4 P : TEXCOORD0;
+ float3 N : NORMAL0;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Vertex Shader
+
+VS_OUTPUT main( uint id : SV_VERTEXID )
+{
+ VS_OUTPUT output;
+
+ // Faces
+ // +X, +Y, +Z, -X, -Y, -Z
+ // Vertices
+ // 0 ---15
+ // | / |
+ // | / |
+ // | / |
+ // 24--- 3
+
+ uint face_idx = id / 6;
+ uint vtx_idx = id % 6;
+ float3 P;
+ P.x = ((vtx_idx % 3) == 2) ? -1 : 1;
+ P.y = ((vtx_idx % 3) == 1) ? -1 : 1;
+ P.z = 0;
+ if ((face_idx % 3) == 0)
+ P.yzx = P.xyz;
+ else if ((face_idx % 3) == 1)
+ P.xzy = P.xyz;
+ // else if ((face_idx % 3) == 2)
+ // P.xyz = P.xyz;
+ P *= ((vtx_idx / 3) == 0) ? 1 : -1;
+
+ float3 N;
+ N.x = ((face_idx % 3) == 0) ? 1 : 0;
+ N.y = ((face_idx % 3) == 1) ? 1 : 0;
+ N.z = ((face_idx % 3) == 2) ? 1 : 0;
+ N *= ((face_idx / 3) == 0) ? 1 : -1;
+ P += N;
+
+ output.P = mul(c_mObject, float4(P, 1));
+ output.ScreenP = mul(c_mViewProj, output.P);
+ output.N = mul(c_mObject, float4(N, 0)).xyz;
+ return output;
+}