More Refactoring
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import Common;
|
||||
|
||||
struct VertexShaderInput
|
||||
{
|
||||
float3 position;
|
||||
};
|
||||
|
||||
struct VertexShaderOutput
|
||||
{
|
||||
float4 clipPos : SV_Position;
|
||||
@@ -18,13 +13,69 @@ struct SkyboxData
|
||||
layout(set=1)
|
||||
ParameterBlock<SkyboxData> pSkyboxData;
|
||||
|
||||
float3 vertices[] = {
|
||||
// Back
|
||||
float3(-512, -512, 512),
|
||||
float3(-512, 512, 512),
|
||||
float3( 512, -512, 512),
|
||||
|
||||
float3( 512, -512, 512),
|
||||
float3(-512, 512, 512),
|
||||
float3( 512, 512, 512),
|
||||
|
||||
// Front
|
||||
float3( 512, -512, -512),
|
||||
float3( 512, 512, -512),
|
||||
float3(-512, -512, -512),
|
||||
|
||||
float3(-512, -512, -512),
|
||||
float3( 512, 512, -512),
|
||||
float3(-512, 512, -512),
|
||||
|
||||
// Top
|
||||
float3(-512, -512, -512),
|
||||
float3(-512, -512, 512),
|
||||
float3( 512, -512, -512),
|
||||
|
||||
float3( 512, -512, -512),
|
||||
float3(-512, -512, 512),
|
||||
float3( 512, -512, 512),
|
||||
|
||||
// Bottom
|
||||
float3(-512, 512, 512),
|
||||
float3(-512, 512, -512),
|
||||
float3( 512, 512, 512),
|
||||
|
||||
float3( 512, 512, 512),
|
||||
float3(-512, 512, -512),
|
||||
float3( 512, 512, -512),
|
||||
|
||||
// Left
|
||||
float3(-512, -512, -512),
|
||||
float3(-512, 512, -512),
|
||||
float3(-512, -512, 512),
|
||||
|
||||
float3(-512, -512, 512),
|
||||
float3(-512, 512, -512),
|
||||
float3(-512, 512, 512),
|
||||
|
||||
// Right
|
||||
float3( 512, -512, 512),
|
||||
float3( 512, 512, 512),
|
||||
float3( 512, -512, -512),
|
||||
|
||||
float3( 512, -512, -512),
|
||||
float3( 512, 512, 512),
|
||||
float3( 512, 512, -512),
|
||||
};
|
||||
|
||||
[shader("vertex")]
|
||||
VertexShaderOutput vertexMain(
|
||||
VertexShaderInput input)
|
||||
uint vertexIndex : SV_VertexId)
|
||||
{
|
||||
VertexShaderOutput output;
|
||||
float3x3 cameraRotation = float3x3(pViewParams.viewMatrix);
|
||||
float4 worldPos = float4(mul(cameraRotation, input.position), 1.0f);
|
||||
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
||||
//clip(dot(worldPos, clipPlane));
|
||||
output.clipPos = mul(pViewParams.projectionMatrix, worldPos);
|
||||
output.texCoords = normalize(input.position);
|
||||
|
||||
@@ -13,15 +13,24 @@ ParameterBlock<SamplerState> glyphSampler;
|
||||
//layout(set = 1)
|
||||
//ShaderBuffer<GlyphData> glyphData;
|
||||
ParameterBuffer<Texture2D<uint>[]> pGlyphTextures;
|
||||
[[vk::push_constant]]
|
||||
ConstantBuffer<TextData> textData;
|
||||
|
||||
struct VertexInput
|
||||
struct GlyphInstanceData
|
||||
{
|
||||
float2 position;
|
||||
float2 widthHeight;
|
||||
uint glyphIndex;
|
||||
};
|
||||
struct TextRender
|
||||
{
|
||||
StructuredBuffer<GlyphInstanceData> instances;
|
||||
TextData textData;
|
||||
}
|
||||
ParameterBuffer<TextRender> pRender;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
uint vertexId : SV_VertexID;
|
||||
uint instanceId : SV_InstanceID;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
@@ -34,11 +43,11 @@ struct VertexOutput
|
||||
[shader("vertex")]
|
||||
VertexOutput vertexMain(VertexInput input)
|
||||
{
|
||||
float xpos = input.position.x;
|
||||
float ypos = input.position.y;
|
||||
float xpos = pRender.instances[input.instanceId].position.x;
|
||||
float ypos = pRender.instances[input.instanceId].position.y;
|
||||
|
||||
float w = input.widthHeight.x;
|
||||
float h = input.widthHeight.y;
|
||||
float w = pRender.instances[input.instanceId].widthHeight.x;
|
||||
float h = pRender.instances[input.instanceId].widthHeight.y;
|
||||
|
||||
float4 coordinates[4] = {
|
||||
float4(xpos, ypos, 0, 1),
|
||||
@@ -50,7 +59,7 @@ VertexOutput vertexMain(VertexInput input)
|
||||
VertexStageOutput output;
|
||||
output.texCoords = vertex.zw;
|
||||
output.position = mul(viewData.projectionMatrix, float4(vertex.xy, 0, 1));
|
||||
output.glyphIndex = input.glyphIndex;
|
||||
output.glyphIndex = pRender.instances[input.instanceId].glyphIndex;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user