mirror of https://github.com/bjornbytes/lovr.git
Add Font shader;
This commit is contained in:
parent
de6edaef31
commit
3df9aea3fd
|
@ -1,6 +1,8 @@
|
||||||
#include "shaders/unlit.vert.h"
|
#include "shaders/unlit.vert.h"
|
||||||
#include "shaders/unlit.frag.h"
|
#include "shaders/unlit.frag.h"
|
||||||
|
|
||||||
|
#include "shaders/font.frag.h"
|
||||||
|
|
||||||
#include "shaders/lovr.glsl.h"
|
#include "shaders/lovr.glsl.h"
|
||||||
|
|
||||||
#define LOCATION_POSITION 10
|
#define LOCATION_POSITION 10
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#version 460
|
||||||
|
#extension GL_EXT_multiview : require
|
||||||
|
#extension GL_GOOGLE_include_directive : require
|
||||||
|
#extension GL_EXT_samplerless_texture_functions : require
|
||||||
|
|
||||||
|
#include "lovr.glsl"
|
||||||
|
|
||||||
|
float screenPxRange() {
|
||||||
|
vec2 screenTexSize = vec2(1.) / fwidth(FragUV);
|
||||||
|
return max(.5 * dot(Material.sdfRange, screenTexSize), 1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
float median(float r, float g, float b) {
|
||||||
|
return max(min(r, g), min(max(r, g), b));
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 msdf = texture(sampler2D(Texture, Sampler), FragUV).rgb;
|
||||||
|
float sdf = median(msdf.r, msdf.g, msdf.b);
|
||||||
|
float screenPxDistance = screenPxRange() * (sdf - .5);
|
||||||
|
float alpha = clamp(screenPxDistance + .5, 0., 1.);
|
||||||
|
if (alpha <= 0.) discard;
|
||||||
|
PixelColors[0] = vec4(FragColor.rgb, alpha);
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ struct MaterialData {
|
||||||
vec4 glow;
|
vec4 glow;
|
||||||
vec2 uvShift;
|
vec2 uvShift;
|
||||||
vec2 uvScale;
|
vec2 uvScale;
|
||||||
|
vec2 sdfRange;
|
||||||
float metalness;
|
float metalness;
|
||||||
float roughness;
|
float roughness;
|
||||||
float clearcoat;
|
float clearcoat;
|
||||||
|
@ -31,7 +32,6 @@ struct MaterialData {
|
||||||
float normalScale;
|
float normalScale;
|
||||||
float alphaCutoff;
|
float alphaCutoff;
|
||||||
float pointSize;
|
float pointSize;
|
||||||
float sdfRange;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(set = 1, binding = 0) uniform MaterialBlock { MaterialData Material; };
|
layout(set = 1, binding = 0) uniform MaterialBlock { MaterialData Material; };
|
||||||
|
|
|
@ -99,6 +99,7 @@ typedef struct {
|
||||||
float glow[4];
|
float glow[4];
|
||||||
float uvShift[2];
|
float uvShift[2];
|
||||||
float uvScale[2];
|
float uvScale[2];
|
||||||
|
float sdfRange[2];
|
||||||
float metalness;
|
float metalness;
|
||||||
float roughness;
|
float roughness;
|
||||||
float clearcoat;
|
float clearcoat;
|
||||||
|
@ -108,7 +109,6 @@ typedef struct {
|
||||||
float normalScale;
|
float normalScale;
|
||||||
float alphaCutoff;
|
float alphaCutoff;
|
||||||
float pointSize;
|
float pointSize;
|
||||||
float sdfRange;
|
|
||||||
uint32_t texture;
|
uint32_t texture;
|
||||||
uint32_t glowTexture;
|
uint32_t glowTexture;
|
||||||
uint32_t occlusionTexture;
|
uint32_t occlusionTexture;
|
||||||
|
|
|
@ -291,6 +291,7 @@ typedef struct {
|
||||||
float glow[4];
|
float glow[4];
|
||||||
float uvShift[2];
|
float uvShift[2];
|
||||||
float uvScale[2];
|
float uvScale[2];
|
||||||
|
float sdfRange[2];
|
||||||
float metalness;
|
float metalness;
|
||||||
float roughness;
|
float roughness;
|
||||||
float clearcoat;
|
float clearcoat;
|
||||||
|
@ -300,7 +301,6 @@ typedef struct {
|
||||||
float normalScale;
|
float normalScale;
|
||||||
float alphaCutoff;
|
float alphaCutoff;
|
||||||
float pointSize;
|
float pointSize;
|
||||||
float sdfRange;
|
|
||||||
} MaterialData;
|
} MaterialData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Reference in New Issue