mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 14:53:24 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into yellow
This commit is contained in:
commit
fdf06ea819
5 changed files with 95 additions and 91 deletions
libraries
render-utils/src
shared/src
|
@ -37,7 +37,6 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 albedo, float roughness
|
|||
_fragColor0 = vec4(albedo, mix(packShadedMetallic(metallic), packScatteringMetallic(metallic), check));
|
||||
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
|
||||
_fragColor2 = vec4(mix(emissive, vec3(scattering), check), occlusion);
|
||||
|
||||
_fragColor3 = vec4(isEmissiveEnabled() * emissive, 1.0);
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,6 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 albedo, float r
|
|||
_fragColor0 = vec4(albedo, packLightmappedMetallic(metallic));
|
||||
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
|
||||
_fragColor2 = vec4(isLightmapEnabled() * lightmap, 1.0);
|
||||
|
||||
_fragColor3 = vec4(isLightmapEnabled() * lightmap * albedo, 1.0);
|
||||
}
|
||||
|
||||
|
@ -59,7 +57,7 @@ void packDeferredFragmentUnlit(vec3 normal, float alpha, vec3 color) {
|
|||
}
|
||||
_fragColor0 = vec4(color, packUnlit());
|
||||
_fragColor1 = vec4(packNormal(normal), 1.0);
|
||||
// _fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor3 = vec4(color, 1.0);
|
||||
}
|
||||
|
||||
|
@ -69,7 +67,8 @@ void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 albedo, floa
|
|||
}
|
||||
_fragColor0 = vec4(albedo.rgb, alpha);
|
||||
_fragColor1 = vec4(packNormal(normal), clamp(roughness, 0.0, 1.0));
|
||||
|
||||
_fragColor2 = vec4(vec3(0.0), 1.0);
|
||||
_fragColor3 = vec4(0.0);
|
||||
}
|
||||
|
||||
<@endif@>
|
||||
|
|
|
@ -41,33 +41,17 @@ namespace gr {
|
|||
|
||||
using namespace render;
|
||||
|
||||
struct LightLocations {
|
||||
bool shadowTransform{ false };
|
||||
void initialize(const gpu::ShaderPointer& program) {
|
||||
shadowTransform = program->getReflection().validUniformBuffer(ru::Buffer::ShadowParams);
|
||||
}
|
||||
};
|
||||
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& program);
|
||||
|
||||
void DeferredLightingEffect::init() {
|
||||
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
|
||||
_directionalSkyboxLightLocations = std::make_shared<LightLocations>();
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light, false, _directionalAmbientSphereLight);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light, false, _directionalSkyboxLight);
|
||||
|
||||
_directionalAmbientSphereLightShadowLocations = std::make_shared<LightLocations>();
|
||||
_directionalSkyboxLightShadowLocations = std::make_shared<LightLocations>();
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light_shadow, false, _directionalAmbientSphereLightShadow);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light_shadow, false, _directionalSkyboxLightShadow);
|
||||
|
||||
_localLightLocations = std::make_shared<LightLocations>();
|
||||
_localLightOutlineLocations = std::make_shared<LightLocations>();
|
||||
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
||||
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light_shadow, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light_shadow, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
|
||||
|
||||
loadLightProgram(shader::render_utils::program::local_lights_shading, true, _localLight, _localLightLocations);
|
||||
loadLightProgram(shader::render_utils::program::local_lights_drawOutline, true, _localLightOutline, _localLightOutlineLocations);
|
||||
loadLightProgram(shader::render_utils::program::local_lights_shading, true, _localLight);
|
||||
loadLightProgram(shader::render_utils::program::local_lights_drawOutline, true, _localLightOutline);
|
||||
}
|
||||
|
||||
// FIXME: figure out how to move lightFrame into a varying in GeometryCache and RenderPipelines
|
||||
|
@ -123,15 +107,9 @@ void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch) {
|
|||
batch.setUniformBuffer(ru::Buffer::LightClusterFrustumGrid, nullptr);
|
||||
}
|
||||
|
||||
static gpu::ShaderPointer makeLightProgram(int programId, LightLocationsPtr& locations) {
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& pipeline) {
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(programId);
|
||||
locations->initialize(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
|
||||
|
||||
gpu::ShaderPointer program = makeLightProgram(programId, locations);
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setColorWriteMask(true, true, true, false);
|
||||
|
@ -456,7 +434,6 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
|||
|
||||
// Setup the global directional pass pipeline
|
||||
auto program = deferredLightingEffect->_directionalSkyboxLight;
|
||||
LightLocationsPtr locations = deferredLightingEffect->_directionalSkyboxLightLocations;
|
||||
{
|
||||
if (keyLightCastShadows) {
|
||||
|
||||
|
@ -464,20 +441,16 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
|
|||
// otherwise use the ambient sphere version
|
||||
if (hasAmbientMap) {
|
||||
program = deferredLightingEffect->_directionalSkyboxLightShadow;
|
||||
locations = deferredLightingEffect->_directionalSkyboxLightShadowLocations;
|
||||
} else {
|
||||
program = deferredLightingEffect->_directionalAmbientSphereLightShadow;
|
||||
locations = deferredLightingEffect->_directionalAmbientSphereLightShadowLocations;
|
||||
}
|
||||
} else {
|
||||
// If the keylight has an ambient Map then use the Skybox version of the pass
|
||||
// otherwise use the ambient sphere version
|
||||
if (hasAmbientMap) {
|
||||
program = deferredLightingEffect->_directionalSkyboxLight;
|
||||
locations = deferredLightingEffect->_directionalSkyboxLightLocations;
|
||||
} else {
|
||||
program = deferredLightingEffect->_directionalAmbientSphereLight;
|
||||
locations = deferredLightingEffect->_directionalAmbientSphereLightLocations;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,6 @@
|
|||
#include "SubsurfaceScattering.h"
|
||||
#include "AmbientOcclusionEffect.h"
|
||||
|
||||
|
||||
struct LightLocations;
|
||||
using LightLocationsPtr = std::shared_ptr<LightLocations>;
|
||||
|
||||
// THis is where we currently accumulate the local lights, let s change that sooner than later
|
||||
class DeferredLightingEffect : public Dependency {
|
||||
SINGLETON_DEPENDENCY
|
||||
|
@ -72,15 +68,6 @@ private:
|
|||
gpu::PipelinePointer _localLight;
|
||||
gpu::PipelinePointer _localLightOutline;
|
||||
|
||||
LightLocationsPtr _directionalSkyboxLightLocations;
|
||||
LightLocationsPtr _directionalAmbientSphereLightLocations;
|
||||
|
||||
LightLocationsPtr _directionalSkyboxLightShadowLocations;
|
||||
LightLocationsPtr _directionalAmbientSphereLightShadowLocations;
|
||||
|
||||
LightLocationsPtr _localLightLocations;
|
||||
LightLocationsPtr _localLightOutlineLocations;
|
||||
|
||||
friend class LightClusteringPass;
|
||||
friend class RenderDeferredSetup;
|
||||
friend class RenderDeferredLocals;
|
||||
|
|
|
@ -18,7 +18,7 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
|
|||
|
||||
void main(void) {
|
||||
const float depth = 1.0;
|
||||
const vec4 UNIT_QUAD[4] = vec4[4](
|
||||
const mat4 UNIT_QUAD = mat4(
|
||||
vec4(-1.0, -1.0, depth, 1.0),
|
||||
vec4(1.0, -1.0, depth, 1.0),
|
||||
vec4(-1.0, 1.0, depth, 1.0),
|
||||
|
@ -26,7 +26,7 @@ void main(void) {
|
|||
);
|
||||
vec4 pos = UNIT_QUAD[gl_VertexID];
|
||||
|
||||
_texCoord01.xy = (pos.xy + 1.0) * 0.5;
|
||||
_texCoord01 = vec4((pos.xy + 1.0) * 0.5, 0.0, 0.0);
|
||||
|
||||
gl_Position = pos;
|
||||
}
|
||||
|
|
|
@ -115,48 +115,39 @@ protected:
|
|||
const Lambda _triggerHandler;
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
class TypedPreference : public Preference {
|
||||
public:
|
||||
using Getter = std::function<T()>;
|
||||
using Setter = std::function<void(const T&)>;
|
||||
|
||||
TypedPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: Preference(category, name), _getter(getter), _setter(setter) { }
|
||||
|
||||
T getValue() const { return _value; }
|
||||
void setValue(const T& value) { if (_value != value) { _value = value; emitValueChanged(); } }
|
||||
void load() override { _value = _getter(); }
|
||||
void save() const override {
|
||||
T oldValue = _getter();
|
||||
if (_value != oldValue) {
|
||||
_setter(_value);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
T _value;
|
||||
const Getter _getter;
|
||||
const Setter _setter;
|
||||
};
|
||||
|
||||
class BoolPreference : public TypedPreference<bool> {
|
||||
class BoolPreference : public Preference {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool value READ getValue WRITE setValue NOTIFY valueChanged)
|
||||
|
||||
public:
|
||||
using Getter = std::function<bool()>;
|
||||
using Setter = std::function<void(const bool&)>;
|
||||
|
||||
BoolPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: TypedPreference(category, name, getter, setter) { }
|
||||
: Preference(category, name), _getter(getter), _setter(setter) { }
|
||||
|
||||
bool getValue() const { return _value; }
|
||||
void setValue(const bool& value) { if (_value != value) { _value = value; emitValueChanged(); } }
|
||||
void load() override { _value = _getter(); }
|
||||
void save() const override {
|
||||
bool oldValue = _getter();
|
||||
if (_value != oldValue) {
|
||||
_setter(_value);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged();
|
||||
|
||||
protected:
|
||||
bool _value;
|
||||
const Getter _getter;
|
||||
const Setter _setter;
|
||||
|
||||
void emitValueChanged() override { emit valueChanged(); }
|
||||
};
|
||||
|
||||
class FloatPreference : public TypedPreference<float> {
|
||||
class FloatPreference : public Preference {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float value READ getValue WRITE setValue NOTIFY valueChanged)
|
||||
Q_PROPERTY(float min READ getMin CONSTANT)
|
||||
|
@ -165,8 +156,21 @@ class FloatPreference : public TypedPreference<float> {
|
|||
Q_PROPERTY(float decimals READ getDecimals CONSTANT)
|
||||
|
||||
public:
|
||||
using Getter = std::function<float()>;
|
||||
using Setter = std::function<void(const float&)>;
|
||||
|
||||
FloatPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: TypedPreference(category, name, getter, setter) { }
|
||||
: Preference(category, name), _getter(getter), _setter(setter) { }
|
||||
|
||||
float getValue() const { return _value; }
|
||||
void setValue(const float& value) { if (_value != value) { _value = value; emitValueChanged(); } }
|
||||
void load() override { _value = _getter(); }
|
||||
void save() const override {
|
||||
float oldValue = _getter();
|
||||
if (_value != oldValue) {
|
||||
_setter(_value);
|
||||
}
|
||||
}
|
||||
|
||||
float getMin() const { return _min; }
|
||||
void setMin(float min) { _min = min; };
|
||||
|
@ -186,14 +190,17 @@ signals:
|
|||
protected:
|
||||
void emitValueChanged() override { emit valueChanged(); }
|
||||
|
||||
float _value;
|
||||
const Getter _getter;
|
||||
const Setter _setter;
|
||||
|
||||
float _decimals { 0 };
|
||||
float _min { 0 };
|
||||
float _max { 1 };
|
||||
float _step { 0.1f };
|
||||
};
|
||||
|
||||
|
||||
class IntPreference : public TypedPreference<int> {
|
||||
class IntPreference : public Preference {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float value READ getValue WRITE setValue NOTIFY valueChanged)
|
||||
Q_PROPERTY(float min READ getMin CONSTANT)
|
||||
|
@ -202,8 +209,21 @@ class IntPreference : public TypedPreference<int> {
|
|||
Q_PROPERTY(int decimals READ getDecimals CONSTANT)
|
||||
|
||||
public:
|
||||
using Getter = std::function<int()>;
|
||||
using Setter = std::function<void(const int&)>;
|
||||
|
||||
IntPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: TypedPreference(category, name, getter, setter) { }
|
||||
: Preference(category, name), _getter(getter), _setter(setter) { }
|
||||
|
||||
int getValue() const { return _value; }
|
||||
void setValue(const int& value) { if (_value != value) { _value = value; emitValueChanged(); } }
|
||||
void load() override { _value = _getter(); }
|
||||
void save() const override {
|
||||
int oldValue = _getter();
|
||||
if (_value != oldValue) {
|
||||
_setter(_value);
|
||||
}
|
||||
}
|
||||
|
||||
float getMin() const { return _min; }
|
||||
void setMin(float min) { _min = min; };
|
||||
|
@ -221,6 +241,10 @@ signals:
|
|||
void valueChanged();
|
||||
|
||||
protected:
|
||||
int _value;
|
||||
const Getter _getter;
|
||||
const Setter _setter;
|
||||
|
||||
void emitValueChanged() override { emit valueChanged(); }
|
||||
|
||||
int _min { std::numeric_limits<int>::min() };
|
||||
|
@ -229,19 +253,37 @@ protected:
|
|||
int _decimals { 0 };
|
||||
};
|
||||
|
||||
class StringPreference : public TypedPreference<QString> {
|
||||
class StringPreference : public Preference {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString value READ getValue WRITE setValue NOTIFY valueChanged)
|
||||
|
||||
public:
|
||||
using Getter = std::function<QString()>;
|
||||
using Setter = std::function<void(const QString&)>;
|
||||
|
||||
StringPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: TypedPreference(category, name, getter, setter) { }
|
||||
: Preference(category, name), _getter(getter), _setter(setter) { }
|
||||
|
||||
|
||||
QString getValue() const { return _value; }
|
||||
void setValue(const QString& value) { if (_value != value) { _value = value; emitValueChanged(); } }
|
||||
void load() override { _value = _getter(); }
|
||||
void save() const override {
|
||||
QString oldValue = _getter();
|
||||
if (_value != oldValue) {
|
||||
_setter(_value);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged();
|
||||
|
||||
protected:
|
||||
void emitValueChanged() override { emit valueChanged(); }
|
||||
|
||||
QString _value;
|
||||
const Getter _getter;
|
||||
const Setter _setter;
|
||||
};
|
||||
|
||||
class SliderPreference : public FloatPreference {
|
||||
|
@ -303,7 +345,7 @@ public:
|
|||
ComboBoxPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: EditPreference(category, name, getter, setter) { }
|
||||
Type getType() override { return ComboBox; }
|
||||
|
||||
|
||||
const QStringList& getItems() { return _items; }
|
||||
void setItems(const QStringList& items) { _items = items; }
|
||||
|
||||
|
@ -342,6 +384,9 @@ class CheckPreference : public BoolPreference {
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(bool indented READ getIndented CONSTANT)
|
||||
public:
|
||||
using Getter = std::function<bool()>;
|
||||
using Setter = std::function<void(const bool&)>;
|
||||
|
||||
CheckPreference(const QString& category, const QString& name, Getter getter, Setter setter)
|
||||
: BoolPreference(category, name, getter, setter) { }
|
||||
Type getType() override { return Checkbox; }
|
||||
|
|
Loading…
Reference in a new issue