mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:29:40 +02:00
Merge pull request #6711 from samcake/hdr
Graphics : Fix procedural Shader Gamma and Adding color linear getters in Particle system
This commit is contained in:
commit
e3ab230638
7 changed files with 19 additions and 14 deletions
|
@ -223,10 +223,10 @@ void RenderableParticleEffectEntityItem::updateRenderItem() {
|
||||||
particleUniforms.radius.middle = getParticleRadius();
|
particleUniforms.radius.middle = getParticleRadius();
|
||||||
particleUniforms.radius.finish = getRadiusFinish();
|
particleUniforms.radius.finish = getRadiusFinish();
|
||||||
particleUniforms.radius.spread = getRadiusSpread();
|
particleUniforms.radius.spread = getRadiusSpread();
|
||||||
particleUniforms.color.start = toGlm(getColorStart(), getAlphaStart());
|
particleUniforms.color.start = glm::vec4(getColorStartRGB(), getAlphaStart());
|
||||||
particleUniforms.color.middle = toGlm(getXColor(), getAlpha());
|
particleUniforms.color.middle = glm::vec4(getColorRGB(), getAlpha());
|
||||||
particleUniforms.color.finish = toGlm(getColorFinish(), getAlphaFinish());
|
particleUniforms.color.finish = glm::vec4(getColorFinishRGB(), getAlphaFinish());
|
||||||
particleUniforms.color.spread = toGlm(getColorSpread(), getAlphaSpread());
|
particleUniforms.color.spread = glm::vec4(getColorSpreadRGB(), getAlphaSpread());
|
||||||
particleUniforms.lifespan = getLifespan();
|
particleUniforms.lifespan = getLifespan();
|
||||||
|
|
||||||
// Build particle primitives
|
// Build particle primitives
|
||||||
|
|
|
@ -9,16 +9,15 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
<@include gpu/Inputs.slh@>
|
<@include gpu/Inputs.slh@>
|
||||||
|
<@include gpu/Color.slh@>
|
||||||
<@include gpu/Transform.slh@>
|
<@include gpu/Transform.slh@>
|
||||||
|
|
||||||
<$declareStandardTransform()$>
|
<$declareStandardTransform()$>
|
||||||
|
|
||||||
out vec4 _color;
|
out vec4 _color;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// pass along the diffuse color
|
// pass along the diffuse color
|
||||||
_color = inColor;
|
_color = colorToLinearRGBA(inColor);
|
||||||
|
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
TransformObject obj = getTransformObject();
|
TransformObject obj = getTransformObject();
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
#include "EntityItem.h"
|
#include "EntityItem.h"
|
||||||
|
|
||||||
|
#include "ColorUtils.h"
|
||||||
|
|
||||||
class ParticleEffectEntityItem : public EntityItem {
|
class ParticleEffectEntityItem : public EntityItem {
|
||||||
public:
|
public:
|
||||||
ALLOW_INSTANTIATION // This class can be instantiated
|
ALLOW_INSTANTIATION // This class can be instantiated
|
||||||
|
@ -47,6 +49,7 @@ public:
|
||||||
|
|
||||||
const rgbColor& getColor() const { return _color; }
|
const rgbColor& getColor() const { return _color; }
|
||||||
xColor getXColor() const { xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; }
|
xColor getXColor() const { xColor color = { _color[RED_INDEX], _color[GREEN_INDEX], _color[BLUE_INDEX] }; return color; }
|
||||||
|
glm::vec3 getColorRGB() const { return ColorUtils::toLinearVec3(toGlm(getXColor())); }
|
||||||
|
|
||||||
static const xColor DEFAULT_COLOR;
|
static const xColor DEFAULT_COLOR;
|
||||||
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
void setColor(const rgbColor& value) { memcpy(_color, value, sizeof(_color)); }
|
||||||
|
@ -59,14 +62,17 @@ public:
|
||||||
bool _isColorStartInitialized = false;
|
bool _isColorStartInitialized = false;
|
||||||
void setColorStart(const xColor& colorStart) { _colorStart = colorStart; _isColorStartInitialized = true; }
|
void setColorStart(const xColor& colorStart) { _colorStart = colorStart; _isColorStartInitialized = true; }
|
||||||
xColor getColorStart() const { return _isColorStartInitialized ? _colorStart : getXColor(); }
|
xColor getColorStart() const { return _isColorStartInitialized ? _colorStart : getXColor(); }
|
||||||
|
glm::vec3 getColorStartRGB() const { return _isColorStartInitialized ? ColorUtils::toLinearVec3(toGlm(_colorStart)) : getColorRGB(); }
|
||||||
|
|
||||||
bool _isColorFinishInitialized = false;
|
bool _isColorFinishInitialized = false;
|
||||||
void setColorFinish(const xColor& colorFinish) { _colorFinish = colorFinish; _isColorFinishInitialized = true; }
|
void setColorFinish(const xColor& colorFinish) { _colorFinish = colorFinish; _isColorFinishInitialized = true; }
|
||||||
xColor getColorFinish() const { return _isColorFinishInitialized ? _colorFinish : getXColor(); }
|
xColor getColorFinish() const { return _isColorFinishInitialized ? _colorFinish : getXColor(); }
|
||||||
|
glm::vec3 getColorFinishRGB() const { return _isColorStartInitialized ? ColorUtils::toLinearVec3(toGlm(_colorFinish)) : getColorRGB(); }
|
||||||
|
|
||||||
static const xColor DEFAULT_COLOR_SPREAD;
|
static const xColor DEFAULT_COLOR_SPREAD;
|
||||||
void setColorSpread(const xColor& colorSpread) { _colorSpread = colorSpread; }
|
void setColorSpread(const xColor& colorSpread) { _colorSpread = colorSpread; }
|
||||||
xColor getColorSpread() const { return _colorSpread; }
|
xColor getColorSpread() const { return _colorSpread; }
|
||||||
|
glm::vec3 getColorSpreadRGB() const { return ColorUtils::toLinearVec3(toGlm(_colorSpread)); }
|
||||||
|
|
||||||
static const float MAXIMUM_ALPHA;
|
static const float MAXIMUM_ALPHA;
|
||||||
static const float MINIMUM_ALPHA;
|
static const float MINIMUM_ALPHA;
|
||||||
|
|
|
@ -35,6 +35,8 @@ void main(void) {
|
||||||
#ifdef PROCEDURAL
|
#ifdef PROCEDURAL
|
||||||
|
|
||||||
vec3 color = getSkyboxColor();
|
vec3 color = getSkyboxColor();
|
||||||
|
// Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline
|
||||||
|
color = pow(color, vec3(2.2));
|
||||||
_fragColor = vec4(color, 0.0);
|
_fragColor = vec4(color, 0.0);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -42,7 +44,6 @@ void main(void) {
|
||||||
vec3 coord = normalize(_normal);
|
vec3 coord = normalize(_normal);
|
||||||
vec3 texel = texture(cubeMap, coord).rgb;
|
vec3 texel = texture(cubeMap, coord).rgb;
|
||||||
vec3 color = texel * _skybox._color.rgb;
|
vec3 color = texel * _skybox._color.rgb;
|
||||||
// vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
|
|
||||||
_fragColor = vec4(color, 0.0);
|
_fragColor = vec4(color, 0.0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,7 +54,6 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
_jobs.push_back(Job(new FetchItems::JobModel("FetchOpaque",
|
_jobs.push_back(Job(new FetchItems::JobModel("FetchOpaque",
|
||||||
FetchItems([](const RenderContextPointer& context, int count) {
|
FetchItems([](const RenderContextPointer& context, int count) {
|
||||||
context->getItemsConfig().opaque.numFeed = count;
|
context->getItemsConfig().opaque.numFeed = count;
|
||||||
auto& opaque = context->getItemsConfig().opaque;
|
|
||||||
})
|
})
|
||||||
)));
|
)));
|
||||||
_jobs.push_back(Job(new CullItemsOpaque::JobModel("CullOpaque", _jobs.back().getOutput())));
|
_jobs.push_back(Job(new CullItemsOpaque::JobModel("CullOpaque", _jobs.back().getOutput())));
|
||||||
|
@ -105,12 +104,12 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
|
|
||||||
// Lighting Buffer ready for tone mapping
|
// Lighting Buffer ready for tone mapping
|
||||||
_jobs.push_back(Job(new ToneMappingDeferred::JobModel("ToneMapping")));
|
_jobs.push_back(Job(new ToneMappingDeferred::JobModel("ToneMapping")));
|
||||||
_toneMappingJobIndex = _jobs.size() - 1;
|
_toneMappingJobIndex = (int)_jobs.size() - 1;
|
||||||
|
|
||||||
// Debugging Deferred buffer job
|
// Debugging Deferred buffer job
|
||||||
_jobs.push_back(Job(new DebugDeferredBuffer::JobModel("DebugDeferredBuffer")));
|
_jobs.push_back(Job(new DebugDeferredBuffer::JobModel("DebugDeferredBuffer")));
|
||||||
_jobs.back().setEnabled(false);
|
_jobs.back().setEnabled(false);
|
||||||
_drawDebugDeferredBufferIndex = _jobs.size() - 1;
|
_drawDebugDeferredBufferIndex = (int)_jobs.size() - 1;
|
||||||
|
|
||||||
// Status icon rendering job
|
// Status icon rendering job
|
||||||
{
|
{
|
||||||
|
@ -119,7 +118,7 @@ RenderDeferredTask::RenderDeferredTask() : Task() {
|
||||||
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
auto statusIconMap = DependencyManager::get<TextureCache>()->getImageTexture(iconMapPath);
|
||||||
_jobs.push_back(Job(new render::DrawStatus::JobModel("DrawStatus", renderedOpaques, DrawStatus(statusIconMap))));
|
_jobs.push_back(Job(new render::DrawStatus::JobModel("DrawStatus", renderedOpaques, DrawStatus(statusIconMap))));
|
||||||
_jobs.back().setEnabled(false);
|
_jobs.back().setEnabled(false);
|
||||||
_drawStatusJobIndex = _jobs.size() - 1;
|
_drawStatusJobIndex = (int)_jobs.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_jobs.push_back(Job(new DrawOverlay3D::JobModel("DrawOverlay3D")));
|
_jobs.push_back(Job(new DrawOverlay3D::JobModel("DrawOverlay3D")));
|
||||||
|
|
|
@ -141,7 +141,5 @@ void ToneMappingEffect::render(RenderArgs* args) {
|
||||||
batch.setUniformBuffer(3, _parametersBuffer);
|
batch.setUniformBuffer(3, _parametersBuffer);
|
||||||
batch.setResourceTexture(0, lightingBuffer);
|
batch.setResourceTexture(0, lightingBuffer);
|
||||||
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
|
||||||
args->_context->render(batch);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -40,6 +40,8 @@ void main(void) {
|
||||||
|
|
||||||
#ifdef PROCEDURAL_V1
|
#ifdef PROCEDURAL_V1
|
||||||
specular = getProceduralColor().rgb;
|
specular = getProceduralColor().rgb;
|
||||||
|
// Procedural Shaders are expected to be Gamma corrected so let's bring back the RGB in linear space for the rest of the pipeline
|
||||||
|
specular = pow(specular, vec3(2.2));
|
||||||
emissiveAmount = 1.0;
|
emissiveAmount = 1.0;
|
||||||
#else
|
#else
|
||||||
emissiveAmount = getProceduralColors(diffuse, specular, shininess);
|
emissiveAmount = getProceduralColors(diffuse, specular, shininess);
|
||||||
|
|
Loading…
Reference in a new issue