Created
August 27, 2016 04:06
-
-
Save yorung/9977349f04291b7c54de39dbd3795d00 to your computer and use it in GitHub Desktop.
[DX12] Define root signature in HLSL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cbuffer perObject : register(b0) | |
{ | |
row_major matrix invVP; | |
} | |
TextureCube texCube : register(t0); | |
SamplerState samplerState : register(s0); | |
struct VsToPs | |
{ | |
float4 pos : SV_POSITION; | |
float3 dir : DIR; | |
}; | |
#define RSDEF "CBV(b0), DescriptorTable(SRV(t0)), StaticSampler(s0)" | |
[RootSignature(RSDEF)] | |
VsToPs VSMain(uint id : SV_VertexID) | |
{ | |
VsToPs ret; | |
ret.pos = float4(id & 2 ? 1 : -1, id & 1 ? -1 : 1, 1, 1); | |
ret.dir = normalize(mul(ret.pos, invVP)).xyz; | |
return ret; | |
} | |
[RootSignature(RSDEF)] | |
float4 PSMain(VsToPs inp) : SV_Target | |
{ | |
return texCube.Sample(samplerState, inp.dir); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment