Materials shown in the view: each object's metal and rough reach the shader (Solid and Rendered); a Material picker with sixteen to start from (gold, chrome, wood, ceramic...); o.material and fry.materials() in scripts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-20 17:14:55 +02:00
commit e93ae44684
9 changed files with 101 additions and 5 deletions

View file

@ -11,6 +11,7 @@
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
namespace fry {
@ -128,6 +129,19 @@ struct Scene {
uint32_t nextId = 1;
};
// Materials to start from: a colour (unless `keepColor`: only how metal and rough it is) and
// how metal and rough. Shown in the view (Solid and Rendered) and exported with the object.
struct MaterialPreset {
const char* id; // as scripts name it
const char* name; // as shown
glm::vec3 color; // sRGB
float metal, rough;
bool keepColor = false;
};
const std::vector<MaterialPreset>& materialPresets();
const MaterialPreset* findMaterial(std::string_view id);
void applyMaterial(Object& o, const MaterialPreset& m);
glm::mat4 objectMatrix(const Object& o);
// A turn as degrees about X, then Y, then Z (what the Properties panel shows), and back.
glm::vec3 toEuler(const glm::quat& q);