Add Look panel: edge outlines, shadow mapping, anime cel and soft studio shading, rim light
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
30d8c98891
commit
3154e4fab9
20 files changed
+740
-81
No files matched your search
+42
-4
@@ -18,6 +18,14 @@ namespace {
|
||||
json vec(const osg::Vec3f& v) { return json::array({v.x(), v.y(), v.z()}); }
|
||||
json vec(const osg::Vec3d& v) { return json::array({v.x(), v.y(), v.z()}); }
|
||||
|
||||
const char* const kShadingNames[] = {"toon", "lambert", "cel", "soft"};
|
||||
|
||||
int shadingFromName(const std::string& name) {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
if (name == kShadingNames[i]) return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename V>
|
||||
void readVec(const json& j, const char* key, V& out) {
|
||||
auto it = j.find(key);
|
||||
@@ -94,8 +102,22 @@ bool saveScene(const Scene& scene, const std::string& path, std::string& error)
|
||||
{"skeleton", scene.skeleton},
|
||||
{"wireframe", scene.wireframe},
|
||||
{"backfaceCulling", scene.backfaceCulling},
|
||||
{"lightFollowsCamera", scene.lightFollowsCamera},
|
||||
{"shading", scene.lightingModel == 1 ? "lambert" : "toon"}};
|
||||
{"lightFollowsCamera", scene.look.lightFollowsCamera},
|
||||
{"shading", kShadingNames[std::clamp(scene.look.shading, 0, 3)]}};
|
||||
const LookSettings& look = scene.look;
|
||||
j["look"] = {{"lightColor", vec(look.lightColor)},
|
||||
{"lightAzimuth", look.lightAzimuth},
|
||||
{"lightElevation", look.lightElevation},
|
||||
{"outlines", look.outlines},
|
||||
{"outlineWidth", look.outlineWidth},
|
||||
{"shadows", look.shadows},
|
||||
{"shadowQuality", look.shadowQuality},
|
||||
{"shadowSoftness", look.shadowSoftness},
|
||||
{"shadowStrength", look.shadowStrength},
|
||||
{"groundShadow", look.groundShadow},
|
||||
{"groundShadowOpacity", look.groundShadowOpacity},
|
||||
{"rimStrength", look.rimStrength},
|
||||
{"rimColor", vec(look.rimColor)}};
|
||||
j["render"] = {{"width", scene.renderWidth},
|
||||
{"height", scene.renderHeight},
|
||||
{"transparent", scene.renderTransparent},
|
||||
@@ -191,8 +213,24 @@ bool loadScene(const std::string& path, Scene& scene, std::string& error) {
|
||||
read(*it, "skeleton", scene.skeleton);
|
||||
read(*it, "wireframe", scene.wireframe);
|
||||
read(*it, "backfaceCulling", scene.backfaceCulling);
|
||||
read(*it, "lightFollowsCamera", scene.lightFollowsCamera);
|
||||
scene.lightingModel = it->value("shading", std::string("toon")) == "lambert" ? 1 : 0;
|
||||
read(*it, "lightFollowsCamera", scene.look.lightFollowsCamera);
|
||||
scene.look.shading = shadingFromName(it->value("shading", std::string("toon")));
|
||||
}
|
||||
if (auto it = j.find("look"); it != j.end() && it->is_object()) {
|
||||
LookSettings& look = scene.look;
|
||||
readVec(*it, "lightColor", look.lightColor);
|
||||
read(*it, "lightAzimuth", look.lightAzimuth);
|
||||
read(*it, "lightElevation", look.lightElevation);
|
||||
read(*it, "outlines", look.outlines);
|
||||
read(*it, "outlineWidth", look.outlineWidth);
|
||||
read(*it, "shadows", look.shadows);
|
||||
read(*it, "shadowQuality", look.shadowQuality);
|
||||
read(*it, "shadowSoftness", look.shadowSoftness);
|
||||
read(*it, "shadowStrength", look.shadowStrength);
|
||||
read(*it, "groundShadow", look.groundShadow);
|
||||
read(*it, "groundShadowOpacity", look.groundShadowOpacity);
|
||||
read(*it, "rimStrength", look.rimStrength);
|
||||
readVec(*it, "rimColor", look.rimColor);
|
||||
}
|
||||
if (auto it = j.find("render"); it != j.end() && it->is_object()) {
|
||||
read(*it, "width", scene.renderWidth);
|
||||
|
||||
Reference in new issue
Block a user