Skip to content

Commit

Permalink
add outline uniform setter
Browse files Browse the repository at this point in the history
  • Loading branch information
hotstreams committed Jun 18, 2024
1 parent f4c860e commit 4026338
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
15 changes: 9 additions & 6 deletions samples/materials/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ void LimitlessMaterials::Scene::setUpModels() {
.build()
);

scene.add(Instance::builder()
.model(assets.models.at("sphere"))
.material(assets.materials.at("basic8"))
.position({24.0f, 1.0f, 19.0f })
.build()
);


auto sphere = Instance::builder()
.model(assets.models.at("sphere"))
.material(assets.materials.at("basic8"))
.position({24.0f, 1.0f, 19.0f })
.build();
sphere->makeOutlined();
scene.add(sphere);

auto floor = std::make_shared<InstancedInstance>();
floor->makeOutlined();
Expand Down
2 changes: 1 addition & 1 deletion shaders/pipeline/gbuffer.frag
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {

info.r = float(mctx.shading_model) / 255.0;
// info.g = object type ?;
info.b = 1.0;
info.b = outline;

emissive = computeMaterialEmissiveColor(mctx);
}
5 changes: 5 additions & 0 deletions src/limitless/instances/model_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <limitless/models/model.hpp>
#include <limitless/models/elementary_model.hpp>
#include <limitless/core/shader/shader_program.hpp>
#include <stdexcept>
#include <utility>

Expand Down Expand Up @@ -44,6 +45,10 @@ void ModelInstance::draw(Context& ctx, const Assets& assets, ShaderType pass, ms
return;
}

const_cast<UniformSetter&>(uniform_setter).add([&] (ShaderProgram& shader) {
shader.setUniform("outline", outlined ? 1.0f : 0.0f);
});

for (auto& [name, mesh] : meshes) {
mesh.draw(ctx, assets, pass, shader_type, final_matrix, blending, uniform_setter);
}
Expand Down

0 comments on commit 4026338

Please sign in to comment.