mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 17:55:29 +02:00
Added new shaders
This commit is contained in:
parent
cbcf9ebe9f
commit
08fcd6c357
25 changed files with 1030 additions and 44 deletions
libraries/render-utils/src
Fade.slhMeshPartPayload.cppRenderDeferredTask.cppRenderDeferredTask.hRenderPipelines.cppmodel_fade.slfmodel_lightmap_fade.slfmodel_lightmap_fade.slvmodel_lightmap_normal_map_fade.slfmodel_lightmap_normal_map_fade.slvmodel_lightmap_normal_specular_map_fade.slfmodel_lightmap_specular_map_fade.slfmodel_normal_map_fade.slfmodel_normal_specular_map_fade.slfmodel_specular_map_fade.slfmodel_unlit_fade.slfsimple_fade.slfsimple_fade.slvsimple_textured_fade.slfsimple_textured_unlit_fade.slfskin_model_fade.slvskin_model_normal_map_fade.slv
plugins/openvr/src
scripts/developer/utilities/render
|
@ -33,7 +33,7 @@ vec2 hash2D(vec3 position) {
|
|||
return position.xy* vec2(0.1677, 0.221765) + position.z*0.561;
|
||||
}
|
||||
|
||||
float evalFadeMask(vec3 position, vec3 normal) {
|
||||
float evalFadeMask(vec3 position) {
|
||||
const float FADE_MASK_INV_SCALE = 1.0;
|
||||
|
||||
// Do tri-linear interpolation
|
||||
|
@ -56,8 +56,8 @@ float evalFadeMask(vec3 position, vec3 normal) {
|
|||
return mix(maskY.x, maskY.y, noisePositionFraction.y);
|
||||
}
|
||||
|
||||
void applyFade(vec3 position, vec3 normal) {
|
||||
if (evalFadeMask(position, normal) < fade._Percent) {
|
||||
void applyFade(vec3 position) {
|
||||
if (evalFadeMask(position) > fade._Percent) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -400,10 +400,6 @@ ItemKey ModelMeshPartPayload::getKey() const {
|
|||
builder.withTransparent();
|
||||
}
|
||||
}
|
||||
|
||||
if (_fadeState != FADE_COMPLETE) {
|
||||
builder.withTransparent();
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
@ -537,9 +533,9 @@ float ModelMeshPartPayload::computeFadePercent() const {
|
|||
return 0.0f;
|
||||
}
|
||||
float fadeAlpha = 1.0f;
|
||||
const float INV_FADE_PERIOD = 1.0f / (float)(3 * USECS_PER_SECOND);
|
||||
float fraction = (float)(usecTimestampNow() - _fadeStartTime) * INV_FADE_PERIOD;
|
||||
if (fraction < 1.0f) {
|
||||
const double INV_FADE_PERIOD = 1.0 / (double)(10 * USECS_PER_SECOND);
|
||||
double fraction = (double)(usecTimestampNow() - _fadeStartTime) * INV_FADE_PERIOD;
|
||||
if (fraction < 1.0) {
|
||||
fadeAlpha = Interpolate::simpleNonLinearBlend(fraction);
|
||||
}
|
||||
if (fadeAlpha >= 1.0f) {
|
||||
|
@ -549,9 +545,9 @@ float ModelMeshPartPayload::computeFadePercent() const {
|
|||
if (model) {
|
||||
model->setRenderItemsNeedUpdate();
|
||||
}
|
||||
return 1.0f;
|
||||
fadeAlpha = 1.0f;
|
||||
}
|
||||
return Interpolate::simpleNonLinearBlend(fadeAlpha);
|
||||
return fadeAlpha;
|
||||
}
|
||||
|
||||
void ModelMeshPartPayload::bindFade(gpu::Batch& batch, const RenderArgs* args) const {
|
||||
|
|
|
@ -147,7 +147,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
|
|||
|
||||
// Render transparent objects forward in LightingBuffer
|
||||
const auto transparentsInputs = DrawDeferred::Inputs(transparents, lightingModel).hasVarying();
|
||||
task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber);
|
||||
task.addJob<DrawDeferred>("DrawTransparentDeferred", transparentsInputs, shapePlumber, fadeMaskMap);
|
||||
|
||||
// LIght Cluster Grid Debuging job
|
||||
{
|
||||
|
@ -276,6 +276,16 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
|
|||
if (lightingModel->isWireframeEnabled()) {
|
||||
keyBuilder.withWireframe();
|
||||
}
|
||||
// Prepare fade effect
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::FADE_MASK, _fadeMaskMap);
|
||||
if (_debugFade) {
|
||||
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags |
|
||||
static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
|
||||
args->_debugFadePercent = _debugFadePercent;
|
||||
// Force fade for everyone
|
||||
keyBuilder.withFade();
|
||||
}
|
||||
|
||||
ShapeKey globalKey = keyBuilder.build();
|
||||
args->_globalShapeKey = globalKey._flags.to_ulong();
|
||||
|
||||
|
@ -283,6 +293,13 @@ void DrawDeferred::run(const RenderContextPointer& renderContext, const Inputs&
|
|||
|
||||
args->_batch = nullptr;
|
||||
args->_globalShapeKey = 0;
|
||||
|
||||
// Not sure this is really needed...
|
||||
if (_debugFade) {
|
||||
// Turn off fade debug
|
||||
args->_debugFlags = static_cast<RenderArgs::DebugFlags>(args->_debugFlags &
|
||||
~static_cast<int>(RenderArgs::RENDER_DEBUG_FADE));
|
||||
}
|
||||
});
|
||||
|
||||
config->setNumDrawn((int)inItems.size());
|
||||
|
|
|
@ -45,17 +45,31 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class DrawFadableDeferred {
|
||||
protected:
|
||||
DrawFadableDeferred(gpu::TexturePointer fadeMaskMap) : _fadeMaskMap{ fadeMaskMap } {}
|
||||
|
||||
gpu::TexturePointer _fadeMaskMap;
|
||||
float _debugFadePercent;
|
||||
bool _stateSort;
|
||||
bool _debugFade;
|
||||
};
|
||||
|
||||
class DrawConfig : public render::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int numDrawn READ getNumDrawn NOTIFY newStats)
|
||||
|
||||
Q_PROPERTY(int maxDrawn MEMBER maxDrawn NOTIFY dirty)
|
||||
Q_PROPERTY(bool debugFade MEMBER debugFade NOTIFY dirty)
|
||||
Q_PROPERTY(float debugFadePercent MEMBER debugFadePercent NOTIFY dirty)
|
||||
|
||||
public:
|
||||
|
||||
int getNumDrawn() { return _numDrawn; }
|
||||
void setNumDrawn(int numDrawn) { _numDrawn = numDrawn; emit newStats(); }
|
||||
|
||||
int maxDrawn{ -1 };
|
||||
float debugFadePercent{ 0.f };
|
||||
bool debugFade{ false };
|
||||
|
||||
signals:
|
||||
void newStats();
|
||||
|
@ -65,15 +79,15 @@ protected:
|
|||
int _numDrawn{ 0 };
|
||||
};
|
||||
|
||||
class DrawDeferred {
|
||||
class DrawDeferred : public DrawFadableDeferred {
|
||||
public:
|
||||
using Inputs = render::VaryingSet2 <render::ItemBounds, LightingModelPointer>;
|
||||
using Config = DrawConfig;
|
||||
using JobModel = render::Job::ModelI<DrawDeferred, Inputs, Config>;
|
||||
|
||||
DrawDeferred(render::ShapePlumberPointer shapePlumber) : _shapePlumber{ shapePlumber } {}
|
||||
DrawDeferred(render::ShapePlumberPointer shapePlumber, gpu::TexturePointer fadeMaskMap) : _shapePlumber{ shapePlumber }, DrawFadableDeferred{ fadeMaskMap } {}
|
||||
|
||||
void configure(const Config& config) { _maxDrawn = config.maxDrawn; }
|
||||
void configure(const Config& config) { _maxDrawn = config.maxDrawn; _debugFadePercent = config.debugFadePercent; _debugFade = config.debugFade; }
|
||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||
|
||||
protected:
|
||||
|
@ -94,8 +108,8 @@ public:
|
|||
void setNumDrawn(int num) { numDrawn = num; emit numDrawnChanged(); }
|
||||
|
||||
int maxDrawn{ -1 };
|
||||
float debugFadePercent{ 0.f };
|
||||
bool stateSort{ true };
|
||||
float debugFadePercent{ 0.f };
|
||||
bool debugFade{ false };
|
||||
|
||||
signals:
|
||||
|
@ -106,25 +120,21 @@ protected:
|
|||
int numDrawn{ 0 };
|
||||
};
|
||||
|
||||
class DrawStateSortDeferred {
|
||||
class DrawStateSortDeferred : public DrawFadableDeferred {
|
||||
public:
|
||||
using Inputs = render::VaryingSet2 <render::ItemBounds, LightingModelPointer>;
|
||||
|
||||
using Config = DrawStateSortConfig;
|
||||
using JobModel = render::Job::ModelI<DrawStateSortDeferred, Inputs, Config>;
|
||||
|
||||
DrawStateSortDeferred(render::ShapePlumberPointer shapePlumber, gpu::TexturePointer fadeMaskMap) : _shapePlumber{ shapePlumber }, _fadeMaskMap{ fadeMaskMap } {}
|
||||
DrawStateSortDeferred(render::ShapePlumberPointer shapePlumber, gpu::TexturePointer fadeMaskMap) : _shapePlumber{ shapePlumber }, DrawFadableDeferred{ fadeMaskMap } {}
|
||||
|
||||
void configure(const Config& config) { _maxDrawn = config.maxDrawn; _stateSort = config.stateSort; _debugFadePercent = config.debugFadePercent; _debugFade = config.debugFade; }
|
||||
void run(const render::RenderContextPointer& renderContext, const Inputs& inputs);
|
||||
|
||||
protected:
|
||||
render::ShapePlumberPointer _shapePlumber;
|
||||
gpu::TexturePointer _fadeMaskMap;
|
||||
int _maxDrawn; // initialized by Config
|
||||
float _debugFadePercent;
|
||||
bool _stateSort;
|
||||
bool _debugFade;
|
||||
};
|
||||
|
||||
class DeferredFramebuffer;
|
||||
|
@ -207,6 +217,7 @@ public:
|
|||
RenderDeferredTask() {}
|
||||
|
||||
void build(JobModel& task, const render::Varying& inputs, render::Varying& outputs);
|
||||
|
||||
};
|
||||
|
||||
#endif // hifi_RenderDeferredTask_h
|
||||
|
|
|
@ -28,12 +28,22 @@
|
|||
#include "skin_model_shadow_vert.h"
|
||||
#include "skin_model_normal_map_vert.h"
|
||||
|
||||
#include "skin_model_fade_vert.h"
|
||||
#include "skin_model_normal_map_fade_vert.h"
|
||||
|
||||
#include "model_lightmap_fade_vert.h"
|
||||
#include "model_lightmap_normal_map_fade_vert.h"
|
||||
|
||||
#include "simple_vert.h"
|
||||
#include "simple_textured_frag.h"
|
||||
#include "simple_textured_unlit_frag.h"
|
||||
#include "simple_transparent_textured_frag.h"
|
||||
#include "simple_transparent_textured_unlit_frag.h"
|
||||
|
||||
#include "simple_fade_vert.h"
|
||||
#include "simple_textured_fade_frag.h"
|
||||
#include "simple_textured_unlit_fade_frag.h"
|
||||
|
||||
#include "model_frag.h"
|
||||
#include "model_unlit_frag.h"
|
||||
#include "model_shadow_frag.h"
|
||||
|
@ -45,7 +55,10 @@
|
|||
#include "model_normal_map_fade_vert.h"
|
||||
|
||||
#include "model_fade_frag.h"
|
||||
#include "model_unlit_fade_frag.h"
|
||||
#include "model_normal_map_fade_frag.h"
|
||||
#include "model_normal_specular_map_fade_frag.h"
|
||||
#include "model_specular_map_fade_frag.h"
|
||||
|
||||
#include "forward_model_frag.h"
|
||||
#include "forward_model_unlit_frag.h"
|
||||
|
@ -60,6 +73,11 @@
|
|||
#include "model_translucent_frag.h"
|
||||
#include "model_translucent_unlit_frag.h"
|
||||
|
||||
#include "model_lightmap_fade_frag.h"
|
||||
#include "model_lightmap_normal_map_fade_frag.h"
|
||||
#include "model_lightmap_normal_specular_map_fade_frag.h"
|
||||
#include "model_lightmap_specular_map_fade_frag.h"
|
||||
|
||||
#include "overlay3D_vert.h"
|
||||
#include "overlay3D_frag.h"
|
||||
#include "overlay3D_model_frag.h"
|
||||
|
@ -156,10 +174,15 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
auto skinModelVertex = gpu::Shader::createVertex(std::string(skin_model_vert));
|
||||
auto skinModelNormalMapVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_vert));
|
||||
auto skinModelShadowVertex = gpu::Shader::createVertex(std::string(skin_model_shadow_vert));
|
||||
auto modelLightmapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_fade_vert));
|
||||
auto modelLightmapNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_lightmap_normal_map_fade_vert));
|
||||
auto skinModelFadeVertex = gpu::Shader::createVertex(std::string(skin_model_fade_vert));
|
||||
auto skinModelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(skin_model_normal_map_fade_vert));
|
||||
|
||||
// Only models can have fade applied to them (?)
|
||||
auto modelFadeVertex = gpu::Shader::createVertex(std::string(model_fade_vert));
|
||||
auto modelNormalMapFadeVertex = gpu::Shader::createVertex(std::string(model_normal_map_fade_vert));
|
||||
auto simpleFadeVertex = gpu::Shader::createVertex(std::string(simple_fade_vert));
|
||||
|
||||
// Pixel shaders
|
||||
auto simplePixel = gpu::Shader::createPixel(std::string(simple_textured_frag));
|
||||
|
@ -178,10 +201,18 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
auto modelLightmapNormalMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_frag));
|
||||
auto modelLightmapSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_frag));
|
||||
auto modelLightmapNormalSpecularMapPixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_frag));
|
||||
auto modelLightmapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_fade_frag));
|
||||
auto modelLightmapNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_map_fade_frag));
|
||||
auto modelLightmapSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_specular_map_fade_frag));
|
||||
auto modelLightmapNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_lightmap_normal_specular_map_fade_frag));
|
||||
|
||||
// Only models can have fade applied to them (?)
|
||||
auto modelFadePixel = gpu::Shader::createPixel(std::string(model_fade_frag));
|
||||
auto modelUnlitFadePixel = gpu::Shader::createPixel(std::string(model_unlit_fade_frag));
|
||||
auto modelNormalMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_map_fade_frag));
|
||||
auto modelSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_specular_map_fade_frag));
|
||||
auto modelNormalSpecularMapFadePixel = gpu::Shader::createPixel(std::string(model_normal_specular_map_fade_frag));
|
||||
auto simpleFadePixel = gpu::Shader::createPixel(std::string(simple_textured_fade_frag));
|
||||
auto simpleUnlitFadePixel = gpu::Shader::createPixel(std::string(simple_textured_unlit_fade_frag));
|
||||
|
||||
using Key = render::ShapeKey;
|
||||
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3);
|
||||
|
@ -212,9 +243,24 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
addPipeline(
|
||||
Key::Builder().withMaterial().withFade(),
|
||||
modelFadeVertex, modelFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withFade(),
|
||||
simpleFadeVertex, simpleFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withUnlit().withFade(),
|
||||
modelFadeVertex, modelUnlitFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withUnlit().withFade(),
|
||||
simpleFadeVertex, simpleUnlitFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTangents().withFade(),
|
||||
modelNormalMapFadeVertex, modelNormalMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSpecular().withFade(),
|
||||
modelFadeVertex, modelSpecularMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTangents().withSpecular().withFade(),
|
||||
modelNormalMapFadeVertex, modelNormalSpecularMapFadePixel);
|
||||
|
||||
// Translucents
|
||||
addPipeline(
|
||||
|
@ -242,6 +288,7 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
// FIXME: Ignore lightmap for translucents meshpart
|
||||
Key::Builder().withMaterial().withTranslucent().withLightmap(),
|
||||
modelVertex, modelTranslucentPixel);
|
||||
|
||||
// Lightmapped
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap(),
|
||||
|
@ -255,6 +302,20 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withTangents().withSpecular(),
|
||||
modelLightmapNormalMapVertex, modelLightmapNormalSpecularMapPixel);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withFade(),
|
||||
modelLightmapFadeVertex, modelLightmapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withTangents().withFade(),
|
||||
modelLightmapNormalMapFadeVertex, modelLightmapNormalMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withSpecular().withFade(),
|
||||
modelLightmapFadeVertex, modelLightmapSpecularMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withTangents().withSpecular().withFade(),
|
||||
modelLightmapNormalMapFadeVertex, modelLightmapNormalSpecularMapFadePixel);
|
||||
|
||||
// Skinned
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned(),
|
||||
|
@ -268,6 +329,20 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular(),
|
||||
skinModelNormalMapVertex, modelNormalSpecularMapPixel);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withFade(),
|
||||
skinModelFadeVertex, modelFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTangents().withFade(),
|
||||
skinModelNormalMapFadeVertex, modelNormalMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withSpecular().withFade(),
|
||||
skinModelFadeVertex, modelSpecularMapFadePixel);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTangents().withSpecular().withFade(),
|
||||
skinModelNormalMapFadeVertex, modelNormalSpecularMapFadePixel);
|
||||
|
||||
// Skinned and Translucent
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent(),
|
||||
|
@ -281,6 +356,7 @@ void initDeferredPipelines(render::ShapePlumber& plumber) {
|
|||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withSpecular(),
|
||||
skinModelNormalMapVertex, modelTranslucentPixel);
|
||||
|
||||
// Depth-only
|
||||
addPipeline(
|
||||
Key::Builder().withDepthOnly(),
|
||||
|
|
|
@ -30,7 +30,7 @@ in vec2 _texCoord1;
|
|||
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz, _normal);
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
|
|
50
libraries/render-utils/src/model_lightmap_fade.slf
Normal file
50
libraries/render-utils/src/model_lightmap_fade.slf
Normal file
|
@ -0,0 +1,50 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(_normal),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat),
|
||||
getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
}
|
48
libraries/render-utils/src/model_lightmap_fade.slv
Normal file
48
libraries/render-utils/src/model_lightmap_fade.slv
Normal file
|
@ -0,0 +1,48 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Color.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _color;
|
||||
out vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
// pass along the color in linear space
|
||||
_color = colorToLinearRGB(inColor.xyz);
|
||||
|
||||
// and the texture coordinates
|
||||
TexMapArray texMapArray = getTexMapArray();
|
||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$>
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToFadePos(obj, inPosition, _worldFadePosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
vec3 viewNormal;
|
||||
<$tangentToViewSpaceLOD(_position, normalTexel, _normal, _tangent, viewNormal)$>
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(viewNormal.xyz),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||
getMaterialRoughness(mat),
|
||||
getMaterialMetallic(mat),
|
||||
getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_map_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Color.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
out vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
// pass along the color in linear space
|
||||
_color = colorToLinearRGB(inColor.xyz);
|
||||
|
||||
TexMapArray texMapArray = getTexMapArray();
|
||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$>
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
|
||||
<$transformModelToFadePos(obj, inPosition, _worldFadePosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangent)$>
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_normal_specular_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
vec3 viewNormal;
|
||||
<$tangentToViewSpaceLOD(_position, normalTexel, _normal, _tangent, viewNormal)$>
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(viewNormal.xyz),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*specular, // no use of */ getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_lightmap_specular_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
|
||||
<$declareMaterialLightmap()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||
|
||||
packDeferredFragmentLightmap(
|
||||
normalize(_normal),
|
||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||
getMaterialRoughness(mat) * roughness,
|
||||
getMaterialMetallic(mat) * metallicTex,
|
||||
/*metallicTex, // no use of */getMaterialFresnel(mat),
|
||||
lightmapVal);
|
||||
}
|
|
@ -31,7 +31,7 @@ in vec3 _tangent;
|
|||
in vec3 _color;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz, _normal);
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_normal_specular_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _tangent;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||
<$discardTransparent(opacity)$>;
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
vec3 viewNormal;
|
||||
<$tangentToViewSpaceLOD(_position, normalTex, _normal, _tangent, viewNormal)$>
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(viewNormal.xyz),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive,
|
||||
occlusionTex,
|
||||
scattering);
|
||||
}
|
68
libraries/render-utils/src/model_specular_map_fade.slf
Normal file
68
libraries/render-utils/src/model_specular_map_fade.slf
Normal file
|
@ -0,0 +1,68 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_specular_map_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _position;
|
||||
in vec2 _texCoord0;
|
||||
in vec2 _texCoord1;
|
||||
in vec3 _normal;
|
||||
in vec3 _color;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||
<$discardTransparent(opacity)$>;
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color;
|
||||
|
||||
float roughness = getMaterialRoughness(mat);
|
||||
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
||||
|
||||
vec3 emissive = getMaterialEmissive(mat);
|
||||
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
||||
|
||||
float metallic = getMaterialMetallic(mat);
|
||||
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
|
||||
|
||||
float scattering = getMaterialScattering(mat);
|
||||
|
||||
packDeferredFragment(
|
||||
normalize(_normal),
|
||||
opacity,
|
||||
albedo,
|
||||
roughness,
|
||||
metallic,
|
||||
emissive,
|
||||
occlusionTex,
|
||||
scattering);
|
||||
}
|
50
libraries/render-utils/src/model_unlit_fade.slf
Normal file
50
libraries/render-utils/src/model_unlit_fade.slf
Normal file
|
@ -0,0 +1,50 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// model_unlit_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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 LightingModel.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTextures(ALBEDO)$>
|
||||
|
||||
in vec2 _texCoord0;
|
||||
in vec3 _normal;
|
||||
in vec3 _color;
|
||||
in float _alpha;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material mat = getMaterial();
|
||||
int matKey = getMaterialKey(mat);
|
||||
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||
|
||||
float opacity = 1.0;
|
||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||
<$discardTransparent(opacity)$>;
|
||||
|
||||
vec3 albedo = getMaterialAlbedo(mat);
|
||||
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||
albedo *= _color;
|
||||
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normal),
|
||||
opacity,
|
||||
albedo * isUnlitEnabled());
|
||||
}
|
97
libraries/render-utils/src/simple_fade.slf
Normal file
97
libraries/render-utils/src/simple_fade.slf
Normal file
|
@ -0,0 +1,97 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// simple_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the interpolated normal
|
||||
in vec3 _normal;
|
||||
in vec3 _modelNormal;
|
||||
in vec4 _color;
|
||||
in vec2 _texCoord0;
|
||||
in vec4 _position;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
//PROCEDURAL_COMMON_BLOCK
|
||||
|
||||
#line 1001
|
||||
//PROCEDURAL_BLOCK
|
||||
|
||||
#line 2030
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
Material material = getMaterial();
|
||||
vec3 normal = normalize(_normal.xyz);
|
||||
vec3 diffuse = _color.rgb;
|
||||
vec3 specular = DEFAULT_SPECULAR;
|
||||
float shininess = DEFAULT_SHININESS;
|
||||
float emissiveAmount = 0.0;
|
||||
|
||||
#ifdef PROCEDURAL
|
||||
|
||||
#ifdef PROCEDURAL_V1
|
||||
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;
|
||||
#else
|
||||
emissiveAmount = getProceduralColors(diffuse, specular, shininess);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (_color.a < ALPHA_THRESHOLD) {
|
||||
if (emissiveAmount > 0.0) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normal,
|
||||
_color.a,
|
||||
specular,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentTranslucent(
|
||||
normal,
|
||||
_color.a,
|
||||
diffuse,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
}
|
||||
} else {
|
||||
if (emissiveAmount > 0.0) {
|
||||
packDeferredFragmentLightmap(
|
||||
normal,
|
||||
1.0,
|
||||
diffuse,
|
||||
max(0, 1.0 - shininess / 128.0),
|
||||
DEFAULT_METALLIC,
|
||||
specular,
|
||||
specular);
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
normal,
|
||||
1.0,
|
||||
diffuse,
|
||||
max(0, 1.0 - shininess / 128.0),
|
||||
length(specular),
|
||||
DEFAULT_EMISSIVE,
|
||||
DEFAULT_OCCLUSION,
|
||||
DEFAULT_SCATTERING);
|
||||
}
|
||||
}
|
||||
}
|
42
libraries/render-utils/src/simple_fade.slv
Normal file
42
libraries/render-utils/src/simple_fade.slv
Normal file
|
@ -0,0 +1,42 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// simple_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/045/17.
|
||||
// Copyright 2017 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Color.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
// the interpolated normal
|
||||
out vec3 _normal;
|
||||
out vec3 _modelNormal;
|
||||
out vec4 _color;
|
||||
out vec2 _texCoord0;
|
||||
out vec4 _position;
|
||||
out vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
_color = colorToLinearRGBA(inColor);
|
||||
_texCoord0 = inTexCoord0.st;
|
||||
_position = inPosition;
|
||||
_modelNormal = inNormal.xyz;
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
|
||||
<$transformModelToFadePos(obj, inPosition, _worldFadePosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normal)$>
|
||||
}
|
60
libraries/render-utils/src/simple_textured_fade.slf
Normal file
60
libraries/render-utils/src/simple_textured_fade.slf
Normal file
|
@ -0,0 +1,60 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// simple_textured_fade.slf
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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 gpu/Color.slh@>
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
<@include model/Material.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
||||
// the interpolated normal
|
||||
in vec3 _normal;
|
||||
in vec4 _color;
|
||||
in vec2 _texCoord0;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = colorToLinearRGBA(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normal),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragment(
|
||||
normalize(_normal),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_ROUGHNESS,
|
||||
DEFAULT_METALLIC,
|
||||
DEFAULT_EMISSIVE,
|
||||
DEFAULT_OCCLUSION,
|
||||
DEFAULT_SCATTERING);
|
||||
}
|
||||
}
|
54
libraries/render-utils/src/simple_textured_unlit_fade.slf
Normal file
54
libraries/render-utils/src/simple_textured_unlit_fade.slf
Normal file
|
@ -0,0 +1,54 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// simple_textured_unlit_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/05/17.
|
||||
// Copyright 2017 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 gpu/Color.slh@>
|
||||
<@include DeferredBufferWrite.slh@>
|
||||
|
||||
<@include Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
// the albedo texture
|
||||
uniform sampler2D originalTexture;
|
||||
|
||||
// the interpolated normal
|
||||
in vec3 _normal;
|
||||
in vec4 _color;
|
||||
in vec2 _texCoord0;
|
||||
in vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
applyFade(_worldFadePosition.xyz);
|
||||
|
||||
vec4 texel = texture(originalTexture, _texCoord0.st);
|
||||
float colorAlpha = _color.a;
|
||||
if (_color.a <= 0.0) {
|
||||
texel = colorToLinearRGBA(texel);
|
||||
colorAlpha = -_color.a;
|
||||
}
|
||||
|
||||
const float ALPHA_THRESHOLD = 0.999;
|
||||
if (colorAlpha * texel.a < ALPHA_THRESHOLD) {
|
||||
packDeferredFragmentTranslucent(
|
||||
normalize(_normal),
|
||||
colorAlpha * texel.a,
|
||||
_color.rgb * texel.rgb,
|
||||
DEFAULT_FRESNEL,
|
||||
DEFAULT_ROUGHNESS);
|
||||
} else {
|
||||
packDeferredFragmentUnlit(
|
||||
normalize(_normal),
|
||||
1.0,
|
||||
_color.rgb * texel.rgb);
|
||||
}
|
||||
}
|
55
libraries/render-utils/src/skin_model_fade.slv
Normal file
55
libraries/render-utils/src/skin_model_fade.slv
Normal file
|
@ -0,0 +1,55 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/045/17.
|
||||
// Copyright 2017 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Color.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec3 interpolatedNormal = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormal(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, position, interpolatedNormal);
|
||||
|
||||
// pass along the color
|
||||
_color = colorToLinearRGB(inColor.rgb);
|
||||
_alpha = inColor.a;
|
||||
|
||||
TexMapArray texMapArray = getTexMapArray();
|
||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToFadePos(obj, inPosition, _worldFadePosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, _normal.xyz)$>
|
||||
}
|
64
libraries/render-utils/src/skin_model_normal_map_fade.slv
Normal file
64
libraries/render-utils/src/skin_model_normal_map_fade.slv
Normal file
|
@ -0,0 +1,64 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_normal_map_fade.vert
|
||||
// vertex shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/045/17.
|
||||
// Copyright 2017 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 gpu/Inputs.slh@>
|
||||
<@include gpu/Color.slh@>
|
||||
<@include gpu/Transform.slh@>
|
||||
<$declareStandardTransform()$>
|
||||
|
||||
<@include Skinning.slh@>
|
||||
|
||||
<@include MaterialTextures.slh@>
|
||||
<$declareMaterialTexMapArrayBuffer()$>
|
||||
|
||||
<@include Fade.slh@>
|
||||
|
||||
out vec4 _position;
|
||||
out vec2 _texCoord0;
|
||||
out vec2 _texCoord1;
|
||||
out vec3 _normal;
|
||||
out vec3 _tangent;
|
||||
out vec3 _color;
|
||||
out float _alpha;
|
||||
out vec4 _worldFadePosition;
|
||||
|
||||
void main(void) {
|
||||
vec4 position = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
|
||||
|
||||
// pass along the color
|
||||
_color = colorToLinearRGB(inColor.rgb);
|
||||
_alpha = inColor.a;
|
||||
|
||||
TexMapArray texMapArray = getTexMapArray();
|
||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||
|
||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
|
||||
|
||||
// standard transform
|
||||
TransformCamera cam = getTransformCamera();
|
||||
TransformObject obj = getTransformObject();
|
||||
<$transformModelToEyeAndClipPos(cam, obj, position, _position, gl_Position)$>
|
||||
<$transformModelToFadePos(obj, inPosition, _worldFadePosition)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$>
|
||||
<$transformModelToWorldDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$>
|
||||
|
||||
_normal = interpolatedNormal.xyz;
|
||||
_tangent = interpolatedTangent.xyz;
|
||||
}
|
|
@ -143,7 +143,7 @@ private:
|
|||
|
||||
int _trackedControllers { 0 };
|
||||
vr::IVRSystem*& _system;
|
||||
quint64 _timeTilCalibration { 0.0f };
|
||||
quint64 _timeTilCalibration { 0 };
|
||||
float _leftHapticStrength { 0.0f };
|
||||
float _leftHapticDuration { 0.0f };
|
||||
float _rightHapticStrength { 0.0f };
|
||||
|
|
|
@ -14,7 +14,7 @@ var qml = Script.resolvePath('fade.qml');
|
|||
var window = new OverlayWindow({
|
||||
title: 'Fade',
|
||||
source: qml,
|
||||
width: 400,
|
||||
width: 500,
|
||||
height: 80
|
||||
});
|
||||
window.setPosition(50, 50);
|
||||
|
|
|
@ -12,22 +12,45 @@ import QtQuick 2.5
|
|||
import QtQuick.Controls 1.4
|
||||
import "configSlider"
|
||||
|
||||
Column {
|
||||
id: root
|
||||
spacing: 8
|
||||
property var drawOpaqueConfig: Render.getConfig("DrawOpaqueDeferred");
|
||||
Row {
|
||||
property var drawOpaqueConfig: Render.getConfig("DrawOpaqueDeferred");
|
||||
property var drawTransparentConfig: Render.getConfig("DrawDeferred");
|
||||
spacing: 4
|
||||
Column {
|
||||
spacing: 8
|
||||
|
||||
CheckBox {
|
||||
text: "Force Fade"
|
||||
checked: drawOpaqueConfig["debugFade"]
|
||||
onCheckedChanged: { drawOpaqueConfig["debugFade"] = checked }
|
||||
CheckBox {
|
||||
text: "Force Fade Opaque"
|
||||
checked: drawOpaqueConfig["debugFade"]
|
||||
onCheckedChanged: { drawOpaqueConfig["debugFade"] = checked }
|
||||
}
|
||||
CheckBox {
|
||||
text: "Force Fade Transparent"
|
||||
checked: drawTransparentConfig["debugFade"]
|
||||
onCheckedChanged: { drawTransparentConfig["debugFade"] = checked }
|
||||
}
|
||||
}
|
||||
ConfigSlider {
|
||||
label: "Percent"
|
||||
integral: false
|
||||
config: drawOpaqueConfig
|
||||
property: "debugFadePercent"
|
||||
max: 1.0
|
||||
min: 0.0
|
||||
Column {
|
||||
spacing: 8
|
||||
|
||||
ConfigSlider {
|
||||
label: "Percent"
|
||||
integral: false
|
||||
config: drawOpaqueConfig
|
||||
property: "debugFadePercent"
|
||||
max: 1.0
|
||||
min: 0.0
|
||||
width: 250
|
||||
}
|
||||
ConfigSlider {
|
||||
label: "Percent"
|
||||
integral: false
|
||||
config: drawTransparentConfig
|
||||
property: "debugFadePercent"
|
||||
max: 1.0
|
||||
min: 0.0
|
||||
width: 250
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue