Created
October 29, 2012 23:37
-
-
Save rygorous/3977354 to your computer and use it in GitHub Desktop.
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
// This is your vertex buffer, split into components. | |
// On D3D11 HW, you can probably use structured buffers to de-SoA this, but I haven't checked. | |
Buffer<float3> buf_pos; | |
Buffer<float3> buf_norm; | |
Buffer<float2> buf_uvs; | |
float4x4 clip_from_model; | |
uint base_index, index_mask; | |
struct Output | |
{ | |
float4 pos : POSITION; | |
float3 normal : NORMAL; | |
float2 uv : TEXCOORD0; | |
}; | |
Output MyVS(uint index : SV_VertexID) | |
{ | |
Output o; | |
uint fetch_index = (index + base_index) & index_mask; | |
float4 in_model_pos = float4(buf_pos.Load(fetch_index), 1.0); | |
float3 in_norm = buf_norm.Load(fetch_index); | |
float2 in_uv = buf_uv.Load(fetch_index); | |
o.pos = mul(clip_from_model, in_model_pos); | |
o.normal = in_norm; // passthrough doesn't really make sense here, but it's just an example | |
o.uv = in_uv; | |
return o; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment