mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 07:44:11 +02:00
Added some fill parameters. Still need to fix issues with blur changing with screen aspect ratio
This commit is contained in:
parent
0f2c41b009
commit
392a99f038
6 changed files with 119 additions and 45 deletions
|
@ -28,15 +28,25 @@ const float FAR_DISTANCE = 1.0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x;
|
float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x;
|
||||||
|
float intensity = 0.0;
|
||||||
|
|
||||||
if (outlinedDepth < FAR_DISTANCE) {
|
if (outlinedDepth < FAR_DISTANCE) {
|
||||||
// We're not on the far plane so we are on the outlined object, thus no outline to do!
|
// We're not on the far plane so we are on the outlined object, thus no outline to do!
|
||||||
discard;
|
|
||||||
}
|
|
||||||
|
|
||||||
//float sceneDepth = texture(sceneDepthMap, varTexCoord0).x;
|
// But maybe we need to fill the interior
|
||||||
float outlineIntensity = 0.0;
|
if (params._fillOpacityUnoccluded>1e-3 && params._fillOpacityUnoccluded>1e-3) {
|
||||||
float weight = 0.0;
|
// Are we occluded?
|
||||||
{
|
float sceneDepth = texture(sceneDepthMap, varTexCoord0).x;
|
||||||
|
if (sceneDepth < outlinedDepth) {
|
||||||
|
intensity = params._fillOpacityOccluded;
|
||||||
|
} else {
|
||||||
|
intensity = params._fillOpacityUnoccluded;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
float weight = 0.0;
|
||||||
const float deltaUv = params._size / BLUR_KERNEL_SIZE;
|
const float deltaUv = params._size / BLUR_KERNEL_SIZE;
|
||||||
vec2 uv;
|
vec2 uv;
|
||||||
vec2 startUv = varTexCoord0 - vec2(params._size, params._size) / 2.0;
|
vec2 startUv = varTexCoord0 - vec2(params._size, params._size) / 2.0;
|
||||||
|
@ -52,7 +62,7 @@ void main(void) {
|
||||||
if (uv.x>=0.0 && uv.x<=1.0)
|
if (uv.x>=0.0 && uv.x<=1.0)
|
||||||
{
|
{
|
||||||
outlinedDepth = texture(outlinedDepthMap, uv).x;
|
outlinedDepth = texture(outlinedDepthMap, uv).x;
|
||||||
outlineIntensity += (outlinedDepth < FAR_DISTANCE) ? 1.0 : 0.0;
|
intensity += (outlinedDepth < FAR_DISTANCE) ? 1.0 : 0.0;
|
||||||
weight += 1.f;
|
weight += 1.f;
|
||||||
}
|
}
|
||||||
uv.x += deltaUv;
|
uv.x += deltaUv;
|
||||||
|
@ -60,12 +70,14 @@ void main(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
outlineIntensity /= weight;
|
intensity /= weight;
|
||||||
|
|
||||||
|
if (intensity < 1e-3) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
|
intensity = min(1.0, intensity / params._threshold) * params._intensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outlineIntensity < 1e-3) {
|
outFragColor = vec4(params._color.rgb, intensity);
|
||||||
discard;
|
|
||||||
}
|
|
||||||
outlineIntensity = min(1.0, outlineIntensity * params._intensity);
|
|
||||||
outFragColor = vec4(params._color.rgb, outlineIntensity);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,10 @@ DrawOutline::DrawOutline() {
|
||||||
void DrawOutline::configure(const Config& config) {
|
void DrawOutline::configure(const Config& config) {
|
||||||
_color = config.color;
|
_color = config.color;
|
||||||
_size = config.width / 1024.f;
|
_size = config.width / 1024.f;
|
||||||
_intensity = config.intensity * 10.f;
|
_fillOpacityUnoccluded = config.fillOpacityUnoccluded;
|
||||||
|
_fillOpacityOccluded = config.fillOpacityOccluded;
|
||||||
|
_threshold = config.glow ? 1.f : 0.f;
|
||||||
|
_intensity = config.intensity * (config.glow ? 2.f : 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOutline::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
void DrawOutline::run(const render::RenderContextPointer& renderContext, const Inputs& inputs) {
|
||||||
|
@ -150,6 +153,9 @@ void DrawOutline::run(const render::RenderContextPointer& renderContext, const I
|
||||||
configuration._color = _color;
|
configuration._color = _color;
|
||||||
configuration._size = _size;
|
configuration._size = _size;
|
||||||
configuration._intensity = _intensity;
|
configuration._intensity = _intensity;
|
||||||
|
configuration._fillOpacityUnoccluded = _fillOpacityUnoccluded;
|
||||||
|
configuration._fillOpacityOccluded = _fillOpacityOccluded;
|
||||||
|
configuration._threshold = _threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
|
||||||
|
|
|
@ -75,11 +75,15 @@ private:
|
||||||
|
|
||||||
class DrawOutlineConfig : public render::Job::Config {
|
class DrawOutlineConfig : public render::Job::Config {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool glow MEMBER glow NOTIFY dirty)
|
||||||
Q_PROPERTY(float width MEMBER width NOTIFY dirty)
|
Q_PROPERTY(float width MEMBER width NOTIFY dirty)
|
||||||
Q_PROPERTY(float intensity MEMBER intensity NOTIFY dirty)
|
Q_PROPERTY(float intensity MEMBER intensity NOTIFY dirty)
|
||||||
Q_PROPERTY(float colorR READ getColorR WRITE setColorR NOTIFY dirty)
|
Q_PROPERTY(float colorR READ getColorR WRITE setColorR NOTIFY dirty)
|
||||||
Q_PROPERTY(float colorG READ getColorG WRITE setColorG NOTIFY dirty)
|
Q_PROPERTY(float colorG READ getColorG WRITE setColorG NOTIFY dirty)
|
||||||
Q_PROPERTY(float colorB READ getColorB WRITE setColorB NOTIFY dirty)
|
Q_PROPERTY(float colorB READ getColorB WRITE setColorB NOTIFY dirty)
|
||||||
|
Q_PROPERTY(float fillOpacityUnoccluded MEMBER fillOpacityUnoccluded NOTIFY dirty)
|
||||||
|
Q_PROPERTY(float fillOpacityOccluded MEMBER fillOpacityOccluded NOTIFY dirty)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void setColorR(float value) { color.r = value; emit dirty(); }
|
void setColorR(float value) { color.r = value; emit dirty(); }
|
||||||
|
@ -94,6 +98,9 @@ public:
|
||||||
glm::vec3 color{ 1.f, 0.7f, 0.2f };
|
glm::vec3 color{ 1.f, 0.7f, 0.2f };
|
||||||
float width{ 5.f };
|
float width{ 5.f };
|
||||||
float intensity{ 1.f };
|
float intensity{ 1.f };
|
||||||
|
float fillOpacityUnoccluded{ 0.35f };
|
||||||
|
float fillOpacityOccluded{ 0.1f };
|
||||||
|
bool glow{ false };
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dirty();
|
void dirty();
|
||||||
|
@ -128,6 +135,9 @@ private:
|
||||||
glm::vec3 _color;
|
glm::vec3 _color;
|
||||||
float _size;
|
float _size;
|
||||||
float _intensity;
|
float _intensity;
|
||||||
|
float _fillOpacityUnoccluded;
|
||||||
|
float _fillOpacityOccluded;
|
||||||
|
float _threshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebugOutlineConfig : public render::Job::Config {
|
class DebugOutlineConfig : public render::Job::Config {
|
||||||
|
|
|
@ -10,6 +10,9 @@ struct OutlineParameters
|
||||||
VEC3 _color;
|
VEC3 _color;
|
||||||
float _size;
|
float _size;
|
||||||
float _intensity;
|
float _intensity;
|
||||||
|
float _fillOpacityUnoccluded;
|
||||||
|
float _fillOpacityOccluded;
|
||||||
|
float _threshold;
|
||||||
};
|
};
|
||||||
|
|
||||||
// <@if 1@>
|
// <@if 1@>
|
||||||
|
|
|
@ -14,7 +14,7 @@ var qml = Script.resolvePath('outline.qml');
|
||||||
var window = new OverlayWindow({
|
var window = new OverlayWindow({
|
||||||
title: 'Outline',
|
title: 'Outline',
|
||||||
source: qml,
|
source: qml,
|
||||||
width: 250,
|
width: 285,
|
||||||
height: 250,
|
height: 370,
|
||||||
});
|
});
|
||||||
window.closed.connect(function() { Script.stop(); });
|
window.closed.connect(function() { Script.stop(); });
|
|
@ -35,6 +35,13 @@ Item {
|
||||||
root.debugConfig["viewOutlinedDepth"] = checked;
|
root.debugConfig["viewOutlinedDepth"] = checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Glow"
|
||||||
|
checked: root.drawConfig["glow"]
|
||||||
|
onCheckedChanged: {
|
||||||
|
root.drawConfig["glow"] = checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
ConfigSlider {
|
ConfigSlider {
|
||||||
label: "Width"
|
label: "Width"
|
||||||
integral: false
|
integral: false
|
||||||
|
@ -42,7 +49,7 @@ Item {
|
||||||
property: "width"
|
property: "width"
|
||||||
max: 15.0
|
max: 15.0
|
||||||
min: 0.0
|
min: 0.0
|
||||||
width: 230
|
width: 280
|
||||||
}
|
}
|
||||||
ConfigSlider {
|
ConfigSlider {
|
||||||
label: "Intensity"
|
label: "Intensity"
|
||||||
|
@ -51,34 +58,70 @@ Item {
|
||||||
property: "intensity"
|
property: "intensity"
|
||||||
max: 1.0
|
max: 1.0
|
||||||
min: 0.0
|
min: 0.0
|
||||||
width: 230
|
width: 280
|
||||||
}
|
|
||||||
ConfigSlider {
|
|
||||||
label: "Color R"
|
|
||||||
integral: false
|
|
||||||
config: root.drawConfig
|
|
||||||
property: "colorR"
|
|
||||||
max: 1.0
|
|
||||||
min: 0.0
|
|
||||||
width: 230
|
|
||||||
}
|
|
||||||
ConfigSlider {
|
|
||||||
label: "Color G"
|
|
||||||
integral: false
|
|
||||||
config: root.drawConfig
|
|
||||||
property: "colorG"
|
|
||||||
max: 1.0
|
|
||||||
min: 0.0
|
|
||||||
width: 230
|
|
||||||
}
|
|
||||||
ConfigSlider {
|
|
||||||
label: "Color B"
|
|
||||||
integral: false
|
|
||||||
config: root.drawConfig
|
|
||||||
property: "colorB"
|
|
||||||
max: 1.0
|
|
||||||
min: 0.0
|
|
||||||
width: 230
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GroupBox {
|
||||||
|
title: "Color"
|
||||||
|
width: 280
|
||||||
|
Column {
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
ConfigSlider {
|
||||||
|
label: "Red"
|
||||||
|
integral: false
|
||||||
|
config: root.drawConfig
|
||||||
|
property: "colorR"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
width: 270
|
||||||
|
}
|
||||||
|
ConfigSlider {
|
||||||
|
label: "Green"
|
||||||
|
integral: false
|
||||||
|
config: root.drawConfig
|
||||||
|
property: "colorG"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
width: 270
|
||||||
|
}
|
||||||
|
ConfigSlider {
|
||||||
|
label: "Blue"
|
||||||
|
integral: false
|
||||||
|
config: root.drawConfig
|
||||||
|
property: "colorB"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
width: 270
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupBox {
|
||||||
|
title: "Fill Opacity"
|
||||||
|
width: 280
|
||||||
|
Column {
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
ConfigSlider {
|
||||||
|
label: "Unoccluded"
|
||||||
|
integral: false
|
||||||
|
config: root.drawConfig
|
||||||
|
property: "fillOpacityUnoccluded"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
width: 270
|
||||||
|
}
|
||||||
|
ConfigSlider {
|
||||||
|
label: "Occluded"
|
||||||
|
integral: false
|
||||||
|
config: root.drawConfig
|
||||||
|
property: "fillOpacityOccluded"
|
||||||
|
max: 1.0
|
||||||
|
min: 0.0
|
||||||
|
width: 270
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue