From fd4cd2a407470a53cc4b787e7b391d00db19e1d8 Mon Sep 17 00:00:00 2001 From: elipzer Date: Wed, 17 Oct 2018 15:09:32 -0400 Subject: [PATCH] Lit pipelines work! Problem was that I didn't set the material (or the normals) --- CharcoalBuiltin/LitPipeline.h | 2 +- CharcoalBuiltin/MeshGenerator.h | 2 +- Example/MyBuiltinLitScene.cpp | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CharcoalBuiltin/LitPipeline.h b/CharcoalBuiltin/LitPipeline.h index 1d1bb20..857a151 100644 --- a/CharcoalBuiltin/LitPipeline.h +++ b/CharcoalBuiltin/LitPipeline.h @@ -36,7 +36,7 @@ namespace charcoal { glutil::uniform_matrix(0, get_camera()->get_world_to_view_matrix()); glutil::uniform_vec3(4, get_camera()->get_position()); - glutil::uniform_uint(5, m_lights.size()); + glutil::uniform_uint(5, (unsigned int)m_lights.size()); glutil::uniform_lights(6, m_lights); } private: diff --git a/CharcoalBuiltin/MeshGenerator.h b/CharcoalBuiltin/MeshGenerator.h index 1f4eed4..7b8011b 100644 --- a/CharcoalBuiltin/MeshGenerator.h +++ b/CharcoalBuiltin/MeshGenerator.h @@ -20,7 +20,7 @@ namespace charcoal namespace meshgenerator { template - Mesh* set_material(Mesh* mesh, const Material& material) + Mesh* set_material(Mesh* mesh, const PhongMaterial& material) { for (unsigned int i = 0; i < mesh->vertex_count; ++i) { diff --git a/Example/MyBuiltinLitScene.cpp b/Example/MyBuiltinLitScene.cpp index 930090f..b656bbb 100644 --- a/Example/MyBuiltinLitScene.cpp +++ b/Example/MyBuiltinLitScene.cpp @@ -11,10 +11,22 @@ MyBuiltinLitScene::MyBuiltinLitScene(Application& application) : Scene(application), - m_shape(meshgenerator::gen_cube_p(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), DrawMode::DRAW_TRIANGLES), + m_shape( + meshgenerator::set_material( + meshgenerator::gen_cube_pn(DRAW_TRIANGLES, 2.0f, 2.0f, 2.0f), + PhongMaterial(1.0f, 1.0f, 0.2f, 1.0f) + ), DrawMode::DRAW_TRIANGLES + ), m_camera((float)TAU_1_4, (float)m_screen_size.x / m_screen_size.y, 1.0f, 10.0f, vec3(0.0f, 0.0f, 5.0f)), m_batch(&m_shape, 2), - m_light(Position(0.0f, 5.0f, 0.0f), PhongLight::Power(0.1f, 100.0f, 1.0f), ColorRGB(1.0f, 1.0f, 1.0f), ColorRGB(1.0f, 1.0f, 1.0f), ColorRGB(1.0f, 1.0f, 1.0f), PhongLight::Fade(1.0f, 0.1f, 0.01f)) + m_light( + Position(0.0f, 2.0f, 2.0f), + PhongLight::Power(0.2f, 1.0f, 1.0f), + ColorRGB(1.0f, 1.0f, 1.0f), + ColorRGB(1.0f, 1.0f, 1.0f), + ColorRGB(1.0f, 1.0f, 1.0f), + PhongLight::Fade(1.0f, 0.1f, 0.01f) + ) { m_pipeline.add_batch(&m_batch); m_pipeline.set_camera(&m_camera);