feat(web): wire Blender area light depth
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-08-30 19:29:04 +08:00
parent ab8d5120b0
commit 6414d899fb
38 changed files with 1952 additions and 20 deletions

View File

@@ -5177,6 +5177,7 @@ json scene_ir_from_blend(const ParsedBlend &blend,
{"cascadeCount", read_integer(*blend.sdna, element, "cascade_count").value_or(4)},
{"areaSize", read_float(*blend.sdna, element, "area_size").value_or(0.25f)},
{"areaSizeY", read_float(*blend.sdna, element, "area_sizey").value_or(0.25f)},
{"areaSizeZ", read_float(*blend.sdna, element, "area_sizez").value_or(0.25f)},
{"areaSpread", read_float(*blend.sdna, element, "area_spread").value_or(3.14159265f)},
{"sunAngle", read_float(*blend.sdna, element, "sun_angle").value_or(0.00918f)}});
}

View File

@@ -5546,6 +5546,29 @@ bool web_engine_blend_main_set_light_cascade_controls(WebBlendMainState *state,
return true;
}
bool web_engine_blend_main_set_light_area_size_z(WebBlendMainState *state,
const char *target_id,
const float area_size_z,
std::string &error)
{
if (state == nullptr || state->main == nullptr || target_id == nullptr) {
error = "RENDER_PROPERTY_INVALID: light area size Z target is missing";
return false;
}
Light *light = find_light(state->main, target_id);
if (light == nullptr || !ensure_single_user_data(state->main, &light->id, error)) {
if (error.empty()) error = "RENDER_PROPERTY_INVALID: light was not found";
return false;
}
if (!std::isfinite(area_size_z) || area_size_z < 0.0001f || area_size_z > 1.0e9f) {
error = "RENDER_PROPERTY_INVALID: light area size Z is outside the bounded range";
return false;
}
light->area_sizez = area_size_z;
light->id.recalc |= ID_RECALC_PARAMETERS;
return true;
}
bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
const char *target_id,
const char *properties_json,
@@ -5742,7 +5765,7 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
if (strncmp(target_id, "light:", 6) == 0) {
Light *light = find_light(state->main, target_id);
if (light == nullptr || !ensure_single_user_data(state->main, &light->id, error)) return false;
if (!reject_unknown({"type", "areaShape", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "color", "energy", "exposure", "temperature", "useTemperature",
if (!reject_unknown({"type", "areaShape", "diffuseFactor", "specularFactor", "transmissionFactor", "volumeFactor", "attenuationDistance", "shadowFilterRadius", "shadowMaximumResolution", "shadowJitterOverblur", "cascadeMaxDistance", "cascadeExponent", "cascadeFade", "cascadeCount", "areaSizeZ", "color", "energy", "exposure", "temperature", "useTemperature",
"castsShadow", "radius", "spotAngle", "spotBlend", "areaSize",
"areaSizeY", "areaSpread", "sunAngle"}))
{
@@ -5818,6 +5841,13 @@ bool web_engine_blend_main_set_render_properties(WebBlendMainState *state,
if (max_distance < 0.0f || exponent < 0.0f || fade < 0.0f ||
!web_engine_blend_main_set_light_cascade_controls(state, target_id, max_distance, exponent, fade, count, error)) return false;
}
if (properties.contains("areaSizeZ")) {
if (!properties["areaSizeZ"].is_number()) {
error = "RENDER_PROPERTY_INVALID: areaSizeZ must be numeric";
return false;
}
if (!web_engine_blend_main_set_light_area_size_z(state, target_id, properties["areaSizeZ"].get<float>(), error)) return false;
}
if (!read_color("color", &light->r) ||
!read_float("energy", 0.0f, 1.0e9f, light->energy) ||
!read_float("exposure", -20.0f, 20.0f, light->exposure) ||

View File

@@ -545,6 +545,10 @@ bool web_engine_blend_main_set_light_cascade_controls(WebBlendMainState *state,
float fade,
int count,
std::string &error);
bool web_engine_blend_main_set_light_area_size_z(WebBlendMainState *state,
const char *target_id,
float area_size_z,
std::string &error);
bool web_engine_blend_main_set_scene_properties(WebBlendMainState *state,
const char *target_id,
const char *properties_json,