mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 08:26:36 +02:00
Fixing the srgb color format conversion for web entities
This commit is contained in:
parent
e40a795a27
commit
1ec9ef560e
9 changed files with 33 additions and 81 deletions
|
@ -210,7 +210,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, textured, culled, emissive);
|
DependencyManager::get<GeometryCache>()->bindSimpleProgram(batch, textured, culled, emissive);
|
||||||
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f));
|
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, glm::vec4(1.0f, 1.0f, 1.0f, 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include "simple_vert.h"
|
#include "simple_vert.h"
|
||||||
#include "simple_textured_frag.h"
|
#include "simple_textured_frag.h"
|
||||||
#include "simple_textured_emisive_frag.h"
|
#include "simple_textured_unlit_frag.h"
|
||||||
|
|
||||||
#include "grid_frag.h"
|
#include "grid_frag.h"
|
||||||
|
|
||||||
|
@ -1687,7 +1687,7 @@ public:
|
||||||
enum FlagBit {
|
enum FlagBit {
|
||||||
IS_TEXTURED_FLAG = 0,
|
IS_TEXTURED_FLAG = 0,
|
||||||
IS_CULLED_FLAG,
|
IS_CULLED_FLAG,
|
||||||
IS_EMISSIVE_FLAG,
|
IS_UNLIT_FLAG,
|
||||||
HAS_DEPTH_BIAS_FLAG,
|
HAS_DEPTH_BIAS_FLAG,
|
||||||
|
|
||||||
NUM_FLAGS,
|
NUM_FLAGS,
|
||||||
|
@ -1696,7 +1696,7 @@ public:
|
||||||
enum Flag {
|
enum Flag {
|
||||||
IS_TEXTURED = (1 << IS_TEXTURED_FLAG),
|
IS_TEXTURED = (1 << IS_TEXTURED_FLAG),
|
||||||
IS_CULLED = (1 << IS_CULLED_FLAG),
|
IS_CULLED = (1 << IS_CULLED_FLAG),
|
||||||
IS_EMISSIVE = (1 << IS_EMISSIVE_FLAG),
|
IS_UNLIT = (1 << IS_UNLIT_FLAG),
|
||||||
HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG),
|
HAS_DEPTH_BIAS = (1 << HAS_DEPTH_BIAS_FLAG),
|
||||||
};
|
};
|
||||||
typedef unsigned short Flags;
|
typedef unsigned short Flags;
|
||||||
|
@ -1705,7 +1705,7 @@ public:
|
||||||
|
|
||||||
bool isTextured() const { return isFlag(IS_TEXTURED); }
|
bool isTextured() const { return isFlag(IS_TEXTURED); }
|
||||||
bool isCulled() const { return isFlag(IS_CULLED); }
|
bool isCulled() const { return isFlag(IS_CULLED); }
|
||||||
bool isEmissive() const { return isFlag(IS_EMISSIVE); }
|
bool isUnlit() const { return isFlag(IS_UNLIT); }
|
||||||
bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); }
|
bool hasDepthBias() const { return isFlag(HAS_DEPTH_BIAS); }
|
||||||
|
|
||||||
Flags _flags = 0;
|
Flags _flags = 0;
|
||||||
|
@ -1715,9 +1715,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
SimpleProgramKey(bool textured = false, bool culled = true,
|
SimpleProgramKey(bool textured = false, bool culled = true,
|
||||||
bool emissive = false, bool depthBias = false) {
|
bool unlit = false, bool depthBias = false) {
|
||||||
_flags = (textured ? IS_TEXTURED : 0) | (culled ? IS_CULLED : 0) |
|
_flags = (textured ? IS_TEXTURED : 0) | (culled ? IS_CULLED : 0) |
|
||||||
(emissive ? IS_EMISSIVE : 0) | (depthBias ? HAS_DEPTH_BIAS : 0);
|
(unlit ? IS_UNLIT : 0) | (depthBias ? HAS_DEPTH_BIAS : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleProgramKey(int bitmask) : _flags(bitmask) {}
|
SimpleProgramKey(int bitmask) : _flags(bitmask) {}
|
||||||
|
@ -1731,8 +1731,8 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
|
||||||
return a.getRaw() == b.getRaw();
|
return a.getRaw() == b.getRaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool emissive, bool depthBiased) {
|
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool culled, bool unlit, bool depthBiased) {
|
||||||
batch.setPipeline(getSimplePipeline(textured, culled, emissive, depthBiased));
|
batch.setPipeline(getSimplePipeline(textured, culled, unlit, depthBiased));
|
||||||
|
|
||||||
// If not textured, set a default albedo map
|
// If not textured, set a default albedo map
|
||||||
if (!textured) {
|
if (!textured) {
|
||||||
|
@ -1744,23 +1744,23 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool cul
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled, bool emissive, bool depthBiased) {
|
gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled, bool unlit, bool depthBiased) {
|
||||||
SimpleProgramKey config{textured, culled, emissive, depthBiased};
|
SimpleProgramKey config{ textured, culled, unlit, depthBiased };
|
||||||
|
|
||||||
// Compile the shaders
|
// Compile the shaders
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [&]() {
|
std::call_once(once, [&]() {
|
||||||
auto VS = gpu::Shader::createVertex(std::string(simple_vert));
|
auto VS = gpu::Shader::createVertex(std::string(simple_vert));
|
||||||
auto PS = gpu::Shader::createPixel(std::string(simple_textured_frag));
|
auto PS = gpu::Shader::createPixel(std::string(simple_textured_frag));
|
||||||
auto PSEmissive = gpu::Shader::createPixel(std::string(simple_textured_emisive_frag));
|
auto PSUnlit = gpu::Shader::createPixel(std::string(simple_textured_unlit_frag));
|
||||||
|
|
||||||
_simpleShader = gpu::Shader::createProgram(VS, PS);
|
_simpleShader = gpu::Shader::createProgram(VS, PS);
|
||||||
_emissiveShader = gpu::Shader::createProgram(VS, PSEmissive);
|
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
slotBindings.insert(gpu::Shader::Binding(std::string("normalFittingMap"), render::ShapePipeline::Slot::MAP::NORMAL_FITTING));
|
||||||
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
|
gpu::Shader::makeProgram(*_simpleShader, slotBindings);
|
||||||
gpu::Shader::makeProgram(*_emissiveShader, slotBindings);
|
gpu::Shader::makeProgram(*_unlitShader, slotBindings);
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the pipeline already exists, return it
|
// If the pipeline already exists, return it
|
||||||
|
@ -1785,7 +1785,7 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool culled
|
||||||
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA,
|
||||||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||||
|
|
||||||
gpu::ShaderPointer program = (config.isEmissive()) ? _emissiveShader : _simpleShader;
|
gpu::ShaderPointer program = (config.isUnlit()) ? _unlitShader : _simpleShader;
|
||||||
gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);
|
gpu::PipelinePointer pipeline = gpu::Pipeline::create(program, state);
|
||||||
_simplePrograms.insert(config, pipeline);
|
_simplePrograms.insert(config, pipeline);
|
||||||
return pipeline;
|
return pipeline;
|
||||||
|
|
|
@ -153,10 +153,10 @@ public:
|
||||||
|
|
||||||
// Bind the pipeline and get the state to render static geometry
|
// Bind the pipeline and get the state to render static geometry
|
||||||
void bindSimpleProgram(gpu::Batch& batch, bool textured = false, bool culled = true,
|
void bindSimpleProgram(gpu::Batch& batch, bool textured = false, bool culled = true,
|
||||||
bool emissive = false, bool depthBias = false);
|
bool unlit = false, bool depthBias = false);
|
||||||
// Get the pipeline to render static geometry
|
// Get the pipeline to render static geometry
|
||||||
gpu::PipelinePointer getSimplePipeline(bool textured = false, bool culled = true,
|
gpu::PipelinePointer getSimplePipeline(bool textured = false, bool culled = true,
|
||||||
bool emissive = false, bool depthBias = false);
|
bool unlit = false, bool depthBias = false);
|
||||||
render::ShapePipelinePointer getShapePipeline() { return GeometryCache::_simplePipeline; }
|
render::ShapePipelinePointer getShapePipeline() { return GeometryCache::_simplePipeline; }
|
||||||
|
|
||||||
// Static (instanced) geometry
|
// Static (instanced) geometry
|
||||||
|
@ -393,7 +393,7 @@ private:
|
||||||
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
QHash<QUrl, QWeakPointer<NetworkGeometry> > _networkGeometry;
|
||||||
|
|
||||||
gpu::ShaderPointer _simpleShader;
|
gpu::ShaderPointer _simpleShader;
|
||||||
gpu::ShaderPointer _emissiveShader;
|
gpu::ShaderPointer _unlitShader;
|
||||||
static render::ShapePipelinePointer _simplePipeline;
|
static render::ShapePipelinePointer _simplePipeline;
|
||||||
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "skin_model_normal_map_vert.h"
|
#include "skin_model_normal_map_vert.h"
|
||||||
|
|
||||||
#include "model_frag.h"
|
#include "model_frag.h"
|
||||||
#include "model_emissive_frag.h"
|
|
||||||
#include "model_unlit_frag.h"
|
#include "model_unlit_frag.h"
|
||||||
#include "model_shadow_frag.h"
|
#include "model_shadow_frag.h"
|
||||||
#include "model_normal_map_frag.h"
|
#include "model_normal_map_frag.h"
|
||||||
|
@ -38,7 +37,6 @@
|
||||||
#include "model_lightmap_normal_specular_map_frag.h"
|
#include "model_lightmap_normal_specular_map_frag.h"
|
||||||
#include "model_lightmap_specular_map_frag.h"
|
#include "model_lightmap_specular_map_frag.h"
|
||||||
#include "model_translucent_frag.h"
|
#include "model_translucent_frag.h"
|
||||||
#include "model_translucent_emissive_frag.h"
|
|
||||||
#include "model_translucent_unlit_frag.h"
|
#include "model_translucent_unlit_frag.h"
|
||||||
|
|
||||||
#include "overlay3D_vert.h"
|
#include "overlay3D_vert.h"
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
<@include gpu/Config.slh@>
|
|
||||||
<$VERSION_HEADER$>
|
|
||||||
// Generated on <$_SCRIBE_DATE$>
|
|
||||||
//
|
|
||||||
// model_emissive.frag
|
|
||||||
// fragment shader
|
|
||||||
//
|
|
||||||
// Created by Zach Pomerantz on 2/3/2016.
|
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
<@include DeferredBufferWrite.slh@>
|
|
||||||
<@include model/Material.slh@>
|
|
||||||
|
|
||||||
uniform sampler2D albedoMap;
|
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
|
||||||
in vec3 _normal;
|
|
||||||
in vec3 _color;
|
|
||||||
in float _alpha;
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
vec4 texel = texture(albedoMap, _texCoord0);
|
|
||||||
|
|
||||||
Material mat = getMaterial();
|
|
||||||
vec3 fragColor = getMaterialAlbedo(mat) * texel.rgb * _color;
|
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
|
||||||
normalize(_normal),
|
|
||||||
texel.a,
|
|
||||||
vec3(1.0),
|
|
||||||
getMaterialRoughness(mat),
|
|
||||||
getMaterialMetallic(mat),
|
|
||||||
getMaterialFresnel(mat),
|
|
||||||
fragColor);
|
|
||||||
}
|
|
|
@ -20,12 +20,12 @@
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
out vec3 _normal;
|
out vec3 _normal;
|
||||||
out vec3 _modelNormal;
|
out vec3 _modelNormal;
|
||||||
out vec3 _color;
|
out vec4 _color;
|
||||||
out vec2 _texCoord0;
|
out vec2 _texCoord0;
|
||||||
out vec4 _position;
|
out vec4 _position;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
_color = colorToLinearRGB(inColor.rgb);
|
_color = colorToLinearRGBA(inColor);
|
||||||
_texCoord0 = inTexCoord0.st;
|
_texCoord0 = inTexCoord0.st;
|
||||||
_position = inPosition;
|
_position = inPosition;
|
||||||
_modelNormal = inNormal.xyz;
|
_modelNormal = inNormal.xyz;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Color.slh@>
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
<@include model/Material.slh@>
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
|
@ -20,13 +21,14 @@ uniform sampler2D originalTexture;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec4 _color;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material material = getMaterial();
|
|
||||||
vec4 texel = texture(originalTexture, _texCoord0);
|
vec4 texel = texture(originalTexture, _texCoord0);
|
||||||
|
if (_color.a <= 0.0) {
|
||||||
|
texel = colorToLinearRGBA(texel);
|
||||||
|
}
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
texel.a,
|
texel.a,
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
|
<@include gpu/Color.slh@>
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
|
|
||||||
// the albedo texture
|
// the albedo texture
|
||||||
|
@ -19,27 +20,17 @@ uniform sampler2D originalTexture;
|
||||||
|
|
||||||
// the interpolated normal
|
// the interpolated normal
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec4 _color;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||||
|
if (_color.a <= 0.0) {
|
||||||
|
texel = colorToLinearRGBA(texel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
packDeferredFragmentUnlit(
|
packDeferredFragmentUnlit(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
texel.a,
|
texel.a,
|
||||||
texel.rgb);
|
_color.rgb * texel.rgb);
|
||||||
|
|
||||||
/*
|
|
||||||
packDeferredFragmentLightmap(
|
|
||||||
normalize(_normal),
|
|
||||||
texel.a,
|
|
||||||
_color.rgb,
|
|
||||||
DEFAULT_ROUGHNESS,
|
|
||||||
DEFAULT_METALLIC,
|
|
||||||
DEFAULT_SPECULAR,
|
|
||||||
texel.rgb);
|
|
||||||
*/
|
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@
|
||||||
#include <render-utils/simple_vert.h>
|
#include <render-utils/simple_vert.h>
|
||||||
#include <render-utils/simple_frag.h>
|
#include <render-utils/simple_frag.h>
|
||||||
#include <render-utils/simple_textured_frag.h>
|
#include <render-utils/simple_textured_frag.h>
|
||||||
#include <render-utils/simple_textured_emisive_frag.h>
|
#include <render-utils/simple_textured_unlit_frag.h>
|
||||||
|
|
||||||
#include <render-utils/deferred_light_vert.h>
|
#include <render-utils/deferred_light_vert.h>
|
||||||
#include <render-utils/deferred_light_limited_vert.h>
|
#include <render-utils/deferred_light_limited_vert.h>
|
||||||
|
@ -160,7 +160,7 @@ void QTestWindow::draw() {
|
||||||
testShaderBuild(skybox_vert, skybox_frag);
|
testShaderBuild(skybox_vert, skybox_frag);
|
||||||
testShaderBuild(simple_vert, simple_frag);
|
testShaderBuild(simple_vert, simple_frag);
|
||||||
testShaderBuild(simple_vert, simple_textured_frag);
|
testShaderBuild(simple_vert, simple_textured_frag);
|
||||||
testShaderBuild(simple_vert, simple_textured_emisive_frag);
|
testShaderBuild(simple_vert, simple_textured_unlit_frag);
|
||||||
testShaderBuild(deferred_light_vert, directional_light_frag);
|
testShaderBuild(deferred_light_vert, directional_light_frag);
|
||||||
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
|
testShaderBuild(deferred_light_vert, directional_ambient_light_frag);
|
||||||
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
|
testShaderBuild(deferred_light_vert, directional_skybox_light_frag);
|
||||||
|
|
Loading…
Reference in a new issue