diff options
Diffstat (limited to 'examples/pbr_params/ex_pbr_params.c')
-rw-r--r-- | examples/pbr_params/ex_pbr_params.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/examples/pbr_params/ex_pbr_params.c b/examples/pbr_params/ex_pbr_params.c index 583fd12..0ac784d 100644 --- a/examples/pbr_params/ex_pbr_params.c +++ b/examples/pbr_params/ex_pbr_params.c @@ -15,19 +15,34 @@ extern core g_core; +const vec3 pointlight_positions[4] = { + { 10.0, 10.0, 10.0 }, + { -10.0, 10.0, 10.0 }, + { 10.0, -10.0, 10.0 }, + { -10.0, -10.0, 10.0 }, +}; +pbr_point_light point_lights[4]; + // Lets define some constant PBR parameters here to test on one sphere with first const rgba ALBEDO = RED_700; const f32 metallic = 0.0; const f32 roughness = 0.8; const f32 ao = 0.2; -const pbr_params_material_uniforms pbr_params = {.albedo = (vec3){0.5,0.5,0.5}, .metallic = metallic, .roughness = roughness, .ao = ao}; +const pbr_params_material_uniforms pbr_params = { + .albedo = (vec3){ 0.5, 0.5, 0.5 }, .metallic = metallic, .roughness = roughness, .ao = ao +}; int main() { core_bringup(); arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024); + for (int i = 0; i < 4; i++) { + point_lights[i].pos = pointlight_positions[i]; + point_lights[i].color = vec3(1, 1, 1); + } + vec3 camera_pos = vec3(3.0, 3., 3.); vec3 camera_front = vec3_normalise(vec3_negate(camera_pos)); camera cam = camera_create(camera_pos, camera_front, VEC3_Y, deg_to_rad(45.0)); @@ -61,7 +76,7 @@ int main() { .code = fragment_shader.contents, .is_spirv = false }, .renderpass = renderpass, - .wireframe = false, + .wireframe = true, .depth_test = false }; gpu_pipeline* pbr_pipeline = gpu_graphics_pipeline_create(pipeline_description); @@ -90,9 +105,13 @@ int main() { camera_view_projection(&cam, 1000, 1000, &view, &proj); // Feed shader data - pbr_bind_data.mvp_matrices = (mvp_matrix_uniforms){.model = model_affine, .view = view, .projection = proj}; + pbr_bind_data.mvp_matrices = + (mvp_matrix_uniforms){ .model = model_affine, .view = view, .projection = proj }; pbr_bind_data.material = pbr_params; - pbr_bind_data.lights = (pbr_params_light_uniforms){.viewPos = cam.position /* TODO: point lights*/}; + pbr_bind_data.lights = + (pbr_params_light_uniforms){ .viewPos = cam.position, + .pointLights = { point_lights[0], point_lights[1], + point_lights[2], point_lights[3] } }; pbr_uniforms.data = &pbr_bind_data; encode_bind_shader_data(enc, 0, &pbr_uniforms); |