ui rendering works now

This commit is contained in:
Dynamitos
2022-04-18 18:08:38 +02:00
parent 796271f334
commit 14b816fc3c
25 changed files with 453 additions and 60 deletions
+59 -13
View File
@@ -1,30 +1,76 @@
struct VertexStageOutput
struct RenderElementStyle
{
float4 position : SV_Position;
float2 uvCoords : TEXCOORD;
float3 position;
uint backgroundImageIndex;
float3 backgroundColor;
float opacity;
//float4 borderBottomColor;
//float4 borderLeftColor;
//float4 borderRightColor;
//float4 borderTopColor;
//float borderBottomLeftRadius;
//float borderBottomRightRadius;
//float borderTopLeftRadius;
//float borderTopRightRadius;
float2 dimensions;
};
struct ViewData
{
float4x4 projectionMatrix;
};
layout(set = 0, binding = 0)
ConstantBuffer<ViewData> viewData;
layout(set = 0, binding = 1)
SamplerState backgroundSampler;
layout(set = 0, binding = 2)
ConstantBuffer<uint> numBackgroundTextures;
layout(set = 0, binding = 3)
Texture2D<float4> backgroundTextures[];
struct VertexStageOutput
{
float4 position : SV_Position;
float2 texCoords : TEXCOORD;
RenderElementStyle style : RENDER_STYLE;
};
[shader("vertex")]
VertexStageOutput vertexMain(uint vertexId : SV_VertexID)
VertexStageOutput vertexMain(uint vertexId : SV_VertexID, RenderElementStyle style)
{
float2 coordinates[4] = {
float2(0, 0),
float2(0, 1),
float2(1, 0),
float2(1, 1)
float xMin = style.position.x;
float xMax = xMin + style.dimensions.x;
float yMin = style.position.y;
float yMax = yMin + style.dimensions.y;
float4 coordinates[] = {
float4(xMin, yMin, 0, 0),
float4(xMin, yMax, 0, 1),
float4(xMax, yMin, 1, 0),
float4(xMax, yMax, 1, 1)
};
VertexStageOutput output;
output.uvCoords = coordinates[vertexId];
output.position = float4(output.uvCoords * 2 - 1, 1, 1);
output.position = mul(viewData.projectionMatrix, float4(coordinates[vertexId].xy, style.position.z, 1));
output.texCoords = coordinates[vertexId].zw;
output.style = style;
return output;
}
[shader("fragment")]
float4 fragmentMain(
float4 position : SV_Position,
float2 uvCoords : TEXCOORD
float2 texCoords : TEXCOORD,
RenderElementStyle style : RENDER_STYLE
) : SV_Target
{
return float4(0, 1, 0, 1);
float4 bgTextureColor = float4(1, 1, 1, 1);
uint imageIndex = style.backgroundImageIndex;
if(imageIndex < numBackgroundTextures)
{
bgTextureColor = backgroundTextures[imageIndex].Sample(backgroundSampler, texCoords);
}
return float4(style.backgroundColor, style.opacity) * bgTextureColor;
}
+103
View File
@@ -0,0 +1,103 @@
#version 450
#extension GL_EXT_nonuniform_qualifier : require
layout(row_major) uniform;
layout(row_major) buffer;
#line 30 0
layout(binding = 2)
layout(std140) uniform _S1
{
uint _data;
} numBackgroundTextures_0;
#line 33
layout(binding = 3)
uniform texture2D backgroundTextures_0[];
#line 27
layout(binding = 1)
uniform sampler backgroundSampler_0;
#line 27
layout(location = 0)
out vec4 _S2;
#line 63
layout(location = 0)
in vec2 _S3;
#line 1
layout(location = 1)
in vec3 _S4;
#line 1
flat layout(location = 2)
in uint _S5;
#line 1
layout(location = 3)
in vec3 _S6;
#line 1
layout(location = 4)
in float _S7;
#line 1
layout(location = 5)
in vec2 _S8;
#line 1
struct RenderElementStyle_0
{
vec3 position_0;
uint backgroundImageIndex_0;
vec3 backgroundColor_0;
float opacity_0;
vec2 dimensions_0;
};
#line 63
void main()
{
vec4 bgTextureColor_0;
#line 63
RenderElementStyle_0 _S9 = RenderElementStyle_0(_S4, _S5, _S6, _S7, _S8);
#line 69
const vec4 _S10 = vec4(float(1), float(1), float(1), float(1));
#line 69
uint imageIndex_0 = _S9.backgroundImageIndex_0;
if(imageIndex_0 < numBackgroundTextures_0._data)
{
vec4 _S11 = (texture(sampler2D(backgroundTextures_0[imageIndex_0],backgroundSampler_0), (_S3)));
#line 71
bgTextureColor_0 = _S11;
}
else
{
#line 71
bgTextureColor_0 = _S10;
}
#line 71
_S2 = vec4(_S9.backgroundColor_0, _S9.opacity_0) * bgTextureColor_0;
#line 71
return;
}
+83
View File
@@ -0,0 +1,83 @@
#version 450
layout(row_major) uniform;
layout(row_major) buffer;
#line 1 0
struct RenderElementStyle_0
{
vec3 position_0;
uint backgroundImageIndex_0;
vec3 backgroundColor_0;
float opacity_0;
vec4 borderBottomColor_0;
vec4 borderLeftColor_0;
vec4 borderRightColor_0;
vec4 borderTopColor_0;
float borderBottomLeftRadius_0;
float borderBottomRightRadius_0;
float borderTopLeftRadius_0;
float borderTopRightRadius_0;
vec2 dimensions_0;
};
#line 33
layout(std430, binding = 3) readonly buffer _S1 {
RenderElementStyle_0 _data[];
} elements_0;
#line 33
layout(location = 0)
out vec2 _S2;
#line 33
layout(location = 1)
out uint _S3;
struct VertexStageOutput_0
{
vec4 position_1;
vec2 texCoords_0;
uint elementId_0;
};
void main()
{
#line 46
uint _S4 = uint(gl_VertexIndex);
#line 46
uint _S5 = uint(gl_InstanceIndex);
RenderElementStyle_0 style_0 = ((elements_0)._data[(_S5)]);
float xMin_0 = style_0.position_0.x;
float xMax_0 = xMin_0 + style_0.dimensions_0.x;
float yMin_0 = style_0.position_0.y;
float yMax_0 = yMin_0 + style_0.dimensions_0.y;
vec4 coordinates_0[4] = { vec4(xMin_0, yMin_0, float(0), float(0)), vec4(xMin_0, yMax_0, float(0), float(1)), vec4(xMax_0, yMin_0, float(1), float(0)), vec4(xMax_0, yMax_0, float(1), float(1)) };
#line 59
VertexStageOutput_0 output_0;
output_0.position_1 = vec4(coordinates_0[_S4].xy, style_0.position_0.z, float(1));
output_0.texCoords_0 = coordinates_0[_S4].zw;
output_0.elementId_0 = _S5;
VertexStageOutput_0 _S6 = output_0;
#line 63
gl_Position = _S6.position_1;
#line 63
_S2 = _S6.texCoords_0;
#line 63
_S3 = _S6.elementId_0;
#line 63
return;
}