mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
Updated some examples with inconsistencies
This commit is contained in:
18
examples/text/resources/shaders/glsl120/alpha_discard.fs
Normal file
18
examples/text/resources/shaders/glsl120/alpha_discard.fs
Normal file
@ -0,0 +1,18 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texelColor = texture2D(texture0, fragTexCoord);
|
||||
|
||||
if (texelColor.a == 0.0) discard;
|
||||
|
||||
gl_FragColor = texelColor*fragColor*colDiffuse;
|
||||
}
|
||||
23
examples/text/resources/shaders/glsl120/sdf.fs
Normal file
23
examples/text/resources/shaders/glsl120/sdf.fs
Normal file
@ -0,0 +1,23 @@
|
||||
#version 120
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
varying vec2 fragTexCoord;
|
||||
varying vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// NOTE: Add your custom variables here
|
||||
const float smoothing = 1.0/16.0;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Texel color fetching from texture sampler
|
||||
// NOTE: Calculate alpha using signed distance field (SDF)
|
||||
float distance = texture2D(texture0, fragTexCoord).a;
|
||||
float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance);
|
||||
|
||||
// Calculate final fragment color
|
||||
gl_FragColor = vec4(fragColor.rgb, fragColor.a*alpha);
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h> // Required for: calloc(), free()
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
@ -199,5 +199,6 @@ static void AddCodepointRange(Font *font, const char *fontPath, int start, int s
|
||||
|
||||
UnloadFont(*font);
|
||||
*font = LoadFontEx(fontPath, 32, updatedCodepoints, updatedCodepointCount);
|
||||
RL_FREE(updatedCodepoints);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user