render 3d to tex

This commit is contained in:
Daniel Ledda
2026-05-11 23:30:35 +02:00
parent e768b38322
commit 66547b0f68
10 changed files with 279 additions and 92 deletions

View File

@@ -9,6 +9,9 @@ in float frag_softness;
in float frag_border_radius;
in float frag_border_thickness;
in vec4 frag_border_color;
in vec2 uv;
uniform sampler2D rect_tex;
float roundedRectSDF(vec2 sample_pos, vec2 rect_center, vec2 rect_half_size, float r) {
vec2 d2 = (abs(rect_center - sample_pos) - rect_half_size + vec2(r, r));
@@ -52,6 +55,7 @@ void main() {
float sdf_factor = 1 - smoothstep(0, 2*frag_softness, dist);
vec4 out_color = frag_color * texture(rect_tex, uv);
pixel_color = frag_border_color * sample * sdf_factor * border_factor
+ frag_color * sample * sdf_factor;
+ out_color * sample * sdf_factor;
};

View File

@@ -17,6 +17,14 @@ out float frag_softness;
out float frag_border_radius;
out float frag_border_thickness;
out vec4 frag_border_color;
out vec2 uv;
const vec2 rectangle_uv[4] = vec2[](
vec2(0, 1),
vec2(0, 0),
vec2(1, 1),
vec2(1, 0)
);
const vec2 rectangle_vertices[4] = vec2[](
vec2(-1, -1),
@@ -44,4 +52,5 @@ void main() {
frag_border_thickness = border_thickness;
frag_border_color = border_color;
frag_softness = edge_softness;
uv = rectangle_uv[gl_VertexID];
}

View File

@@ -1,5 +1,5 @@
#version 330 core
out vec4 frag_color;
layout(location = 0) out vec4 frag_color;
uniform vec3 light_pos;
uniform vec4 solid_color;
@@ -7,7 +7,7 @@ uniform vec3 camera;
in vec3 normal;
in vec3 frag_position;
void main() {
vec4 light_color = vec4(1, 1, 1, 1);
vec3 normal_norm = normalize(normal);

View File

@@ -7,5 +7,5 @@ in vec2 frag_uv_position;
uniform sampler2D glyph_atlas;
void main() {
pixel_color = vec4(1,1,1,texture(glyph_atlas, frag_uv_position).r);
pixel_color = vec4(frag_color.xyz,texture(glyph_atlas, frag_uv_position).r);
};