diff options
Diffstat (limited to 'demo/Shaders')
| -rw-r--r-- | demo/Shaders/customEmitAllocCS.hlsl | 34 | ||||
| -rw-r--r-- | demo/Shaders/customEmitEmit2CS.hlsl | 66 | ||||
| -rw-r--r-- | demo/Shaders/customEmitEmitCS.hlsl | 65 | ||||
| -rw-r--r-- | demo/Shaders/customLightingCS.hlsl | 87 | ||||
| -rw-r--r-- | demo/Shaders/imguiPS.hlsl | 22 | ||||
| -rw-r--r-- | demo/Shaders/imguiVS.hlsl | 31 | ||||
| -rw-r--r-- | demo/Shaders/meshPS.hlsl | 21 | ||||
| -rw-r--r-- | demo/Shaders/meshVS.hlsl | 31 |
8 files changed, 357 insertions, 0 deletions
diff --git a/demo/Shaders/customEmitAllocCS.hlsl b/demo/Shaders/customEmitAllocCS.hlsl new file mode 100644 index 0000000..930ef4f --- /dev/null +++ b/demo/Shaders/customEmitAllocCS.hlsl @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, 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 THREAD_DIM_X 8 +#define THREAD_DIM_Y 8 +#define THREAD_DIM_Z 8 + +typedef uint4 NvFlowUint4; + +cbuffer params : register(b0) +{ + NvFlowUint4 minMaskIdx; + NvFlowUint4 maxMaskIdx; +}; + +RWTexture3D<uint> maskUAV : register(u0); + +[numthreads(THREAD_DIM_X, THREAD_DIM_Y, THREAD_DIM_Z)] +void customEmitAllocCS(uint3 tidx : SV_DispatchThreadID) +{ + int3 maskIdx = tidx + minMaskIdx.xyz; + + if (all(maskIdx >= int3(minMaskIdx.xyz)) && all(maskIdx < int3(maxMaskIdx.xyz))) + { + maskUAV[maskIdx] = 1u; + } +}
\ No newline at end of file diff --git a/demo/Shaders/customEmitEmit2CS.hlsl b/demo/Shaders/customEmitEmit2CS.hlsl new file mode 100644 index 0000000..4616b87 --- /dev/null +++ b/demo/Shaders/customEmitEmit2CS.hlsl @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, 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 THREAD_DIM_X 8 +#define THREAD_DIM_Y 8 +#define THREAD_DIM_Z 8 + +typedef uint4 NvFlowUint4; +typedef float4 NvFlowFloat4; + +/// Begin Samplers supplied by ComputeContext +SamplerState borderSampler : register(s0); +SamplerState borderPointSampler : register(s1); +SamplerState wrapSampler : register(s2); +SamplerState wrapPointSampler : register(s3); +SamplerState clampSampler : register(s4); +SamplerState clampPointSampler : register(s5); +/// End Samplers supplied by ComputeContext + +#include "../DemoApp/flowShaderParams.h" + +cbuffer params : register(b0) +{ + NvFlowShaderPointParams customEmitParams; + + NvFlowUint4 minVidx; + NvFlowUint4 maxVidx; + NvFlowFloat4 targetValue; + NvFlowFloat4 blendRate; +}; + +Buffer<uint> blockList : register(t0); +Texture3D<uint> blockTable : register(t1); +Texture3D<float4> dataSRV : register(t2); +RWTexture3D<float4> dataUAV : register(u0); + +NV_FLOW_DISPATCH_ID_TO_VIRTUAL(blockList, customEmitParams); + +NV_FLOW_VIRTUAL_TO_REAL(VirtualToReal, blockTable, customEmitParams); + +[numthreads(THREAD_DIM_X, THREAD_DIM_Y, THREAD_DIM_Z)] +void customEmitEmit2CS(uint3 tidx : SV_DispatchThreadID) +{ + int3 vidx = DispatchIDToVirtual(tidx); + + //int3 vidx = tidx.xyz + minVidx.xyz; + + int3 ridx = VirtualToReal(vidx); + + float4 value = dataSRV[ridx]; + + if (all(vidx >= int3(minVidx.xyz)) && all(vidx < int3(maxVidx.xyz))) + { + value = (1.f.xxxx - blendRate) * value + blendRate * targetValue; + value = (1.f.xxxx - blendRate) * value + blendRate * targetValue; + } + + dataUAV[ridx] = value; +}
\ No newline at end of file diff --git a/demo/Shaders/customEmitEmitCS.hlsl b/demo/Shaders/customEmitEmitCS.hlsl new file mode 100644 index 0000000..c9adbb9 --- /dev/null +++ b/demo/Shaders/customEmitEmitCS.hlsl @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, 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 THREAD_DIM_X 8 +#define THREAD_DIM_Y 8 +#define THREAD_DIM_Z 8 + +typedef uint4 NvFlowUint4; +typedef float4 NvFlowFloat4; + +/// Begin Samplers supplied by ComputeContext +SamplerState borderSampler : register(s0); +SamplerState borderPointSampler : register(s1); +SamplerState wrapSampler : register(s2); +SamplerState wrapPointSampler : register(s3); +SamplerState clampSampler : register(s4); +SamplerState clampPointSampler : register(s5); +/// End Samplers supplied by ComputeContext + +#include "../DemoApp/flowShaderParams.h" + +cbuffer params : register(b0) +{ + NvFlowShaderPointParams customEmitParams; + + NvFlowUint4 minVidx; + NvFlowUint4 maxVidx; + NvFlowFloat4 targetValue; + NvFlowFloat4 blendRate; +}; + +Buffer<uint> blockList : register(t0); +Texture3D<uint> blockTable : register(t1); +Texture3D<float4> dataSRV : register(t2); +RWTexture3D<float4> dataUAV : register(u0); + +NV_FLOW_DISPATCH_ID_TO_VIRTUAL(blockList, customEmitParams); + +NV_FLOW_VIRTUAL_TO_REAL(VirtualToReal, blockTable, customEmitParams); + +[numthreads(THREAD_DIM_X, THREAD_DIM_Y, THREAD_DIM_Z)] +void customEmitEmitCS(uint3 tidx : SV_DispatchThreadID) +{ + //int3 vidx = DispatchIDToVirtual(tidx); + + int3 vidx = tidx.xyz + minVidx.xyz; + + if (all(vidx >= int3(minVidx.xyz)) && all(vidx < int3(maxVidx.xyz))) + { + int3 ridx = VirtualToReal(vidx); + + float4 value = dataSRV[ridx]; + + value = (1.f.xxxx - blendRate) * value + blendRate * targetValue; + + dataUAV[ridx] = value; + } +}
\ No newline at end of file diff --git a/demo/Shaders/customLightingCS.hlsl b/demo/Shaders/customLightingCS.hlsl new file mode 100644 index 0000000..d9f95ee --- /dev/null +++ b/demo/Shaders/customLightingCS.hlsl @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, 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 THREAD_DIM_X 8 +#define THREAD_DIM_Y 8 +#define THREAD_DIM_Z 8 + +/// Begin Samplers supplied by ComputeContext +SamplerState borderSampler : register(s0); +SamplerState borderPointSampler : register(s1); +SamplerState wrapSampler : register(s2); +SamplerState wrapPointSampler : register(s3); +SamplerState clampSampler : register(s4); +SamplerState clampPointSampler : register(s5); +/// End Samplers supplied by ComputeContext + +typedef uint4 NvFlowUint4; +typedef float4 NvFlowFloat4; + +#include "../DemoApp/flowShaderParams.h" + +struct Light +{ + float4 location; + float4 intensity; + float4 bias; + float4 falloff; +}; + +cbuffer params : register(b0) +{ + NvFlowShaderLinearParams exportParams; + NvFlowShaderLinearParams importParams; + + Light light[3]; +}; + +Buffer<uint> exportBlockList : register(t0); +Texture3D<uint> exportBlockTable : register(t1); +Texture3D<float4> exportData : register(t2); + +Buffer<uint> importBlockList : register(t3); +Texture3D<uint> importBlockTable : register(t4); +RWTexture3D<float4> importDataRW : register(u0); + +NV_FLOW_DISPATCH_ID_TO_VIRTUAL(importBlockList, importParams); + +NV_FLOW_VIRTUAL_TO_REAL_LINEAR(VirtualToRealExport, exportBlockTable, exportParams); +NV_FLOW_VIRTUAL_TO_REAL(VirtualToRealImport, importBlockTable, importParams); + +float4 applyLight(uniform Light light, float3 vidxNorm) +{ + float3 offset = vidxNorm.xyz - light.location.xyz; + float dist2 = dot(offset.xyz, offset.xyz); + return light.intensity * light.bias / (light.bias + light.falloff * dist2); +} + +[numthreads(THREAD_DIM_X, THREAD_DIM_Y, THREAD_DIM_Z)] +void customLightingCS(uint3 tidx : SV_DispatchThreadID) +{ + int3 vidx = DispatchIDToVirtual(tidx); + float3 vidxf = float3(vidx)+0.5f.xxx; + + float3 vidxNorm = 2.f * vidxf * exportParams.vdimInv.xyz - 1.f; + + float3 ridxExport = VirtualToRealExport(vidxf); + float4 value = exportData.SampleLevel(borderSampler,exportParams.dimInv.xyz * ridxExport,0); + float temp = value.x; + + float4 color = float4(0.1f * temp, 0.1f * temp, 0.1f * temp, 0.25f); + + color += applyLight(light[0], vidxNorm); + color += applyLight(light[1], vidxNorm); + color += applyLight(light[2], vidxNorm); + + color.w *= 0.25f * max(temp - 0.25f, 0.f); + + int3 ridxImport = VirtualToRealImport(vidx); + importDataRW[ridxImport] = color; +}
\ No newline at end of file diff --git a/demo/Shaders/imguiPS.hlsl b/demo/Shaders/imguiPS.hlsl new file mode 100644 index 0000000..f51a21b --- /dev/null +++ b/demo/Shaders/imguiPS.hlsl @@ -0,0 +1,22 @@ + +struct Input +{ + float4 position : SV_POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +Texture2D<float> tex : register(t0); +SamplerState texSampler : register(s0); + +float4 imguiPS(Input input) : SV_TARGET +{ + float4 color = input.color; + + if (input.texCoord.x >= 0.f) + { + color.a *= tex.SampleLevel(texSampler, input.texCoord, 0.f); + } + + return color; +}
\ No newline at end of file diff --git a/demo/Shaders/imguiVS.hlsl b/demo/Shaders/imguiVS.hlsl new file mode 100644 index 0000000..6116ee1 --- /dev/null +++ b/demo/Shaders/imguiVS.hlsl @@ -0,0 +1,31 @@ + +cbuffer params : register(b0) +{ + float4x4 transform; +}; + +struct Input +{ + float2 position : POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +struct Output +{ + float4 position : SV_POSITION; + float2 texCoord : TEXCOORD; + float4 color : COLOR; +}; + +Output imguiVS(Input input, uint instance : SV_InstanceID) +{ + Output output; + + output.position = mul(float4(input.position, 0.f, 1.f), transform); + + output.texCoord = input.texCoord.xy; // float2(input.texCoord.x, 1.f - input.texCoord.y); + output.color = input.color; + + return output; +}
\ No newline at end of file diff --git a/demo/Shaders/meshPS.hlsl b/demo/Shaders/meshPS.hlsl new file mode 100644 index 0000000..6df4ebe --- /dev/null +++ b/demo/Shaders/meshPS.hlsl @@ -0,0 +1,21 @@ + +struct Input +{ + float4 position : SV_POSITION; + float3 normal : NORMAL; +}; + +float4 meshPS(Input input) : SV_TARGET +{ + float color = 0.1f; + + color += 0.4f * max(0.f,dot(input.normal, float3(0.57f, 0.57f, 0.57f))); + + color += 0.4f * max(0.f, dot(input.normal, float3(-0.57f, 0.57f, 0.57f))); + + color += 0.4f * max(0.f, dot(input.normal, float3(0.57f, 0.57f, -0.57f))); + + color += 0.4f * max(0.f, dot(input.normal, float3(-0.57f, 0.57f, -0.57f))); + + return float4(color.xxx, 1.0f); +}
\ No newline at end of file diff --git a/demo/Shaders/meshVS.hlsl b/demo/Shaders/meshVS.hlsl new file mode 100644 index 0000000..969cbeb --- /dev/null +++ b/demo/Shaders/meshVS.hlsl @@ -0,0 +1,31 @@ + +cbuffer params : register(b0) +{ + float4x4 projection; +}; + +struct Input +{ + float3 position : POSITION; + float3 normal : NORMAL; +}; + +struct Output +{ + float4 position : SV_POSITION; + float3 normal : NORMAL; +}; + +Output meshVS( Input input, uint instance : SV_InstanceID ) +{ + Output output; + output.position = mul(float4(input.position,1.f),projection); + output.normal = input.normal; + + //output.position.z *= -1.f; + //output.position.z += 0.5f; + + //output.position.y -= 1.f * float(instance) + 0.1f; + + return output; +}
\ No newline at end of file |