Add DynamicResolution to Settings
update remote ui
This commit is contained in:
committed by
Mathias Agopian
parent
f04864c216
commit
764a0df669
File diff suppressed because one or more lines are too long
Binary file not shown.
@@ -66,6 +66,8 @@ using Dithering = filament::View::Dithering;
|
||||
using FogOptions = filament::View::FogOptions;
|
||||
using RenderQuality = filament::View::RenderQuality;
|
||||
using ShadowType = filament::View::ShadowType;
|
||||
using DynamicResolutionOptions = filament::View::DynamicResolutionOptions;
|
||||
using MultiSampleAntiAliasingOptions = filament::View::MultiSampleAntiAliasingOptions;
|
||||
using TemporalAntiAliasingOptions = filament::View::TemporalAntiAliasingOptions;
|
||||
using VignetteOptions = filament::View::VignetteOptions;
|
||||
using VsmShadowOptions = filament::View::VsmShadowOptions;
|
||||
@@ -156,6 +158,7 @@ struct ViewSettings {
|
||||
TemporalAntiAliasingOptions taa;
|
||||
ColorGradingSettings colorGrading;
|
||||
AmbientOcclusionOptions ssao;
|
||||
DynamicResolutionOptions dsr;
|
||||
BloomOptions bloom;
|
||||
FogOptions fog;
|
||||
DepthOfFieldOptions dof;
|
||||
|
||||
@@ -121,6 +121,13 @@ static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, bool* va
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, math::float2* val) {
|
||||
float values[2];
|
||||
i = parse(tokens, i, jsonChunk, values, 2);
|
||||
*val = {values[0], values[1]};
|
||||
return i;
|
||||
}
|
||||
|
||||
static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, math::float3* val) {
|
||||
float values[3];
|
||||
i = parse(tokens, i, jsonChunk, values, 3);
|
||||
@@ -241,6 +248,37 @@ static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk,
|
||||
return i;
|
||||
}
|
||||
|
||||
static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk,
|
||||
DynamicResolutionOptions* 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 if (compare(tok, jsonChunk, "minScale") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->minScale);
|
||||
} else if (compare(tok, jsonChunk, "maxScale") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->maxScale);
|
||||
} else if (compare(tok, jsonChunk, "sharpness") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->sharpness);
|
||||
} else if (compare(tok, jsonChunk, "quality") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->quality);
|
||||
} else if (compare(tok, jsonChunk, "homogeneousScaling") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->homogeneousScaling);
|
||||
} else {
|
||||
slog.w << "Invalid dsr key: '" << STR(tok, jsonChunk) << "'" << io::endl;
|
||||
i = parse(tokens, i + 1);
|
||||
}
|
||||
if (i < 0) {
|
||||
slog.e << "Invalid dsr value: '" << STR(tok, jsonChunk) << "'" << io::endl;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk,
|
||||
MultiSampleAntiAliasingOptions* out) {
|
||||
CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
|
||||
@@ -695,6 +733,8 @@ static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, ViewSett
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->msaa);
|
||||
} else if (compare(tok, jsonChunk, "taa") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->taa);
|
||||
} else if (compare(tok, jsonChunk, "dsr") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->dsr);
|
||||
} else if (compare(tok, jsonChunk, "colorGrading") == 0) {
|
||||
i = parse(tokens, i + 1, jsonChunk, &out->colorGrading);
|
||||
} else if (compare(tok, jsonChunk, "ssao") == 0) {
|
||||
@@ -944,6 +984,7 @@ void applySettings(const ViewSettings& settings, View* dest) {
|
||||
dest->setAntiAliasing(settings.antiAliasing);
|
||||
dest->setTemporalAntiAliasingOptions(settings.taa);
|
||||
dest->setMultiSampleAntiAliasingOptions(settings.msaa);
|
||||
dest->setDynamicResolutionOptions(settings.dsr);
|
||||
dest->setAmbientOcclusionOptions(settings.ssao);
|
||||
dest->setBloomOptions(settings.bloom);
|
||||
dest->setFogOptions(settings.fog);
|
||||
@@ -1154,12 +1195,27 @@ static std::ostream& writeJson(std::ostream& oss, const float* v, int count) {
|
||||
return oss;
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& out, math::float2 v) {
|
||||
return writeJson(out, v.v, 2);
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& out, math::float3 v) {
|
||||
return writeJson(out, &v.x, 3);
|
||||
return writeJson(out, v.v, 3);
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& out, math::float4 v) {
|
||||
return writeJson(out, &v.x, 4);
|
||||
return writeJson(out, v.v, 4);
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& out, const DynamicResolutionOptions& in) {
|
||||
return out << "{\n"
|
||||
<< "\"enabled\": " << to_string(in.enabled) << ",\n"
|
||||
<< "\"minScale\": " << in.minScale << ",\n"
|
||||
<< "\"maxScale\": " << in.maxScale << ",\n"
|
||||
<< "\"sharpness\": " << in.sharpness << ",\n"
|
||||
<< "\"quality\": " << in.quality << ",\n"
|
||||
<< "\"homogeneousScaling\": " << to_string(in.homogeneousScaling) << "\n"
|
||||
<< "}";
|
||||
}
|
||||
|
||||
static std::ostream& operator<<(std::ostream& out, const MultiSampleAntiAliasingOptions& in) {
|
||||
@@ -1426,6 +1482,7 @@ static std::ostream& operator<<(std::ostream& out, const ViewSettings& in) {
|
||||
<< "\"antiAliasing\": " << in.antiAliasing << ",\n"
|
||||
<< "\"msaa\": " << in.msaa << ",\n"
|
||||
<< "\"taa\": " << in.taa << ",\n"
|
||||
<< "\"dsr\": " << in.dsr << ",\n"
|
||||
<< "\"colorGrading\": " << (in.colorGrading) << ",\n"
|
||||
<< "\"ssao\": " << (in.ssao) << ",\n"
|
||||
<< "\"bloom\": " << (in.bloom) << ",\n"
|
||||
|
||||
@@ -733,6 +733,21 @@ void SimpleViewer::updateUserInterface() {
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Dynamic Resolution")) {
|
||||
auto& dsr = mSettings.view.dsr;
|
||||
int quality = (int)dsr.quality;
|
||||
ImGui::Checkbox("enabled", &dsr.enabled);
|
||||
ImGui::Checkbox("homogeneous", &dsr.homogeneousScaling);
|
||||
ImGui::SliderFloat("min. scale", &dsr.minScale.x, 0.25f, 1.0f);
|
||||
ImGui::SliderFloat("max. scale", &dsr.maxScale.x, 0.25f, 1.0f);
|
||||
ImGui::SliderInt("quality", &quality, 0, 3);
|
||||
ImGui::SliderFloat("sharpness", &dsr.sharpness, 0.0f, 1.0f);
|
||||
dsr.minScale.x = std::min(dsr.minScale.x, dsr.maxScale.x);
|
||||
dsr.minScale.y = dsr.minScale.x;
|
||||
dsr.maxScale.y = dsr.maxScale.x;
|
||||
dsr.quality = (QualityLevel)quality;
|
||||
}
|
||||
|
||||
auto& light = mSettings.lighting;
|
||||
if (ImGui::CollapsingHeader("Light")) {
|
||||
ImGui::Indent();
|
||||
|
||||
@@ -37,6 +37,15 @@ static const char* JSON_TEST_DEFAULTS = R"TXT(
|
||||
"sampleCount": 4,
|
||||
"customResolve": false
|
||||
},
|
||||
"dsr": {
|
||||
"enabled": false,
|
||||
"minScale": [0.25, 0.25],
|
||||
"maxScale": [1.0, 1.0],
|
||||
"sharpness": 0.9,
|
||||
"enabled": false,
|
||||
"homogeneousScaling": false,
|
||||
"quality": "MEDIUM"
|
||||
},
|
||||
"colorGrading": {
|
||||
"enabled": true,
|
||||
"quality": "MEDIUM",
|
||||
|
||||
@@ -343,11 +343,6 @@ static void createGroundPlane(Engine* engine, Scene* scene, App& app) {
|
||||
app.scene.groundMaterial = shadowMaterial;
|
||||
}
|
||||
|
||||
static float sGlobalScale = 1.0f;
|
||||
static float sGlobalScaleAnamorphism = 0.0f;
|
||||
static int sGlobalScaleQuality = 0;
|
||||
static float sGlobalScaleSharpness = 0.9f;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
App app;
|
||||
|
||||
@@ -575,11 +570,6 @@ int main(int argc, char** argv) {
|
||||
debug.getPropertyAddress<bool>("d.renderer.doFrameCapture");
|
||||
*captureFrame = true;
|
||||
}
|
||||
ImGui::SliderFloat("scale", &sGlobalScale, 0.25f, 1.0f);
|
||||
ImGui::SliderFloat("anamorphism", &sGlobalScaleAnamorphism, -1.0f, 1.0f);
|
||||
ImGui::SliderInt("quality", &sGlobalScaleQuality, 0, 3);
|
||||
ImGui::SliderFloat("sharpness", &sGlobalScaleSharpness, 0.0f, 1.0f);
|
||||
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal("MessageBox", NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
@@ -691,24 +681,6 @@ int main(int argc, char** argv) {
|
||||
} else {
|
||||
view->setColorGrading(nullptr);
|
||||
}
|
||||
|
||||
view->setDynamicResolutionOptions({
|
||||
.minScale = {
|
||||
lerp(sGlobalScale, 1.0f,
|
||||
sGlobalScaleAnamorphism >= 0.0f ? sGlobalScaleAnamorphism : 0.0f),
|
||||
lerp(sGlobalScale, 1.0f,
|
||||
sGlobalScaleAnamorphism <= 0.0f ? -sGlobalScaleAnamorphism : 0.0f),
|
||||
},
|
||||
.maxScale = {
|
||||
lerp(sGlobalScale, 1.0f,
|
||||
sGlobalScaleAnamorphism >= 0.0f ? sGlobalScaleAnamorphism : 0.0f),
|
||||
lerp(sGlobalScale, 1.0f,
|
||||
sGlobalScaleAnamorphism <= 0.0f ? -sGlobalScaleAnamorphism : 0.0f),
|
||||
},
|
||||
.sharpness = sGlobalScaleSharpness,
|
||||
.enabled = sGlobalScale != 1.0f,
|
||||
.quality = (QualityLevel)sGlobalScaleQuality
|
||||
});
|
||||
};
|
||||
|
||||
auto postRender = [&app](Engine* engine, View* view, Scene* scene, Renderer* renderer) {
|
||||
|
||||
Reference in New Issue
Block a user