Skip to content

Commit

Permalink
[ren.quad] quads with a greater y coordinate will not display behind …
Browse files Browse the repository at this point in the history
…quads with a lower y coord. this doesnt affect layering at all - quads with a higher layer will almost certainly display over as the y effect is miniscule. TODO: make this optional
  • Loading branch information
harrand committed Nov 19, 2024
1 parent c481a7b commit a3ce3e5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tz/ren/quad.vertex.tzsl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ void main()
zcoord = -1.0 + ((cur_quad.layer + 100) / 200.0);
}
out::position = camera.projection * cur_quad.model * vec4(local_pos, zcoord, 1);

// slightly increase the z coordinate based on the y coordinate of the bottom of the quad.
// this means that quads with a greater y coord will display behind quads with a lower y coord. this makes for a more convincing 2d depth affect. TODO: make this optional.
float miny = cur_quad.model[3][1] - cur_quad.model[1][1];
out::position.z += miny * 0.01f;

out::tint = vec3(cur_quad.colour);
out::uv = quad_texcoords[in::vertex_id % 6];
out::texture_id = cur_quad.texture_id;
Expand Down

0 comments on commit a3ce3e5

Please sign in to comment.