Update/Improve ViewerGUI
- separate out the settings for bloom, ssao and ssr - update webgl binaries - change default bloom resolution to 384 from 360 to have up to 7 mipmap levels vertically
This commit is contained in:
committed by
Mathias Agopian
parent
3ab8e4d725
commit
8d440cea17
@@ -1391,13 +1391,13 @@ public class View {
|
||||
/**
|
||||
* resolution of vertical axis (2^levels to 2048)
|
||||
*/
|
||||
public int resolution = 360;
|
||||
public int resolution = 384;
|
||||
/**
|
||||
* bloom x/y aspect-ratio (1/32 to 32)
|
||||
*/
|
||||
public float anamorphism = 1.0f;
|
||||
/**
|
||||
* number of blur levels (3 to 11)
|
||||
* number of blur levels (1 to 11)
|
||||
*/
|
||||
public int levels = 6;
|
||||
/**
|
||||
@@ -1985,4 +1985,11 @@ public class View {
|
||||
*/
|
||||
public float penumbraRatioScale = 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for stereoscopic (multi-eye) rendering.
|
||||
*/
|
||||
public static class StereoscopicOptions {
|
||||
public boolean enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -133,9 +133,9 @@ struct BloomOptions {
|
||||
Texture* dirt = nullptr; //!< user provided dirt texture %codegen_skip_json% %codegen_skip_javascript%
|
||||
float dirtStrength = 0.2f; //!< strength of the dirt texture %codegen_skip_json% %codegen_skip_javascript%
|
||||
float strength = 0.10f; //!< bloom's strength between 0.0 and 1.0
|
||||
uint32_t resolution = 360; //!< resolution of vertical axis (2^levels to 2048)
|
||||
uint32_t resolution = 384; //!< resolution of vertical axis (2^levels to 2048)
|
||||
float anamorphism = 1.0f; //!< bloom x/y aspect-ratio (1/32 to 32)
|
||||
uint8_t levels = 6; //!< number of blur levels (3 to 11)
|
||||
uint8_t levels = 6; //!< number of blur levels (1 to 11)
|
||||
BlendMode blendMode = BlendMode::ADD; //!< how the bloom effect is applied
|
||||
bool threshold = true; //!< whether to threshold the source
|
||||
bool enabled = false; //!< enable or disable bloom
|
||||
|
||||
@@ -1080,7 +1080,7 @@ void FView::setSoftShadowOptions(SoftShadowOptions options) noexcept {
|
||||
|
||||
void FView::setBloomOptions(BloomOptions options) noexcept {
|
||||
options.dirtStrength = math::saturate(options.dirtStrength);
|
||||
options.levels = math::clamp(options.levels, uint8_t(3), uint8_t(11));
|
||||
options.levels = math::clamp(options.levels, uint8_t(1), uint8_t(11));
|
||||
options.resolution = math::clamp(options.resolution, 1u << options.levels, 2048u);
|
||||
options.anamorphism = math::clamp(options.anamorphism, 1.0f/32.0f, 32.0f);
|
||||
options.highlight = std::max(10.0f, options.highlight);
|
||||
|
||||
@@ -868,4 +868,30 @@ std::ostream& operator<<(std::ostream& out, const SoftShadowOptions& in) {
|
||||
<< "}";
|
||||
}
|
||||
|
||||
int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, StereoscopicOptions* out) {
|
||||
CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
||||
int size = tokens[i++].size;
|
||||
for (int j = 0; j < size; ++j) {
|
||||
const jsmntok_t tok = tokens[i];
|
||||
CHECK_KEY(tok);
|
||||
if (compare(tok, jsonChunk, "enabled") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->enabled);
|
||||
} else {
|
||||
slog.w << "Invalid StereoscopicOptions key: '" << STR(tok, jsonChunk) << "'" << io::endl;
|
||||
i = parse(tokens, i + 1);
|
||||
}
|
||||
if (i < 0) {
|
||||
slog.e << "Invalid StereoscopicOptions value: '" << STR(tok, jsonChunk) << "'" << io::endl;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const StereoscopicOptions& in) {
|
||||
return out << "{\n"
|
||||
<< "\"enabled\": " << to_string(in.enabled) << "\n"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
} // namespace filament::viewer
|
||||
|
||||
@@ -93,4 +93,7 @@ std::ostream& operator<<(std::ostream& out, const VsmShadowOptions& in);
|
||||
int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, SoftShadowOptions* out);
|
||||
std::ostream& operator<<(std::ostream& out, const SoftShadowOptions& in);
|
||||
|
||||
int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, StereoscopicOptions* out);
|
||||
std::ostream& operator<<(std::ostream& out, const StereoscopicOptions& in);
|
||||
|
||||
} // namespace filament::viewer
|
||||
|
||||
@@ -738,8 +738,6 @@ void ViewerGui::updateUserInterface() {
|
||||
ImGui::Checkbox("Dithering", &dither);
|
||||
enableDithering(dither);
|
||||
ImGui::Checkbox("Bloom", &mSettings.view.bloom.enabled);
|
||||
ImGui::Checkbox("Flare", &mSettings.view.bloom.lensFlare);
|
||||
|
||||
ImGui::Checkbox("TAA", &mSettings.view.taa.enabled);
|
||||
// this clutters the UI and isn't that useful (except when working on TAA)
|
||||
//ImGui::Indent();
|
||||
@@ -758,56 +756,74 @@ void ViewerGui::updateUserInterface() {
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::Checkbox("SSAO", &mSettings.view.ssao.enabled);
|
||||
if (ImGui::CollapsingHeader("SSAO Options")) {
|
||||
auto& ssao = mSettings.view.ssao;
|
||||
|
||||
int quality = (int) ssao.quality;
|
||||
int lowpass = (int) ssao.lowPassFilter;
|
||||
bool upsampling = ssao.upsampling != View::QualityLevel::LOW;
|
||||
|
||||
bool halfRes = ssao.resolution != 1.0f;
|
||||
ImGui::SliderInt("Quality", &quality, 0, 3);
|
||||
ImGui::SliderInt("Low Pass", &lowpass, 0, 2);
|
||||
ImGui::Checkbox("Bent Normals", &ssao.bentNormals);
|
||||
ImGui::Checkbox("High quality upsampling", &upsampling);
|
||||
ImGui::SliderFloat("Min Horizon angle", &ssao.minHorizonAngleRad, 0.0f, (float)M_PI_4);
|
||||
ImGui::SliderFloat("Bilateral Threshold", &ssao.bilateralThreshold, 0.0f, 0.1f);
|
||||
ImGui::Checkbox("Half resolution", &halfRes);
|
||||
ssao.resolution = halfRes ? 0.5f : 1.0f;
|
||||
|
||||
|
||||
ssao.upsampling = upsampling ? View::QualityLevel::HIGH : View::QualityLevel::LOW;
|
||||
ssao.lowPassFilter = (View::QualityLevel) lowpass;
|
||||
ssao.quality = (View::QualityLevel) quality;
|
||||
|
||||
if (ImGui::CollapsingHeader("Dominant Light Shadows (experimental)")) {
|
||||
int sampleCount = ssao.ssct.sampleCount;
|
||||
ImGui::Checkbox("Enabled##dls", &ssao.ssct.enabled);
|
||||
ImGui::SliderFloat("Cone angle", &ssao.ssct.lightConeRad, 0.0f, (float)M_PI_2);
|
||||
ImGui::SliderFloat("Shadow Distance", &ssao.ssct.shadowDistance, 0.0f, 10.0f);
|
||||
ImGui::SliderFloat("Contact dist max", &ssao.ssct.contactDistanceMax, 0.0f, 100.0f);
|
||||
ImGui::SliderFloat("Intensity##dls", &ssao.ssct.intensity, 0.0f, 10.0f);
|
||||
ImGui::SliderFloat("Depth bias", &ssao.ssct.depthBias, 0.0f, 1.0f);
|
||||
ImGui::SliderFloat("Depth slope bias", &ssao.ssct.depthSlopeBias, 0.0f, 1.0f);
|
||||
ImGui::SliderInt("Sample Count", &sampleCount, 1, 32);
|
||||
ImGuiExt::DirectionWidget("Direction##dls", ssao.ssct.lightDirection.v);
|
||||
ssao.ssct.sampleCount = sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Screen-space reflections", &mSettings.view.screenSpaceReflections.enabled);
|
||||
if (ImGui::CollapsingHeader("Screen-space reflections Options")) {
|
||||
auto& ssrefl = mSettings.view.screenSpaceReflections;
|
||||
ImGui::SliderFloat("Ray thickness", &ssrefl.thickness, 0.001f, 0.2f);
|
||||
ImGui::SliderFloat("Bias", &ssrefl.bias, 0.001f, 0.5f);
|
||||
ImGui::SliderFloat("Max distance", &ssrefl.maxDistance, 0.1, 10.0f);
|
||||
ImGui::SliderFloat("Stride", &ssrefl.stride, 1.0, 10.0f);
|
||||
}
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::Checkbox("Screen-space Guard Band", &mSettings.view.guardBand.enabled);
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Bloom Options")) {
|
||||
ImGui::SliderFloat("Strength", &mSettings.view.bloom.strength, 0.0f, 1.0f);
|
||||
ImGui::Checkbox("Threshold", &mSettings.view.bloom.threshold);
|
||||
|
||||
float anamorphism = mSettings.view.bloom.anamorphism >= 1.0f ?
|
||||
mSettings.view.bloom.anamorphism - 1.0f : 1.0f - 1.0f / mSettings.view.bloom.anamorphism;
|
||||
ImGui::SliderFloat("Amamorphism", &anamorphism, -32.0f, 32.0f);
|
||||
mSettings.view.bloom.anamorphism = anamorphism >= 0 ?
|
||||
(anamorphism + 1.0f) : 1.0f / (1.0f - anamorphism);
|
||||
|
||||
int levels = mSettings.view.bloom.levels;
|
||||
ImGui::SliderInt("Levels", &levels, 3, 11);
|
||||
mSettings.view.bloom.levels = levels;
|
||||
|
||||
ImGui::Checkbox("Lens Flare", &mSettings.view.bloom.lensFlare);
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("SSAO Options")) {
|
||||
auto& ssao = mSettings.view.ssao;
|
||||
|
||||
int quality = (int) ssao.quality;
|
||||
int lowpass = (int) ssao.lowPassFilter;
|
||||
bool upsampling = ssao.upsampling != View::QualityLevel::LOW;
|
||||
|
||||
bool halfRes = ssao.resolution != 1.0f;
|
||||
ImGui::SliderInt("Quality", &quality, 0, 3);
|
||||
ImGui::SliderInt("Low Pass", &lowpass, 0, 2);
|
||||
ImGui::Checkbox("Bent Normals", &ssao.bentNormals);
|
||||
ImGui::Checkbox("High quality upsampling", &upsampling);
|
||||
ImGui::SliderFloat("Min Horizon angle", &ssao.minHorizonAngleRad, 0.0f, (float)M_PI_4);
|
||||
ImGui::SliderFloat("Bilateral Threshold", &ssao.bilateralThreshold, 0.0f, 0.1f);
|
||||
ImGui::Checkbox("Half resolution", &halfRes);
|
||||
ssao.resolution = halfRes ? 0.5f : 1.0f;
|
||||
|
||||
ssao.upsampling = upsampling ? View::QualityLevel::HIGH : View::QualityLevel::LOW;
|
||||
ssao.lowPassFilter = (View::QualityLevel) lowpass;
|
||||
ssao.quality = (View::QualityLevel) quality;
|
||||
|
||||
if (ImGui::CollapsingHeader("Dominant Light Shadows (experimental)")) {
|
||||
int sampleCount = ssao.ssct.sampleCount;
|
||||
ImGui::Checkbox("Enabled##dls", &ssao.ssct.enabled);
|
||||
ImGui::SliderFloat("Cone angle", &ssao.ssct.lightConeRad, 0.0f, (float)M_PI_2);
|
||||
ImGui::SliderFloat("Shadow Distance", &ssao.ssct.shadowDistance, 0.0f, 10.0f);
|
||||
ImGui::SliderFloat("Contact dist max", &ssao.ssct.contactDistanceMax, 0.0f, 100.0f);
|
||||
ImGui::SliderFloat("Intensity##dls", &ssao.ssct.intensity, 0.0f, 10.0f);
|
||||
ImGui::SliderFloat("Depth bias", &ssao.ssct.depthBias, 0.0f, 1.0f);
|
||||
ImGui::SliderFloat("Depth slope bias", &ssao.ssct.depthSlopeBias, 0.0f, 1.0f);
|
||||
ImGui::SliderInt("Sample Count", &sampleCount, 1, 32);
|
||||
ImGuiExt::DirectionWidget("Direction##dls", ssao.ssct.lightDirection.v);
|
||||
ssao.ssct.sampleCount = sampleCount;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Screen-space reflections Options")) {
|
||||
auto& ssrefl = mSettings.view.screenSpaceReflections;
|
||||
ImGui::SliderFloat("Ray thickness", &ssrefl.thickness, 0.001f, 0.2f);
|
||||
ImGui::SliderFloat("Bias", &ssrefl.bias, 0.001f, 0.5f);
|
||||
ImGui::SliderFloat("Max distance", &ssrefl.maxDistance, 0.1, 10.0f);
|
||||
ImGui::SliderFloat("Stride", &ssrefl.stride, 1.0, 10.0f);
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Dynamic Resolution")) {
|
||||
auto& dsr = mSettings.view.dsr;
|
||||
int quality = (int)dsr.quality;
|
||||
|
||||
@@ -19,7 +19,7 @@ Filament.loadGeneratedExtensions = function() {
|
||||
// JavaScript binding for dirt is not yet supported, must use default value.
|
||||
// JavaScript binding for dirtStrength is not yet supported, must use default value.
|
||||
strength: 0.10,
|
||||
resolution: 360,
|
||||
resolution: 384,
|
||||
anamorphism: 1.0,
|
||||
levels: 6,
|
||||
blendMode: Filament.View$BloomOptions$BlendMode.ADD,
|
||||
@@ -182,4 +182,11 @@ Filament.loadGeneratedExtensions = function() {
|
||||
return Object.assign(options, overrides);
|
||||
};
|
||||
|
||||
Filament.View.prototype.setStereoscopicOptionsDefaults = function(overrides) {
|
||||
const options = {
|
||||
enabled: false,
|
||||
};
|
||||
return Object.assign(options, overrides);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
9
web/filament-js/filament.d.ts
vendored
9
web/filament-js/filament.d.ts
vendored
@@ -1234,7 +1234,7 @@ export interface View$BloomOptions {
|
||||
*/
|
||||
anamorphism?: number;
|
||||
/**
|
||||
* number of blur levels (3 to 11)
|
||||
* number of blur levels (1 to 11)
|
||||
*/
|
||||
levels?: number;
|
||||
/**
|
||||
@@ -1770,3 +1770,10 @@ export interface View$SoftShadowOptions {
|
||||
*/
|
||||
penumbraRatioScale?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for stereoscopic (multi-eye) rendering.
|
||||
*/
|
||||
export interface View$StereoscopicOptions {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -148,4 +148,8 @@ value_object<View::SoftShadowOptions>("View$SoftShadowOptions")
|
||||
.field("penumbraRatioScale", &View::SoftShadowOptions::penumbraRatioScale)
|
||||
;
|
||||
|
||||
value_object<View::StereoscopicOptions>("View$StereoscopicOptions")
|
||||
.field("enabled", &View::StereoscopicOptions::enabled)
|
||||
;
|
||||
|
||||
} // EMSCRIPTEN_BINDINGS
|
||||
|
||||
Reference in New Issue
Block a user