diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-08-06 14:26:15 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-08-06 14:56:40 -0700 |
| commit | 5b5f7bb4b3cac1fa96b2325e7c3d0784ade28ebf (patch) | |
| tree | df536be69c964533bf19c75119a8e406f9daad31 /shaders | |
| parent | 562693fe2d0afbe9c828fa1acb4473db9752eeed (diff) | |
factor out the render commands into a new scene module
use push constants this concludes the tutorial; there's now a bit of fairly obvious refactoring to do to group objects in a way that reflects when they're needed, which can be followed by building a real scene graph Change-Id: Id3b76d00d08ae915270095bd606e41767b7ec177 Force-Push: yes
Diffstat (limited to 'shaders')
| -rw-r--r-- | shaders/shader.vert | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/shaders/shader.vert b/shaders/shader.vert index c07575a..009b38f 100644 --- a/shaders/shader.vert +++ b/shaders/shader.vert @@ -6,12 +6,15 @@ struct Transformation { }; layout(binding = 0) uniform UniformBlock { - vec3 scale; - Transformation model; - Transformation view; - mat4 projection; + Transformation view; + mat4 projection; } uniform_block; +layout(push_constant) uniform PushBlock { + vec3 scale; + Transformation model; +} push_block; + layout(location = 0) in vec3 inPosition; layout(location = 1) in vec3 inColor; layout(location = 2) in vec2 inTextureCoordinate; @@ -74,10 +77,10 @@ vec3 transform(vec3 a, Transformation transformation) { vec4 apply_all_transforms(vec3 position) { - vec3 scaled = vec3(position.x * uniform_block.scale.x, - position.y * uniform_block.scale.y, - position.z * uniform_block.scale.z); - vec3 model = transform(scaled, uniform_block.model); + vec3 scaled = vec3(position.x * push_block.scale.x, + position.y * push_block.scale.y, + position.z * push_block.scale.z); + vec3 model = transform(scaled, push_block.model); vec3 view = transform(model, uniform_block.view); vec4 projected = vec4(view, 1.0) * uniform_block.projection; return projected; |