added ui rendering
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
12 8 !"#$&'()*+,-./0123456789:;<=>?@ABCDEFGIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgijklmnopqrstuvwxyz{|}~
|
||||
12 8 !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ float4 _main(
|
||||
uint triid: SV_PrimitiveID,
|
||||
) : SV_TARGET
|
||||
{
|
||||
return float4(0.2,0.2,0.2,1);
|
||||
return float4(color);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,10 @@ struct VertexOutput
|
||||
|
||||
DECLARE_CONSTANTS()
|
||||
{
|
||||
int2 resolution;
|
||||
uint2 resolution;
|
||||
uint2 size;
|
||||
int2 position;
|
||||
float4 color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ float4 _main(
|
||||
uint triid: SV_PrimitiveID,
|
||||
) : SV_TARGET
|
||||
{
|
||||
return float4(0.2,0.2,0.2,1);
|
||||
float dist = SampleTexture(font, (input.uv+glyphPos)*glyphSize).x;
|
||||
float smoothing = 0.2;
|
||||
float alpha = smoothstep(0.5-smoothing, 0.5+smoothing, dist);
|
||||
if (alpha<0.01) discard;
|
||||
return float4(color);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 position: SV_Position;
|
||||
float2 uv: TEXCOORD0;
|
||||
}
|
||||
#include "shader_base.h"
|
||||
|
||||
@@ -11,8 +12,11 @@ DECLARE_CONSTANTS()
|
||||
int2 resolution;
|
||||
uint2 size;
|
||||
int2 position;
|
||||
int8_t character;
|
||||
float4 color;
|
||||
float2 glyphPos;
|
||||
float2 glyphSize;
|
||||
uint font;
|
||||
};
|
||||
|
||||
DECLARE_TEXTURES(0);
|
||||
DECLARE_TEXTURES(29);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ VertexOutput _main(
|
||||
{
|
||||
VertexOutput output;
|
||||
output.position = float4((input.position*size+position)/resolution*2-1, 0, 1.0f);
|
||||
output.uv = input.uv;
|
||||
FIX_VERTEX_POSITION(output.position);
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,19 @@ SamplerState mlGetSampler()
|
||||
_mlGetSampler();
|
||||
};
|
||||
|
||||
#define DECLARE_CBUFFER(b) \
|
||||
[[vk::binding(b)]] cbuffer cbuffer_##b : register(t##b)
|
||||
#define DECLARE_CBUFFER(n) \
|
||||
[[vk::binding(n)]] cbuffer cbuffer_##b : register(b##n)
|
||||
|
||||
#define DECLARE_CONSTANTS() \
|
||||
[[vk::push_constant]] \
|
||||
cbuffer cbuffer_constants : register(t29)
|
||||
cbuffer cbuffer_constants : register(b29)
|
||||
|
||||
#define FIX_VERTEX_POSITION(g) g = float4(g.x, -g.y, g.z, g.w);
|
||||
|
||||
#elif defined(__SPIRV__)
|
||||
|
||||
#define DECLARE_TEXTURES(b) \
|
||||
[[vk::binding(b)]] \
|
||||
#define DECLARE_TEXTURES(n) \
|
||||
[[vk::binding(n)]] \
|
||||
Sampler2D g_textures[]; \
|
||||
float4 SampleTexture(uint32_t binding, float2 uv) \
|
||||
{ \
|
||||
|
||||
Reference in New Issue
Block a user