summaryrefslogtreecommitdiff
path: root/glsl
diff options
context:
space:
mode:
authorFrederico Linhares <fred@linhares.blue>2023-01-12 15:23:16 -0300
committerFrederico Linhares <fred@linhares.blue>2023-01-12 15:23:16 -0300
commit704858045b4f7defb977adb8344ae4428cd02081 (patch)
treea21dfcdbd7836b0a55bdeaf99001e615ada98e0a /glsl
parent62367a0bcca75c45eb3e7d1582c4fff18827ddc7 (diff)
refa Use Push constants for 3D models
Diffstat (limited to 'glsl')
-rw-r--r--glsl/shader_3d.frag.glsl2
-rw-r--r--glsl/shader_3d.vert.glsl9
2 files changed, 5 insertions, 6 deletions
diff --git a/glsl/shader_3d.frag.glsl b/glsl/shader_3d.frag.glsl
index 302f7d4..916f26f 100644
--- a/glsl/shader_3d.frag.glsl
+++ b/glsl/shader_3d.frag.glsl
@@ -34,7 +34,7 @@ layout(set = 0, binding = 1) uniform UBOWorld
vec4 directional_light_color;
} ubo_world;
-layout(set = 2, binding = 1) uniform sampler2D texture_sampler;
+layout(set = 2, binding = 0) uniform sampler2D texture_sampler;
void
main()
diff --git a/glsl/shader_3d.vert.glsl b/glsl/shader_3d.vert.glsl
index 29beea9..8fd9167 100644
--- a/glsl/shader_3d.vert.glsl
+++ b/glsl/shader_3d.vert.glsl
@@ -40,9 +40,9 @@ layout(set = 1, binding = 0) uniform UBOView
mat4 proj;
} ubo_view;
-layout(set = 2, binding = 0) uniform UBOModelInstance
+layout(push_constant) uniform UBOModelInstance
{
- mat4 instances[128];
+ mat4 matrix;
} ubo_model_instance;
void
@@ -50,9 +50,8 @@ main()
{
gl_Position =
ubo_view.proj * ubo_view.view *
- ubo_model_instance.instances[gl_InstanceIndex] * vec4(in_position, 1.0);
+ ubo_model_instance.matrix * vec4(in_position, 1.0);
out_dto.frag_color = ubo_world.ambient_light_color;
out_dto.frag_texture_coord = in_texture_coord;
- out_dto.normal = mat3(ubo_model_instance.instances[gl_InstanceIndex]) *
- in_normal;
+ out_dto.normal = mat3(ubo_model_instance.matrix) * in_normal;
}