diff options
| author | Connor Thomson <blumatrikz@gmail.com> | 2026-09-10 17:07:15 -0700 |
|---|---|---|
| committer | Connor Thomson <blumatrikz@gmail.com> | 2026-09-10 17:07:15 -0700 |
| commit | e9d4cbaa3c44337115d672d2038a7b73745181c8 (patch) | |
| tree | acc15d887e370117f80cc94512af612002ebdbd9 /src/obj_model.c | |
| parent | da1891aa0a053297e1b17bc34c23c362f9ac0c6b (diff) | |
Update teapot model, add phong shading, & more
Diffstat (limited to 'src/obj_model.c')
| -rw-r--r-- | src/obj_model.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/obj_model.c b/src/obj_model.c index 6b11583..39c25b6 100644 --- a/src/obj_model.c +++ b/src/obj_model.c @@ -27,6 +27,8 @@ typedef struct ta_obj_uniforms { float mvp[16]; float model[16]; + float camera_position[3]; + float padding; } ta_obj_uniforms; static SDL_GPUShader *ta_obj_shader(SDL_GPUDevice *device, const void *code, size_t size, SDL_GPUShaderStage stage) { @@ -167,6 +169,10 @@ void ta_obj_model_render(const ta_obj_model *model, SDL_GPUCommandBuffer *comman projection[14] = near_plane * far_plane / (near_plane - far_plane); ta_obj_multiply(view_model, view, uniforms.model); ta_obj_multiply(uniforms.mvp, projection, view_model); + uniforms.camera_position[0] = ta_camera_current.x; + uniforms.camera_position[1] = ta_camera_current.y; + uniforms.camera_position[2] = ta_camera_current.z; + uniforms.padding = 0.0f; SDL_PushGPUVertexUniformData(command_buffer, 0, &uniforms, sizeof(uniforms)); SDL_BindGPUGraphicsPipeline(render_pass, model->pipeline); SDL_GPUBufferBinding binding = {.buffer = model->vertex_buffer}; |