TapirEngine: Implement UVScroll mesh attribute

This commit is contained in:
kichikuou
2024-10-20 08:16:24 +09:00
parent 9ca3d3e9c6
commit abd3a276a3
3 changed files with 14 additions and 2 deletions
+8 -2
View File
@@ -39,6 +39,12 @@ out vec3 specular_dir;
out vec3 ls_ex;
out vec3 ls_in;
const vec2 uv_scroll = vec2(0.0);
#else // ENGINE == REIGN_ENGINE
uniform vec2 uv_scroll;
#endif // ENGINE == REIGN_ENGINE
uniform mat4 local_transform;
@@ -104,8 +110,8 @@ void main() {
vec4 view_pos = view_transform * world_pos;
gl_Position = proj_transform * view_pos;
tex_coord = vertex_uv;
light_tex_coord = vertex_light_uv;
tex_coord = vertex_uv + uv_scroll;
light_tex_coord = vertex_light_uv + uv_scroll;
color_mod = vertex_color;
dist = -view_pos.z;
shadow_frag_pos = shadow_transform * world_pos;
+1
View File
@@ -177,6 +177,7 @@ struct RE_renderer {
GLint ls_sun_color;
GLint alpha_mode;
GLint alpha_texture;
GLint uv_scroll;
GLuint billboard_vao;
GLuint billboard_attr_buffer;
+5
View File
@@ -254,6 +254,7 @@ struct RE_renderer *RE_renderer_new(enum RE_plugin_version version)
r->ls_sun_color = glGetUniformLocation(r->program, "ls_sun_color");
r->alpha_mode = glGetUniformLocation(r->program, "alpha_mode");
r->alpha_texture = glGetUniformLocation(r->program, "alpha_texture");
r->uv_scroll = glGetUniformLocation(r->program, "uv_scroll");
glGenRenderbuffers(1, &r->depth_buffer);
@@ -429,6 +430,10 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d
glUniform1i(r->alpha_mode, ALPHA_BLEND);
}
vec2 uv_scroll;
glm_vec2_scale(mesh->uv_scroll, r->last_frame_timestamp / 1000.f, uv_scroll);
glUniform2fv(r->uv_scroll, 1, uv_scroll);
glBindVertexArray(mesh->vao);
if (mesh->nr_indices)