Merge pull request #15671 from SamGondelman/uber

DEV-203, BUGZ-978: Condense all redundant shader variants using new slp defines feature and add Haze to Forward renderer
This commit is contained in:
Shannon Romano 2019-07-12 09:39:33 -07:00 committed by GitHub
commit 3e70f4f51c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
205 changed files with 1487 additions and 4373 deletions

View file

@ -268,6 +268,7 @@ macro(AUTOSCRIBE_SHADER_LIB)
set(PROGRAM_ENUMS "namespace program { enum {\n")
foreach(PROGRAM_FILE ${SHADER_PROGRAM_FILES})
get_filename_component(PROGRAM_NAME ${PROGRAM_FILE} NAME_WE)
get_filename_component(PROGRAM_FOLDER ${PROGRAM_FILE} DIRECTORY)
file(READ ${PROGRAM_FILE} PROGRAM_CONFIG)
set(AUTOSCRIBE_PROGRAM_VERTEX ${PROGRAM_NAME})
set(AUTOSCRIBE_PROGRAM_FRAGMENT ${PROGRAM_NAME})
@ -315,7 +316,11 @@ macro(AUTOSCRIBE_SHADER_LIB)
if (HAS_FRAGMENT EQUAL -1)
set(DEFINES "${VERTEX_DEFINES}")
set(SHADER_LIST "")
set(SHADER_FILE "${SRC_FOLDER}/${VERTEX_NAME}.slv")
set(SHADER_FILE "${PROGRAM_FOLDER}/${VERTEX_NAME}.slv")
if (NOT EXISTS "${SHADER_FILE}")
set(SHADER_FILE "${PROGRAM_FOLDER}/../${VERTEX_NAME}.slv")
endif()
find_file(SHADER_FILE "" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES ".." NO_DEFAULT_PATH)
AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS})
string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}")
else()
@ -331,7 +336,10 @@ macro(AUTOSCRIBE_SHADER_LIB)
if (HAS_VERTEX EQUAL -1)
set(DEFINES "${FRAGMENT_DEFINES}")
set(SHADER_LIST "")
set(SHADER_FILE "${SRC_FOLDER}/${FRAGMENT_NAME}.slf")
set(SHADER_FILE "${PROGRAM_FOLDER}/${FRAGMENT_NAME}.slf")
if (NOT EXISTS "${SHADER_FILE}")
set(SHADER_FILE "${PROGRAM_FOLDER}/../${FRAGMENT_NAME}.slf")
endif()
AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS})
string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}")
else()

View file

@ -259,7 +259,7 @@ void GraphicsEngine::render_performFrame() {
batch.enableSkybox(true);
batch.enableStereo(isStereo);
batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() });
_splashScreen->render(batch, viewFrustum);
_splashScreen->render(batch, viewFrustum, renderArgs._renderMethod == RenderArgs::RenderMethod::FORWARD);
});
} else {
{

View file

@ -405,7 +405,8 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo
using namespace shader::render_utils::program;
static const std::vector<std::tuple<bool, bool, uint32_t>> keys = {
std::make_tuple(false, false, parabola), std::make_tuple(false, true, forward_parabola), std::make_tuple(true, false, parabola_translucent)/*, std::make_tuple(true, true, forward_parabola_translucent)*/
std::make_tuple(false, false, parabola), std::make_tuple(false, true, parabola_forward),
std::make_tuple(true, false, parabola_translucent), std::make_tuple(true, true, parabola_forward) // The forward opaque/translucent pipelines are the same for now
};
for (auto& key : keys) {
@ -423,9 +424,6 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo
_parabolaPipelines[{std::get<0>(key), std::get<1>(key)}] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state);
}
// The forward opaque/translucent pipelines are the same for now
_parabolaPipelines[{ true, true }] = _parabolaPipelines[{ false, true}];
}
return _parabolaPipelines[{ _parabolaData.color.a < 1.0f, forward }];
}

View file

@ -122,7 +122,7 @@ void GridEntityRenderer::doRender(RenderArgs* args) {
forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD;
});
if (!_visible) {
if (!_visible || color.a == 0.0f) {
return;
}

View file

@ -23,7 +23,7 @@ static uint8_t CUSTOM_PIPELINE_NUMBER = 0;
static gpu::Stream::FormatPointer _vertexFormat;
static std::weak_ptr<gpu::Pipeline> _texturedPipeline;
static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) {
auto texturedPipeline = _texturedPipeline.lock();
if (!texturedPipeline) {
auto state = std::make_shared<gpu::State>();

View file

@ -34,9 +34,7 @@
#include "EntityTreeRenderer.h"
#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT
# include <FadeEffect.h>
#endif
#include <FadeEffect.h>
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
@ -1553,52 +1551,49 @@ using namespace render;
using namespace render::entities;
static uint8_t CUSTOM_PIPELINE_NUMBER;
static gpu::PipelinePointer _pipelines[2];
static gpu::PipelinePointer _wireframePipelines[2];
static std::map<std::tuple<bool, bool, bool>, ShapePipelinePointer> _pipelines;
static gpu::Stream::FormatPointer _vertexFormat;
ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
if (!_pipelines[0]) {
ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) {
// FIXME: custom pipelines like this don't handle shadows or renderLayers correctly
if (_pipelines.empty()) {
using namespace shader::entities_renderer::program;
int programsIds[2] = { polyvox, polyvox_fade };
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
PrepareStencil::testMaskDrawShape(*state);
static const std::vector<std::tuple<bool, bool, uint32_t>> keys = {
std::make_tuple(false, false, polyvox), std::make_tuple(true, false, polyvox_forward)
#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT
, std::make_tuple(false, true, polyvox_fade), std::make_tuple(true, true, polyvox_forward_fade)
#else
, std::make_tuple(false, true, polyvox), std::make_tuple(true, true, polyvox_forward)
#endif
};
for (auto& key : keys) {
for (int i = 0; i < 2; ++i) {
bool wireframe = i != 0;
auto wireframeState = std::make_shared<gpu::State>();
wireframeState->setCullMode(gpu::State::CULL_BACK);
wireframeState->setDepthTest(true, true, gpu::LESS_EQUAL);
wireframeState->setFillMode(gpu::State::FILL_LINE);
PrepareStencil::testMaskDrawShape(*wireframeState);
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_BACK);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
PrepareStencil::testMaskDrawShape(*state);
// Two sets of pipelines: normal and fading
for (auto i = 0; i < 2; i++) {
gpu::ShaderPointer program = gpu::Shader::createProgram(programsIds[i]);
_pipelines[i] = gpu::Pipeline::create(program, state);
_wireframePipelines[i] = gpu::Pipeline::create(program, wireframeState);
if (wireframe) {
state->setFillMode(gpu::State::FILL_LINE);
}
auto pipeline = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state);
if (std::get<1>(key)) {
_pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared<render::ShapePipeline>(pipeline, nullptr, nullptr, nullptr);
} else {
const auto& fadeEffect = DependencyManager::get<FadeEffect>();
_pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared<render::ShapePipeline>(pipeline, nullptr,
fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
}
}
}
}
#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT
if (key.isFaded()) {
const auto& fadeEffect = DependencyManager::get<FadeEffect>();
if (key.isWireframe()) {
return std::make_shared<render::ShapePipeline>(_wireframePipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
} else {
return std::make_shared<render::ShapePipeline>(_pipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter());
}
} else {
#endif
if (key.isWireframe()) {
return std::make_shared<render::ShapePipeline>(_wireframePipelines[0], nullptr, nullptr, nullptr);
} else {
return std::make_shared<render::ShapePipeline>(_pipelines[0], nullptr, nullptr, nullptr);
}
#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT
}
#endif
return _pipelines[std::make_tuple(args->_renderMethod == Args::RenderMethod::FORWARD, key.isFaded(), key.isWireframe())];
}
PolyVoxEntityRenderer::PolyVoxEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {

View file

@ -30,14 +30,11 @@ using namespace render::entities;
// is a half unit sphere. However, the geometry cache renders a UNIT sphere, so we need to scale down.
static const float SPHERE_ENTITY_SCALE = 0.5f;
static_assert(shader::render_utils::program::simple != 0, "Validate simple program exists");
static_assert(shader::render_utils::program::simple_transparent != 0, "Validate simple transparent program exists");
ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
_procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::render_utils::vertex::simple);
_procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::render_utils::vertex::simple_procedural);
// FIXME: Setup proper uniform slots and use correct pipelines for forward rendering
_procedural._opaqueFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple);
_procedural._transparentFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_transparent);
_procedural._opaqueFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_procedural);
_procedural._transparentFragmentSource = gpu::Shader::Source::get(shader::render_utils::fragment::simple_procedural_translucent);
// TODO: move into Procedural.cpp
PrepareStencil::testMaskDrawShape(*_procedural._opaqueState);

View file

@ -315,12 +315,19 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
gpu::Batch& batch = *args->_batch;
glm::vec4 color;
Transform transform;
bool forward;
withReadLock([&] {
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
color = glm::vec4(toGlm(_color), _alpha * fadeRatio);
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
transform = _renderTransform;
forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == render::Args::FORWARD;
});
if (color.a == 0.0f) {
return;
}
batch.setResourceTexture(0, _texture);
transform.setRotation(EntityItem::getBillboardRotation(transform.getTranslation(), transform.getRotation(), _billboardMode, args->getViewFrustum().getPosition()));
@ -328,7 +335,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
// Turn off jitter for these entities
batch.pushProjectionJitter();
DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD);
DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward);
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId);
batch.popProjectionJitter();
batch.setResourceTexture(0, nullptr);

View file

@ -0,0 +1 @@
DEFINES forward

View file

@ -0,0 +1 @@
DEFINES (shadow fade)/forward

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// paintStroke.frag
// fragment shader
//
// Created by Eric Levin on 8/10/2015
// Copyright 2015 High Fidelity, Inc.
//
@ -12,29 +10,32 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
<@else@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
<@include paintStroke.slh@>
<$declarePolyLineBuffers()$>
LAYOUT(binding=0) uniform sampler2D _texture;
layout(location=0) in vec3 _normalWS;
<@if not HIFI_USE_FORWARD@>
layout(location=0) in vec3 _normalWS;
<@endif@>
layout(location=1) in vec2 _texCoord;
layout(location=2) in vec4 _color;
layout(location=3) in float _distanceFromCenter;
void main(void) {
vec4 texel = texture(_texture, _texCoord);
float frontCondition = 2.0 * float(gl_FrontFacing) - 1.0;
vec3 color = _color.rgb * texel.rgb;
float alpha = texel.a * _color.a;
texel *= _color;
texel.a *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y);
alpha *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y);
packDeferredFragmentTranslucent(
_normalWS * frontCondition,
alpha,
color,
DEFAULT_ROUGHNESS);
<@if not HIFI_USE_FORWARD@>
packDeferredFragmentTranslucent((2.0 * float(gl_FrontFacing) - 1.0) * _normalWS, texel.a, texel.rgb, DEFAULT_ROUGHNESS);
<@else@>
_fragColor0 = texel;
<@endif@>
}

View file

@ -1,10 +1,8 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// paintStroke.vert
// vertex shader
//
// Created by Eric Levin on 7/20/15.
// Copyright 2014 High Fidelity, Inc.
//
@ -20,7 +18,9 @@
<@include paintStroke.slh@>
<$declarePolyLineBuffers()$>
layout(location=0) out vec3 _normalWS;
<@if not HIFI_USE_FORWARD@>
layout(location=0) out vec3 _normalWS;
<@endif@>
layout(location=1) out vec2 _texCoord;
layout(location=2) out vec4 _color;
layout(location=3) out float _distanceFromCenter;
@ -50,11 +50,15 @@ void main(void) {
vec3 binormalEye = normalize(cross(normalEye, tangentEye));
posEye.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormalEye;
<$transformEyeToClipPos(cam, posEye, gl_Position)$>
<@if not HIFI_USE_FORWARD@>
<$transformEyeToWorldDir(cam, normalEye, _normalWS)$>
<@endif@>
} else {
vec3 normal = vertex.normal.xyz;
position.xyz += _distanceFromCenter * vertex.binormalAndHalfWidth.w * binormal;
<$transformModelToClipPos(cam, obj, position, gl_Position)$>
<@if not HIFI_USE_FORWARD@>
<$transformModelToWorldDir(cam, obj, normal, _normalWS)$>
<@endif@>
}
}

View file

@ -1,35 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// paintStroke.frag
// fragment shader
//
// Created by Eric Levin on 8/10/2015
// Copyright 2015 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 paintStroke.slh@>
<$declarePolyLineBuffers()$>
LAYOUT(binding=0) uniform sampler2D _texture;
layout(location=0) in vec3 _normalWS;
layout(location=1) in vec2 _texCoord;
layout(location=2) in vec4 _color;
layout(location=3) in float _distanceFromCenter;
layout(location=0) out vec4 _fragColor0;
void main(void) {
vec4 texel = texture(_texture, _texCoord);
int frontCondition = 1 - 2 * int(gl_FrontFacing);
vec3 color = _color.rgb * texel.rgb;
float alpha = texel.a * _color.a;
alpha *= mix(1.0, pow(1.0 - abs(_distanceFromCenter), 10.0), _polylineData.faceCameraGlow.y);
_fragColor0 = vec4(color, alpha);
}

View file

@ -1,8 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// polyvox.frag
// fragment shader
//
// Created by Seth Alves on 2015-8-3
// Copyright 2015 High Fidelity, Inc.
@ -11,51 +10,111 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include graphics/Material.slh@>
<@include DeferredBufferWrite.slh@>
<@include render-utils/ShaderConstants.h@>
<@include entities-renderer/ShaderConstants.h@>
<@if HIFI_USE_FADE@>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normal;
layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _position;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _worldPosition;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
<@endif@>
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap;
<@if not HIFI_USE_SHADOW@>
<@include graphics/Material.slh@>
<@include render-utils/ShaderConstants.h@>
<@include entities-renderer/ShaderConstants.h@>
struct PolyvoxParams {
vec4 voxelVolumeSize;
};
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
<@else@>
<@include DefaultMaterials.slh@>
LAYOUT(binding=0) uniform polyvoxParamsBuffer {
PolyvoxParams params;
};
<@include GlobalLight.slh@>
<$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@endif@>
<@if HIFI_USE_FORWARD@>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
<@endif@>
layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec3 _positionMS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap;
struct PolyvoxParams {
vec4 voxelVolumeSize;
};
LAYOUT(binding=0) uniform polyvoxParamsBuffer {
PolyvoxParams params;
};
<@endif@>
<@if HIFI_USE_SHADOW or HIFI_USE_FORWARD@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
void main(void) {
vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz));
worldNormal = normalize(worldNormal);
<@if HIFI_USE_FADE@>
<@if not HIFI_USE_SHADOW@>
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
<@else@>
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFadeClip(fadeParams, _positionWS.xyz);
<@endif@>
<@endif@>
float inPositionX = (_worldPosition.x - 0.5) / params.voxelVolumeSize.x;
float inPositionY = (_worldPosition.y - 0.5) / params.voxelVolumeSize.y;
float inPositionZ = (_worldPosition.z - 0.5) / params.voxelVolumeSize.z;
<@if not HIFI_USE_SHADOW@>
float inPositionX = (_positionMS.x - 0.5) / params.voxelVolumeSize.x;
float inPositionY = (_positionMS.y - 0.5) / params.voxelVolumeSize.y;
float inPositionZ = (_positionMS.z - 0.5) / params.voxelVolumeSize.z;
vec4 xyDiffuse = texture(xMap, vec2(-inPositionX, -inPositionY));
vec4 xzDiffuse = texture(yMap, vec2(-inPositionX, inPositionZ));
vec4 yzDiffuse = texture(zMap, vec2(inPositionZ, -inPositionY));
vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(worldNormal.z);
vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(worldNormal.y);
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x);
vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0);
vec3 normalMS = normalize(cross(dFdy(_positionMS.xyz), dFdx(_positionMS.xyz)));
vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(normalMS.z);
vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(normalMS.y);
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(normalMS.x);
vec3 diffuse = vec3(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled);
packDeferredFragment(
_normal,
1.0,
vec3(diffuse),
DEFAULT_ROUGHNESS,
DEFAULT_METALLIC,
DEFAULT_EMISSIVE,
DEFAULT_OCCLUSION,
DEFAULT_SCATTERING);
<@if not HIFI_USE_FORWARD@>
packDeferredFragment(
normalize(_normalWS),
1.0,
diffuse,
DEFAULT_ROUGHNESS,
DEFAULT_METALLIC,
DEFAULT_EMISSIVE
<@if HIFI_USE_FADE@>
+ fadeEmissive
<@endif@>
,
DEFAULT_OCCLUSION,
DEFAULT_SCATTERING);
<@else@>
TransformCamera cam = getTransformCamera();
_fragColor0 = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
_positionES.xyz,
normalize(_normalWS),
diffuse,
DEFAULT_FRESNEL,
DEFAULT_METALLIC,
DEFAULT_ROUGHNESS),
1.0);
<@endif@>
<@else@>
_fragColor0 = vec4(1.0);
<@endif@>
}

View file

@ -1,8 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// polyvox.vert
// vertex shader
//
// Copyright 2015 High Fidelity, Inc.
//
@ -11,20 +10,39 @@
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<@include render-utils/ShaderConstants.h@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _position;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _worldPosition;
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normal;
<@if HIFI_USE_FADE@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
<@endif@>
<@if not HIFI_USE_SHADOW@>
<@if HIFI_USE_FORWARD@>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
<@endif@>
layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec3 _positionMS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
<@endif@>
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
_worldPosition = inPosition;
<@if HIFI_USE_SHADOW@>
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<@else@>
<@if not HIFI_USE_FORWARD@>
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<@else@>
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$>
<@endif@>
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
_positionMS = inPosition.xyz;
<@endif@>
<@if HIFI_USE_FADE@>
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
<@endif@>
}

View file

@ -1,73 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// polyvox_fade.frag
// fragment shader
//
// Created by Olivier Prat on 2017-06-08
// 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 graphics/Material.slh@>
<@include DeferredBufferWrite.slh@>
<@include render-utils/ShaderConstants.h@>
<@include entities-renderer/ShaderConstants.h@>
<@include Fade.slh@>
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normal;
layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _position;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _worldPosition;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _worldFadePosition;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_XMAP) uniform sampler2D xMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_YMAP) uniform sampler2D yMap;
LAYOUT(binding=ENTITIES_TEXTURE_POLYVOX_ZMAP) uniform sampler2D zMap;
struct PolyvoxParams {
vec4 voxelVolumeSize;
};
LAYOUT(binding=0) uniform polyvoxParamsBuffer {
PolyvoxParams params;
};
// Declare after all samplers to prevent sampler location mix up with voxel shading (sampler locations are hardcoded in RenderablePolyVoxEntityItem)
<$declareFadeFragment()$>
void main(void) {
vec3 emissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _worldFadePosition.xyz, emissive);
vec3 worldNormal = cross(dFdy(_worldPosition.xyz), dFdx(_worldPosition.xyz));
worldNormal = normalize(worldNormal);
float inPositionX = (_worldPosition.x - 0.5) / params.voxelVolumeSize.x;
float inPositionY = (_worldPosition.y - 0.5) / params.voxelVolumeSize.y;
float inPositionZ = (_worldPosition.z - 0.5) / params.voxelVolumeSize.z;
vec4 xyDiffuse = texture(xMap, vec2(-inPositionX, -inPositionY));
vec4 xzDiffuse = texture(yMap, vec2(-inPositionX, inPositionZ));
vec4 yzDiffuse = texture(zMap, vec2(inPositionZ, -inPositionY));
vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(worldNormal.z);
vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(worldNormal.y);
vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(worldNormal.x);
vec4 diffuse = vec4(xyDiffuseScaled + xzDiffuseScaled + yzDiffuseScaled, 1.0);
packDeferredFragment(
_normal,
1.0,
vec3(diffuse),
DEFAULT_ROUGHNESS,
DEFAULT_METALLIC,
DEFAULT_EMISSIVE+emissive,
DEFAULT_OCCLUSION,
DEFAULT_SCATTERING);
}

View file

@ -1,33 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// polyvox_fade.vert
// vertex shader
//
// Created by Seth Alves on 2015-8-3
// Copyright 2015 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/Transform.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareStandardTransform()$>
layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _position;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _worldPosition;
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normal;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _worldFadePosition;
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$>
<$transformModelToEyeDir(cam, obj, inNormal.xyz, _normal)$>
<$transformModelToWorldPos(obj, inPosition, _worldFadePosition)$>
_worldPosition = inPosition;
}

View file

@ -98,7 +98,7 @@ void Haze::setHazeGlareColor(const glm::vec3 hazeGlareColor) {
void Haze::setHazeActive(const bool isHazeActive) {
auto& params = _hazeParametersBuffer.get<Parameters>();
if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) {
if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) && !isHazeActive) {
_hazeParametersBuffer.edit<Parameters>().hazeMode &= ~HAZE_MODE_IS_ACTIVE;
} else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) {
_hazeParametersBuffer.edit<Parameters>().hazeMode |= HAZE_MODE_IS_ACTIVE;

View file

@ -10,7 +10,7 @@
<@if not HAZE_SLH@>
<@def HAZE_SLH@>
<@include render-utils/ShaderConstants.h@>
<@include graphics/ShaderConstants.h@>
const int HAZE_MODE_IS_ACTIVE = 1 << 0;
const int HAZE_MODE_IS_ALTITUDE_BASED = 1 << 1;
@ -38,8 +38,7 @@ struct HazeParams {
float hazeKeyLightAltitudeFactor;
};
// See ShapePipeline::Slot::BUFFER in ShapePipeline.h
LAYOUT_STD140(binding=RENDER_UTILS_BUFFER_HAZE_PARAMS) uniform hazeBuffer {
LAYOUT_STD140(binding=GRAPHICS_BUFFER_HAZE_PARAMS) uniform hazeBuffer {
HazeParams hazeParams;
};

View file

@ -32,6 +32,8 @@
#define GRAPHICS_TEXTURE_SKYBOX 11
#define GRAPHICS_BUFFER_SKYBOX_PARAMS 5
#define GRAPHICS_BUFFER_HAZE_PARAMS 7
// <!
namespace graphics { namespace slot {
@ -43,7 +45,8 @@ enum Buffer {
Light = GRAPHICS_BUFFER_LIGHT,
KeyLight = GRAPHICS_BUFFER_KEY_LIGHT,
AmbientLight = GRAPHICS_BUFFER_AMBIENT_LIGHT,
SkyboxParams = GRAPHICS_BUFFER_SKYBOX_PARAMS
SkyboxParams = GRAPHICS_BUFFER_SKYBOX_PARAMS,
HazeParams = GRAPHICS_BUFFER_HAZE_PARAMS
};
} // namespace buffer

View file

@ -73,29 +73,29 @@ void Skybox::prepare(gpu::Batch& batch) const {
}
}
void Skybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
void Skybox::render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const {
updateSchemaBuffer();
Skybox::render(batch, frustum, (*this));
Skybox::render(batch, frustum, (*this), forward);
}
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox) {
// Create the static shared elements used to render the skybox
static gpu::BufferPointer theConstants;
static gpu::PipelinePointer thePipeline;
static std::once_flag once;
std::call_once(once, [&] {
{
auto skyShader = gpu::Shader::createProgram(shader::graphics::program::skybox);
auto skyState = std::make_shared<gpu::State>();
static std::map<bool, gpu::PipelinePointer> _pipelines;
void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox, bool forward) {
if (_pipelines.empty()) {
static const std::vector<std::tuple<bool, uint32_t>> keys = {
std::make_tuple(false, shader::graphics::program::skybox),
std::make_tuple(true, shader::graphics::program::skybox_forward)
};
for (auto& key : keys) {
auto state = std::make_shared<gpu::State>();
// Must match PrepareStencil::STENCIL_BACKGROUND
const int8_t STENCIL_BACKGROUND = 0;
skyState->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL,
state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL,
gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP));
thePipeline = gpu::Pipeline::create(skyShader, skyState);
_pipelines[std::get<0>(key)] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<1>(key)), state);
}
});
}
// Render
glm::mat4 projMat;
@ -111,7 +111,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
batch.setViewTransform(viewTransform);
batch.setModelTransform(Transform()); // only for Mac
batch.setPipeline(thePipeline);
batch.setPipeline(_pipelines[forward]);
skybox.prepare(batch);
batch.draw(gpu::TRIANGLE_STRIP, 4);

View file

@ -44,9 +44,9 @@ public:
virtual void clear();
void prepare(gpu::Batch& batch) const;
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const;
virtual void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const;
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox);
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox, bool forward);
const UniformBufferView& getSchemaBuffer() const { return _schemaBuffer; }

View file

@ -1,8 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// skybox.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2015.
// Copyright 2015 High Fidelity, Inc.
@ -12,6 +11,16 @@
//
<@include graphics/ShaderConstants.h@>
<@if HIFI_USE_FORWARD@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include graphics/Light.slh@>
<$declareLightBuffer()$>
<@include graphics/Haze.slh@>
<@endif@>
LAYOUT(binding=GRAPHICS_TEXTURE_SKYBOX) uniform samplerCube cubeMap;
struct Skybox {
@ -32,8 +41,28 @@ void main(void) {
// mix(skyboxColor, skyboxTexel, skybox.color.a)
// and the blend factor should be user controlled
vec3 skyboxTexel = texture(cubeMap, normalize(_normal)).rgb;
vec3 normal = normalize(_normal);
vec3 skyboxTexel = texture(cubeMap, normal).rgb;
vec3 skyboxColor = skybox.color.rgb;
_fragColor = vec4(mix(vec3(1.0), skyboxTexel, float(skybox.color.a > 0.0)) *
mix(vec3(1.0), skyboxColor, float(skybox.color.a < 1.0)), 1.0);
<@if HIFI_USE_FORWARD@>
// FIXME: either move this elsewhere or give it access to isHazeEnabled() (which is in render-utils/LightingModel.slh)
if (/*(isHazeEnabled() > 0.0) && */(hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
TransformCamera cam = getTransformCamera();
vec4 eyePositionWS = cam._viewInverse[3];
// We choose an arbitrary large number > BLEND_DISTANCE in Haze.slh
const float SKYBOX_DISTANCE = 32000.0;
vec4 fragPositionWS = eyePositionWS + SKYBOX_DISTANCE * vec4(normal, 0.0);
vec4 fragPositionES = cam._view * fragPositionWS;
Light light = getKeyLight();
vec3 lightDirectionWS = getLightDirection(light);
vec4 hazeColor = computeHazeColor(fragPositionES.xyz, fragPositionWS.xyz, eyePositionWS.xyz, lightDirectionWS);
_fragColor.rgb = mix(_fragColor.rgb, hazeColor.rgb, hazeColor.a);
}
<@endif@>
}

View file

@ -0,0 +1 @@
DEFINES forward:f

View file

@ -1,8 +1,7 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// skybox.vert
// vertex shader
//
// Created by Sam Gateau on 5/5/2015.
// Copyright 2015 High Fidelity, Inc.
@ -12,7 +11,6 @@
//
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
layout(location=0) out vec3 _normal;

View file

@ -18,6 +18,7 @@
#include <shaders/Shaders.h>
ProceduralSkybox::ProceduralSkybox(uint64_t created) : graphics::Skybox(), _created(created) {
// FIXME: support forward rendering for procedural skyboxes (needs haze calculation)
_procedural._vertexSource = gpu::Shader::createVertex(shader::graphics::vertex::skybox)->getSource();
_procedural._opaqueFragmentSource = shader::Source::get(shader::procedural::fragment::proceduralSkybox);
// Adjust the pipeline state for background using the stencil test
@ -40,15 +41,15 @@ void ProceduralSkybox::clear() {
Skybox::clear();
}
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const {
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const {
if (_procedural.isReady()) {
ProceduralSkybox::render(batch, frustum, (*this));
ProceduralSkybox::render(batch, frustum, (*this), forward);
} else {
Skybox::render(batch, frustum);
Skybox::render(batch, frustum, forward);
}
}
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) {
void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox, bool forward) {
glm::mat4 projMat;
viewFrustum.evalProjectionMatrix(projMat);

View file

@ -26,8 +26,8 @@ public:
bool empty() override;
void clear() override;
void render(gpu::Batch& batch, const ViewFrustum& frustum) const override;
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox);
void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const override;
static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox, bool forward);
uint64_t getCreated() const { return _created; }

View file

@ -13,6 +13,8 @@
#include <gpu/Context.h>
#include <graphics/ShaderConstants.h>
std::string BackgroundStage::_stageName { "BACKGROUND_STAGE"};
const BackgroundStage::Index BackgroundStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX };
@ -71,6 +73,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
}
}
const auto& hazeFrame = inputs.get2();
if (skybox && !skybox->empty()) {
PerformanceTimer perfTimer("skybox");
auto args = renderContext->args;
@ -91,7 +95,18 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext,
batch.setProjectionTransform(projMat);
batch.setViewTransform(viewMat);
skybox->render(batch, args->getViewFrustum());
// If we're using forward rendering, we need to calculate haze
if (args->_renderMethod == render::Args::RenderMethod::FORWARD) {
const auto& hazeStage = args->_scene->getStage<HazeStage>();
if (hazeStage && hazeFrame->_hazes.size() > 0) {
const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front());
if (hazePointer) {
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
}
}
}
skybox->render(batch, args->getViewFrustum(), args->_renderMethod == render::Args::RenderMethod::FORWARD);
});
args->_batch = nullptr;
}

View file

@ -16,6 +16,7 @@
#include <unordered_map>
#include <render/IndexedContainer.h>
#include <render/Stage.h>
#include "HazeStage.h"
#include "LightingModel.h"
@ -81,7 +82,7 @@ public:
class DrawBackgroundStage {
public:
using Inputs = render::VaryingSet2<LightingModelPointer, BackgroundStage::FramePointer>;
using Inputs = render::VaryingSet3<LightingModelPointer, BackgroundStage::FramePointer, HazeStage::FramePointer>;
using JobModel = render::Job::ModelI<DrawBackgroundStage, Inputs>;
DrawBackgroundStage() {}

View file

@ -432,7 +432,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext,
if (hazeStage && hazeFrame->_hazes.size() > 0) {
const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front());
if (hazePointer) {
batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
}
}
@ -655,7 +655,6 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) {
if (!_defaultHaze) {
auto hazeStage = renderContext->_scene->getStage<HazeStage>();
if (hazeStage) {
auto haze = std::make_shared<graphics::Haze>();
_defaultHaze = haze;

View file

@ -78,7 +78,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(outputFramebufferSize, args->_viewport));
batch.setPipeline(_hazePipeline);
batch.setUniformBuffer(ru::Buffer::HazeParams, haze->getHazeParametersBuffer());
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer());
batch.setUniformBuffer(ru::Buffer::DeferredFrameTransform, transformBuffer->getFrameTransformBuffer());
batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer());

View file

@ -1,247 +0,0 @@
<!
// ForwardGlobalLight.slh
// libraries/render-utils/src
//
// Created by Gabriel Calero & Cristian Duarte on 4/7/17.
// Copyright 2013 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
!>
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
<@include graphics/Light.slh@>
<@include LightingModel.slh@>
<$declareLightBuffer()$>
<$declareLightAmbientBuffer()$>
<@include LightAmbient.slh@>
<@include LightDirectional.slh@>
<@func prepareGlobalLight(positionES, normalWS)@>
// prepareGlobalLight
// Transform directions to worldspace
vec3 fragNormalWS = vec3(<$normalWS$>);
vec3 fragPositionWS = vec3(invViewMat * vec4(<$positionES$>, 1.0));
vec3 fragEyeVectorWS = invViewMat[3].xyz - fragPositionWS;
vec3 fragEyeDirWS = normalize(fragEyeVectorWS);
// Get light
Light light = getKeyLight();
LightAmbient lightAmbient = getLightAmbient();
vec3 lightDirection = getLightDirection(light);
vec3 lightIrradiance = getLightIrradiance(light);
vec3 color = vec3(0.0);
<@endfunc@>
<@func declareEvalAmbientGlobalColor()@>
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) {
<$prepareGlobalLight(position, normal)$>
color += albedo * getLightColor(light) * obscurance * getLightAmbientIntensity(lightAmbient);
return color;
}
<@endfunc@>
<@func declareEvalAmbientSphereGlobalColor(supportScattering)@>
<$declareLightingAmbient(1, _SCRIBE_NULL, _SCRIBE_NULL, $supportScattering$)$>
<$declareLightingDirectional($supportScattering$)$>
<@if supportScattering@>
<$declareDeferredCurvature()$>
<@endif@>
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
vec3 albedo, vec3 fresnel, float metallic, float roughness
<@if supportScattering@>
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
<@endif@> ) {
<$prepareGlobalLight(position, normal)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
// Ambient
vec3 ambientDiffuse;
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@> );
color += ambientDiffuse;
color += ambientSpecular;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@> );
color += directionalDiffuse;
color += directionalSpecular;
return color;
}
<@endfunc@>
<@func declareEvalSkyboxGlobalColor(supportScattering)@>
<$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$>
<$declareLightingDirectional($supportScattering$)$>
<@if supportScattering@>
<$declareDeferredCurvature()$>
<@endif@>
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
vec3 albedo, vec3 fresnel, float metallic, float roughness
<@if supportScattering@>
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
<@endif@>
) {
<$prepareGlobalLight(position, normal)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
// Ambient
vec3 ambientDiffuse;
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += ambientDiffuse;
color += ambientSpecular;
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += directionalDiffuse;
color += directionalSpecular;
// FIXME - temporarily removed until we support it for forward...
// Attenuate the light if haze effect selected
// if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
// color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
// }
return color;
}
<@endfunc@>
<@func declareEvalLightmappedColor()@>
vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 normal, vec3 albedo, vec3 lightmap) {
Light light = getKeyLight();
LightAmbient ambient = getLightAmbient();
// Catch normals perpendicular to the projection plane, hence the magic number for the threshold
// It should be just 0, but we have inaccuracy so we overshoot
const float PERPENDICULAR_THRESHOLD = -0.005;
vec3 fragNormal = vec3(invViewMat * vec4(normal, 0.0)); // transform to worldspace
float diffuseDot = dot(fragNormal, -getLightDirection(light));
float facingLight = step(PERPENDICULAR_THRESHOLD, diffuseDot);
// Reevaluate the shadow attenuation for light facing fragments
float lightAttenuation = (1.0 - facingLight) + facingLight * shadowAttenuation;
// Diffuse light is the lightmap dimmed by shadow
vec3 diffuseLight = lightAttenuation * lightmap;
// Ambient light is the lightmap when in shadow
vec3 ambientLight = (1.0 - lightAttenuation) * lightmap * getLightAmbientIntensity(ambient);
return isLightmapEnabled() * obscurance * albedo * (diffuseLight + ambientLight);
}
<@endfunc@>
<@include Haze.slh@>
<@func declareEvalGlobalLightingAlphaBlended()@>
<$declareLightingAmbient(1, 1, 1)$>
<$declareLightingDirectional()$>
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) {
<$prepareGlobalLight(position, normal)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
color += emissive * isEmissiveEnabled();
// Ambient
vec3 ambientDiffuse;
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
color += ambientDiffuse;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
color += directionalDiffuse;
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
return color;
}
vec3 evalGlobalLightingAlphaBlendedWithHaze(
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
{
<$prepareGlobalLight(position, normal)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
color += emissive * isEmissiveEnabled();
// Ambient
vec3 ambientDiffuse;
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
color += ambientDiffuse;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
color += directionalDiffuse;
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
// Haze
// FIXME - temporarily removed until we support it for forward...
/* if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
fragPositionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector
);
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
}*/
return color;
}
<@endfunc@>
<@endif@>

View file

@ -113,6 +113,7 @@ static const uint SHAPE_NORMALS_OFFSET = offsetof(GeometryCache::ShapeVertex, no
static const uint SHAPE_TEXCOORD0_OFFSET = offsetof(GeometryCache::ShapeVertex, uv);
static const uint SHAPE_TANGENT_OFFSET = offsetof(GeometryCache::ShapeVertex, tangent);
std::map<std::pair<bool, bool>, gpu::PipelinePointer> GeometryCache::_webPipelines;
std::map<std::pair<bool, bool>, gpu::PipelinePointer> GeometryCache::_gridPipelines;
void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityExtents, QVector<glm::vec3> &outPointList) {
@ -2018,7 +2019,7 @@ void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bo
const float DEPTH_BIAS = 0.001f;
static const std::vector<std::tuple<bool, bool, uint32_t>> keys = {
std::make_tuple(false, false, grid), std::make_tuple(false, true, forward_grid), std::make_tuple(true, false, grid_translucent), std::make_tuple(true, true, forward_grid_translucent)
std::make_tuple(false, false, grid), std::make_tuple(false, true, grid_forward), std::make_tuple(true, false, grid_translucent), std::make_tuple(true, true, grid_translucent_forward)
};
for (auto& key : keys) {
@ -2109,34 +2110,35 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
return a.getRaw() == b.getRaw();
}
static void buildWebShader(int programId, bool blendEnable,
gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) {
shaderPointerOut = gpu::Shader::createProgram(programId);
auto state = std::make_shared<gpu::State>();
state->setCullMode(gpu::State::CULL_NONE);
state->setDepthTest(true, true, gpu::LESS_EQUAL);
state->setBlendFunction(blendEnable,
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);
PrepareStencil::testMaskDrawShapeNoAA(*state);
pipelinePointerOut = gpu::Pipeline::create(shaderPointerOut, state);
void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent, bool forward) {
batch.setPipeline(getWebBrowserProgram(transparent, forward));
}
void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) {
batch.setPipeline(getWebBrowserProgram(transparent));
}
gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent, bool forward) {
if (_webPipelines.empty()) {
using namespace shader::render_utils::program;
const int NUM_WEB_PIPELINES = 4;
for (int i = 0; i < NUM_WEB_PIPELINES; ++i) {
bool transparent = i & 1;
bool forward = i & 2;
gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) {
static std::once_flag once;
std::call_once(once, [&]() {
// FIXME: need a forward pipeline for this
buildWebShader(shader::render_utils::program::simple_opaque_web_browser, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline);
buildWebShader(shader::render_utils::program::simple_transparent_web_browser, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline);
});
// For any non-opaque or non-deferred pipeline, we use web_browser_forward
auto pipeline = (transparent || forward) ? web_browser_forward : web_browser;
return transparent ? _simpleTransparentWebBrowserPipeline : _simpleOpaqueWebBrowserPipeline;
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
state->setDepthTest(true, true, gpu::LESS_EQUAL);
// FIXME: do we need a testMaskDrawNoAA?
PrepareStencil::testMaskDrawShapeNoAA(*state);
state->setBlendFunction(transparent,
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);
state->setCullMode(gpu::State::CULL_NONE);
_webPipelines[{ transparent, forward }] = gpu::Pipeline::create(gpu::Shader::createProgram(pipeline), state);
}
}
return _webPipelines[{ transparent, forward }];
}
void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased, bool isAntiAliased, bool forward) {
@ -2164,24 +2166,24 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
std::call_once(once, [&]() {
using namespace shader::render_utils::program;
_forwardSimpleShader = gpu::Shader::createProgram(forward_simple_textured);
_forwardTransparentShader = gpu::Shader::createProgram(forward_simple_textured_transparent);
_forwardUnlitShader = gpu::Shader::createProgram(forward_simple_textured_unlit);
_forwardSimpleShader = gpu::Shader::createProgram(simple_forward);
_forwardTransparentShader = gpu::Shader::createProgram(simple_translucent_forward);
_forwardUnlitShader = gpu::Shader::createProgram(simple_unlit_forward);
_simpleShader = gpu::Shader::createProgram(simple_textured);
_transparentShader = gpu::Shader::createProgram(simple_transparent_textured);
_unlitShader = gpu::Shader::createProgram(simple_textured_unlit);
_simpleShader = gpu::Shader::createProgram(simple);
_transparentShader = gpu::Shader::createProgram(simple_translucent);
_unlitShader = gpu::Shader::createProgram(simple_unlit);
});
} else {
static std::once_flag once;
std::call_once(once, [&]() {
using namespace shader::render_utils::program;
// FIXME: these aren't right...
_forwardSimpleFadeShader = gpu::Shader::createProgram(forward_simple_textured);
_forwardUnlitFadeShader = gpu::Shader::createProgram(forward_simple_textured_unlit);
// Fading is currently disabled during forward rendering
_forwardSimpleFadeShader = gpu::Shader::createProgram(simple_forward);
_forwardUnlitFadeShader = gpu::Shader::createProgram(simple_unlit_forward);
_simpleFadeShader = gpu::Shader::createProgram(simple_textured_fade);
_unlitFadeShader = gpu::Shader::createProgram(simple_textured_unlit_fade);
_simpleFadeShader = gpu::Shader::createProgram(simple_fade);
_unlitFadeShader = gpu::Shader::createProgram(simple_unlit_fade);
});
}

View file

@ -168,8 +168,9 @@ public:
static gpu::PipelinePointer getSimplePipeline(bool textured = false, bool transparent = false, bool culled = true,
bool unlit = false, bool depthBias = false, bool fading = false, bool isAntiAliased = true, bool forward = false);
void bindWebBrowserProgram(gpu::Batch& batch, bool transparent = false);
gpu::PipelinePointer getWebBrowserProgram(bool transparent);
void bindWebBrowserProgram(gpu::Batch& batch, bool transparent, bool forward);
gpu::PipelinePointer getWebBrowserProgram(bool transparent, bool forward);
static std::map<std::pair<bool, bool>, gpu::PipelinePointer> _webPipelines;
static void initializeShapePipelines();
render::ShapePipelinePointer getShapePipelinePointer(bool transparent, bool unlit, bool forward) { return _shapePipelines[std::make_tuple(transparent, unlit, forward)]; }
@ -458,11 +459,6 @@ private:
static std::map<std::tuple<bool, bool, bool>, render::ShapePipelinePointer> _shapePipelines;
static QHash<SimpleProgramKey, gpu::PipelinePointer> _simplePrograms;
gpu::ShaderPointer _simpleOpaqueWebBrowserShader;
gpu::PipelinePointer _simpleOpaqueWebBrowserPipeline;
gpu::ShaderPointer _simpleTransparentWebBrowserShader;
gpu::PipelinePointer _simpleTransparentWebBrowserPipeline;
static render::ShapePipelinePointer getShapePipeline(bool textured = false, bool transparent = false, bool culled = true,
bool unlit = false, bool depthBias = false, bool forward = false);
static render::ShapePipelinePointer getFadingShapePipeline(bool textured = false, bool transparent = false, bool culled = true,

View file

@ -1,5 +1,5 @@
<!
// DeferredGlobalLight.slh
// GlobalLight.slh
// libraries/render-utils/src
//
// Created by Sam Gateau on 2/5/15.
@ -8,8 +8,8 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
!>
<@if not DEFERRED_GLOBAL_LIGHT_SLH@>
<@def DEFERRED_GLOBAL_LIGHT_SLH@>
<@if not GLOBAL_LIGHT_SLH@>
<@def GLOBAL_LIGHT_SLH@>
<@include graphics/Light.slh@>
@ -43,7 +43,6 @@
<@endfunc@>
<@func declareEvalAmbientGlobalColor()@>
vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, float roughness) {
<$prepareGlobalLight(position, normal)$>
@ -62,10 +61,11 @@ vec3 evalAmbientGlobalColor(mat4 invViewMat, float shadowAttenuation, float obsc
<@endif@>
vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
vec3 albedo, vec3 fresnel, float metallic, float roughness
vec3 albedo, vec3 fresnel, float metallic, float roughness
<@if supportScattering@>
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
<@endif@> ) {
<@endif@>
) {
<$prepareGlobalLight(position, normal)$>
@ -76,19 +76,20 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@> );
, scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += ambientDiffuse;
color += ambientSpecular;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
<@endif@> );
, scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += directionalDiffuse;
color += directionalSpecular;
@ -97,9 +98,9 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
<@endfunc@>
<@include Haze.slh@>
<@include graphics/Haze.slh@>
<@func declareEvalSkyboxGlobalColor(supportScattering)@>
<@func declareEvalSkyboxGlobalColor(supportScattering, computeHaze)@>
<$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$>
<$declareLightingDirectional($supportScattering$)$>
@ -108,13 +109,13 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness
<$declareDeferredCurvature()$>
<@endif@>
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal,
vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
vec3 albedo, vec3 fresnel, float metallic, float roughness
<@if supportScattering@>
, float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature
<@endif@>
) {
<$prepareGlobalLight(position, normal)$>
<$prepareGlobalLight(positionES, normalWS)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
@ -123,25 +124,41 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
, scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += ambientDiffuse;
color += ambientSpecular;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation
<@if supportScattering@>
,scattering, midNormalCurvature, lowNormalCurvature
, scattering, midNormalCurvature, lowNormalCurvature
<@endif@>
);
color += directionalDiffuse;
color += directionalSpecular;
// Attenuate the light if haze effect selected
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
// Haze
if (isHazeEnabled() > 0.0) {
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
}
<@if computeHaze@>
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
fragPositionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector in world coordinates
);
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
}
<@endif@>
}
return color;
@ -179,41 +196,10 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur
<$declareLightingAmbient(1, 1, 1)$>
<$declareLightingDirectional()$>
vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity, vec3 prevLighting) {
<$prepareGlobalLight(position, normal)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
color = prevLighting;
color += emissive * isEmissiveEnabled();
// Ambient
vec3 ambientDiffuse;
vec3 ambientSpecular;
evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance);
color += ambientDiffuse;
// Directional
vec3 directionalDiffuse;
vec3 directionalSpecular;
evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation);
color += directionalDiffuse;
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
return color;
}
<@endfunc@>
<@func declareEvalGlobalLightingAlphaBlendedWithHaze()@>
<$declareLightingAmbient(1, 1, 1)$>
<$declareLightingDirectional()$>
vec3 evalGlobalLightingAlphaBlendedWithHaze(
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
vec3 evalGlobalLightingAlphaBlended(
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity)
{
<$prepareGlobalLight(positionES, normalWS)$>
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS);
@ -234,23 +220,29 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
// Haze
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
fragPositionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector in world coordinates
);
if (isHazeEnabled() > 0.0) {
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
}
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
fragPositionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector in world coordinates
);
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
}
}
return color;
}
vec3 evalGlobalLightingAlphaBlendedWithHaze(
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS,
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting)
vec3 evalGlobalLightingAlphaBlended(
mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS,
vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting)
{
<$fetchGlobalLight()$>
@ -271,15 +263,23 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze(
color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity);
// Haze
if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
positionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector
);
if (isHazeEnabled() > 0.0) {
vec3 fragPositionWS = vec3(invViewMat * vec4(positionES, 1.0));
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) {
color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS);
}
if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) {
vec4 hazeColor = computeHazeColor(
positionES, // fragment position in eye coordinates
fragPositionWS, // fragment position in world coordinates
invViewMat[3].xyz, // eye position in world coordinates
lightDirection // keylight direction vector in world coordinates
);
color = mix(color.rgb, hazeColor.rgb, hazeColor.a);
}
}
return color;

View file

@ -15,11 +15,11 @@
<$declareDeferredFrameTransform()$>
<@include graphics/Light.slh@>
<@include LightingModel.slh@>
<$declareLightBuffer()$>
<@include Haze.slh@>
<@include LightingModel.slh@>
<@include graphics/Haze.slh@>
LAYOUT(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearDepthMap;

View file

@ -59,13 +59,21 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs&
const auto& inItems = inputs.get0();
const auto& lightingModel = inputs.get1();
const auto jitter = inputs.get2();
const auto& hazeFrame = inputs.get2();
const auto jitter = inputs.get3();
config->setNumDrawn((int)inItems.size());
emit config->numDrawnChanged();
RenderArgs* args = renderContext->args;
graphics::HazePointer haze;
const auto& hazeStage = renderContext->args->_scene->getStage<HazeStage>();
if (hazeStage && hazeFrame->_hazes.size() > 0) {
// We use _hazes.back() here because the last haze object will always have haze disabled.
haze = hazeStage->getHaze(hazeFrame->_hazes.back());
}
// Clear the framebuffer without stereo
// Needs to be distinct from the other batch because using the clear call
// while stereo is enabled triggers a warning
@ -96,6 +104,10 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs&
batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer());
batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT());
if (haze) {
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer());
}
if (_opaquePass) {
renderStateSortShapes(renderContext, _shapePlumber, inItems, _maxDrawn);
} else {

View file

@ -11,10 +11,9 @@
#include <gpu/Pipeline.h>
#include "LightStage.h"
#include "HazeStage.h"
#include "LightingModel.h"
class BeginGPURangeTimer {
public:
using JobModel = render::Job::ModelO<BeginGPURangeTimer, gpu::RangeTimerPointer>;
@ -62,7 +61,7 @@ protected:
class DrawLayered3D {
public:
using Inputs = render::VaryingSet3<render::ItemBounds, LightingModelPointer, glm::vec2>;
using Inputs = render::VaryingSet4<render::ItemBounds, LightingModelPointer, HazeStage::FramePointer, glm::vec2>;
using Config = DrawLayered3DConfig;
using JobModel = render::Job::ModelI<DrawLayered3D, Inputs, Config>;

View file

@ -207,7 +207,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<RenderDeferred>("RenderDeferred", deferredLightingInputs);
// Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job
const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying();
const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying();
task.addJob<DrawBackgroundStage>("DrawBackgroundDeferred", backgroundInputs);
const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeFrame, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingModel, lightFrame));
@ -225,8 +225,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
task.addJob<EndGPURangeTimer>("HighlightRangeTimer", outlineRangeTimer);
// Layered Over (in front)
const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, jitter).asVarying();
const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, jitter).asVarying();
const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, jitter).asVarying();
const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, jitter).asVarying();
task.addJob<DrawLayered3D>("DrawInFrontOpaque", inFrontOpaquesInputs, true);
task.addJob<DrawLayered3D>("DrawInFrontTransparent", inFrontTransparentsInputs, false);
@ -254,7 +254,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren
const auto primaryFramebuffer = task.addJob<render::UpsampleToBlitFramebuffer>("PrimaryBufferUpscale", toneMappedBuffer);
// HUD Layer
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying();
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying();
task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs);
}
@ -506,7 +506,7 @@ void RenderTransparentDeferred::run(const RenderContextPointer& renderContext, c
if (hazeStage && hazeFrame->_hazes.size() > 0) {
const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front());
if (hazePointer) {
batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer());
}
}

View file

@ -90,6 +90,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
const auto currentStageFrames = lightingStageInputs.get0();
const auto lightFrame = currentStageFrames[0];
const auto backgroundFrame = currentStageFrames[1];
const auto hazeFrame = currentStageFrames[2];
const auto& zones = lightingStageInputs[1];
@ -111,21 +112,21 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
task.addJob<PrepareStencil>("PrepareStencil", scaledPrimaryFramebuffer);
// Draw opaques forward
const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying();
const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel, hazeFrame).asVarying();
task.addJob<DrawForward>("DrawOpaques", opaqueInputs, shapePlumber, true);
// Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job
const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying();
const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying();
task.addJob<DrawBackgroundStage>("DrawBackgroundForward", backgroundInputs);
// Draw transparent objects forward
const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel).asVarying();
const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel, hazeFrame).asVarying();
task.addJob<DrawForward>("DrawTransparents", transparentInputs, shapePlumber, false);
// Layered
const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f));
const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, nullJitter).asVarying();
const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, nullJitter).asVarying();
const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, nullJitter).asVarying();
const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, nullJitter).asVarying();
task.addJob<DrawLayered3D>("DrawInFrontOpaque", inFrontOpaquesInputs, true);
task.addJob<DrawLayered3D>("DrawInFrontTransparent", inFrontTransparentsInputs, false);
@ -167,7 +168,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend
const auto primaryFramebuffer = task.addJob<render::UpsampleToBlitFramebuffer>("PrimaryBufferUpscale", toneMappedBuffer);
// HUD Layer
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying();
const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying();
task.addJob<RenderHUDLayerTask>("RenderHUDLayer", renderHUDLayerInputs);
}
@ -258,11 +259,17 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i
const auto& inItems = inputs.get0();
const auto& lightingModel = inputs.get1();
const auto& hazeFrame = inputs.get2();
graphics::HazePointer haze;
const auto& hazeStage = renderContext->args->_scene->getStage<HazeStage>();
if (hazeStage && hazeFrame->_hazes.size() > 0) {
haze = hazeStage->getHaze(hazeFrame->_hazes.front());
}
gpu::doInBatch("DrawForward::run", args->_context, [&](gpu::Batch& batch) {
args->_batch = &batch;
// Setup projection
glm::mat4 projMat;
Transform viewMat;
@ -276,6 +283,10 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i
batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer());
batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT());
if (haze) {
batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer());
}
// From the lighting model define a global shapeKey ORED with individiual keys
ShapeKey::Builder keyBuilder;
if (lightingModel->isWireframeEnabled()) {

View file

@ -96,7 +96,7 @@ private:
class DrawForward{
public:
using Inputs = render::VaryingSet2<render::ItemBounds, LightingModelPointer>;
using Inputs = render::VaryingSet3<render::ItemBounds, LightingModelPointer, HazeStage::FramePointer>;
using JobModel = render::Job::ModelI<DrawForward, Inputs>;
DrawForward(const render::ShapePlumberPointer& shapePlumber, bool opaquePass) : _shapePlumber(shapePlumber), _opaquePass(opaquePass) {}

View file

@ -47,14 +47,15 @@ void RenderHUDLayerTask::build(JobModel& task, const render::Varying& input, ren
const auto& lightingModel = inputs[1];
const auto& hudOpaque = inputs[2];
const auto& hudTransparent = inputs[3];
const auto& hazeFrame = inputs[4];
// Composite the HUD and HUD overlays
task.addJob<CompositeHUD>("HUD", primaryFramebuffer);
// And HUD Layer objects
const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f));
const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying();
const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying();
const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, hazeFrame, nullJitter).asVarying();
const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, hazeFrame, nullJitter).asVarying();
task.addJob<DrawLayered3D>("DrawHUDOpaque", hudOpaquesInputs, true);
task.addJob<DrawLayered3D>("DrawHUDTransparent", hudTransparentsInputs, false);
}

View file

@ -10,7 +10,7 @@
#define hifi_RenderHUDLayerTask_h
#include "LightingModel.h"
#include "HazeStage.h"
class CompositeHUD {
public:
@ -25,7 +25,7 @@ public:
class RenderHUDLayerTask {
public:
// Framebuffer where to draw, lighting model, opaque items, transparent items
using Input = render::VaryingSet4<gpu::FramebufferPointer, LightingModelPointer, render::ItemBounds, render::ItemBounds>;
using Input = render::VaryingSet5<gpu::FramebufferPointer, LightingModelPointer, render::ItemBounds, render::ItemBounds, HazeStage::FramePointer>;
using JobModel = render::Task::ModelI<RenderHUDLayerTask, Input>;
void build(JobModel& task, const render::Varying& input, render::Varying& output);

View file

@ -54,158 +54,125 @@ void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePip
using namespace shader::render_utils::program;
using Key = render::ShapeKey;
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4);
// TODO: Refactor this to use a filter
// Opaques
addPipeline(
Key::Builder().withMaterial(),
model, nullptr, nullptr);
addPipeline(
Key::Builder(),
simple_textured, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withUnlit(),
model_unlit, nullptr, nullptr);
addPipeline(
Key::Builder().withUnlit(),
simple_textured_unlit, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTangents(),
model_normal_map, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withFade(),
model_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withFade(),
simple_textured_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withUnlit().withFade(),
model_unlit_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withUnlit().withFade(),
simple_textured_unlit_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTangents().withFade(),
model_normal_map_fade, batchSetter, itemSetter);
// TOOD: build this list algorithmically so we don't have to maintain it
std::vector<std::pair<render::ShapeKey::Builder, uint32_t>> pipelines = {
// Simple
{ Key::Builder(), simple },
{ Key::Builder().withTranslucent(), simple_translucent },
{ Key::Builder().withUnlit(), simple_unlit },
{ Key::Builder().withTranslucent().withUnlit(), simple_translucent_unlit },
// Simple Fade
{ Key::Builder().withFade(), simple_fade },
{ Key::Builder().withTranslucent().withFade(), simple_translucent_fade },
{ Key::Builder().withUnlit().withFade(), simple_unlit_fade },
{ Key::Builder().withTranslucent().withUnlit().withFade(), simple_translucent_unlit_fade },
// Translucents
addPipeline(
Key::Builder().withMaterial().withTranslucent(),
model_translucent, nullptr, nullptr);
addPipeline(
Key::Builder().withTranslucent(),
simple_transparent_textured, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withUnlit(),
model_translucent_unlit, nullptr, nullptr);
addPipeline(
Key::Builder().withTranslucent().withUnlit(),
simple_transparent_textured_unlit, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents(),
model_translucent_normal_map, nullptr, nullptr);
addPipeline(
// FIXME: Ignore lightmap for translucents meshpart
Key::Builder().withMaterial().withTranslucent().withLightMap(),
model_translucent, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withTranslucent().withFade(),
model_translucent_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withTranslucent().withFade(),
simple_transparent_textured_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withUnlit().withFade(),
model_translucent_unlit_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withTranslucent().withUnlit().withFade(),
simple_transparent_textured_unlit_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withTranslucent().withTangents().withFade(),
model_translucent_normal_map_fade, batchSetter, itemSetter);
addPipeline(
// FIXME: Ignore lightmap for translucents meshpart
Key::Builder().withMaterial().withTranslucent().withLightMap().withFade(),
model_translucent_fade, batchSetter, itemSetter);
// Lightmapped
addPipeline(
Key::Builder().withMaterial().withLightMap(),
model_lightmap, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withLightMap().withTangents(),
model_lightmap_normal_map, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withLightMap().withFade(),
model_lightmap_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withLightMap().withTangents().withFade(),
model_lightmap_normal_map_fade, batchSetter, itemSetter);
// Unskinned
{ Key::Builder().withMaterial(), model },
{ Key::Builder().withMaterial().withTangents(), model_normalmap },
{ Key::Builder().withMaterial().withTranslucent(), model_translucent },
{ Key::Builder().withMaterial().withTangents().withTranslucent(), model_normalmap_translucent },
// Unskinned Unlit
{ Key::Builder().withMaterial().withUnlit(), model_unlit },
{ Key::Builder().withMaterial().withTangents().withUnlit(), model_normalmap_unlit },
{ Key::Builder().withMaterial().withTranslucent().withUnlit(), model_translucent_unlit },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit(), model_normalmap_translucent_unlit },
// Unskinned Lightmapped
{ Key::Builder().withMaterial().withLightMap(), model_lightmap },
{ Key::Builder().withMaterial().withTangents().withLightMap(), model_normalmap_lightmap },
{ Key::Builder().withMaterial().withTranslucent().withLightMap(), model_translucent_lightmap },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap(), model_normalmap_translucent_lightmap },
// Unskinned Fade
{ Key::Builder().withMaterial().withFade(), model_fade },
{ Key::Builder().withMaterial().withTangents().withFade(), model_normalmap_fade },
{ Key::Builder().withMaterial().withTranslucent().withFade(), model_translucent_fade },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withFade(), model_normalmap_translucent_fade },
// Unskinned Unlit Fade
{ Key::Builder().withMaterial().withUnlit().withFade(), model_unlit_fade },
{ Key::Builder().withMaterial().withTangents().withUnlit().withFade(), model_normalmap_unlit_fade },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withFade(), model_translucent_unlit_fade },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade(), model_normalmap_translucent_unlit_fade },
// Unskinned Lightmapped Fade
{ Key::Builder().withMaterial().withLightMap().withFade(), model_lightmap_fade },
{ Key::Builder().withMaterial().withTangents().withLightMap().withFade(), model_normalmap_lightmap_fade },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withFade(), model_translucent_lightmap_fade },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade(), model_normalmap_translucent_lightmap_fade },
// matrix palette skinned
addPipeline(
Key::Builder().withMaterial().withDeformed(),
deformed_model, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withDeformed().withTangents(),
deformed_model_normal_map, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withDeformed().withFade(),
deformed_model_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withDeformed().withTangents().withFade(),
deformed_model_normal_map_fade, batchSetter, itemSetter);
// matrix palette skinned and translucent
addPipeline(
Key::Builder().withMaterial().withDeformed().withTranslucent(),
deformed_model_translucent, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents(),
deformed_model_normal_map_translucent, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withDeformed().withTranslucent().withFade(),
deformed_model_translucent_fade, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents().withFade(),
deformed_model_normal_map_translucent_fade, batchSetter, itemSetter);
// Matrix palette skinned
{ Key::Builder().withMaterial().withDeformed(), model_deformed },
{ Key::Builder().withMaterial().withTangents().withDeformed(), model_normalmap_deformed },
{ Key::Builder().withMaterial().withTranslucent().withDeformed(), model_translucent_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed(), model_normalmap_translucent_deformed },
// Matrix palette skinned Unlit
{ Key::Builder().withMaterial().withUnlit().withDeformed(), model_unlit_deformed },
{ Key::Builder().withMaterial().withTangents().withUnlit().withDeformed(), model_normalmap_unlit_deformed },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed(), model_translucent_unlit_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed(), model_normalmap_translucent_unlit_deformed },
// Matrix palette skinned Lightmapped
{ Key::Builder().withMaterial().withLightMap().withDeformed(), model_lightmap_deformed },
{ Key::Builder().withMaterial().withTangents().withLightMap().withDeformed(), model_normalmap_lightmap_deformed },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed(), model_translucent_lightmap_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed(), model_normalmap_translucent_lightmap_deformed },
// Matrix palette skinned Fade
{ Key::Builder().withMaterial().withFade().withDeformed(), model_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withFade().withDeformed(), model_normalmap_fade_deformed },
{ Key::Builder().withMaterial().withTranslucent().withFade().withDeformed(), model_translucent_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withFade().withDeformed(), model_normalmap_translucent_fade_deformed },
// Matrix palette skinned Unlit Fade
{ Key::Builder().withMaterial().withUnlit().withFade().withDeformed(), model_unlit_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withUnlit().withFade().withDeformed(), model_normalmap_unlit_fade_deformed },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withFade().withDeformed(), model_translucent_unlit_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade().withDeformed(), model_normalmap_translucent_unlit_fade_deformed },
// Matrix palette skinned Lightmapped Fade
{ Key::Builder().withMaterial().withLightMap().withFade().withDeformed(), model_lightmap_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withLightMap().withFade().withDeformed(), model_normalmap_lightmap_fade_deformed },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withFade().withDeformed(), model_translucent_lightmap_fade_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade().withDeformed(), model_normalmap_translucent_lightmap_fade_deformed },
// dual quaternion skinned
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(),
deformed_model_dq, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTangents(),
deformed_model_normal_map_dq, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withFade(),
deformed_model_fade_dq, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTangents().withFade(),
deformed_model_normal_map_fade_dq, batchSetter, itemSetter);
// dual quaternion skinned and translucent
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent(),
deformed_model_translucent_dq, nullptr, nullptr);
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withTangents(),
deformed_model_normal_map_translucent_dq, nullptr, nullptr);
// Same thing but with Fade on
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withFade(),
deformed_model_translucent_fade_dq, batchSetter, itemSetter);
addPipeline(
Key::Builder().withMaterial().withDeformed().withDualQuatSkinned().withTranslucent().withTangents().withFade(),
deformed_model_normal_map_translucent_fade_dq, batchSetter, itemSetter);
// Dual quaternion skinned
{ Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), model_deformeddq },
{ Key::Builder().withMaterial().withTangents().withDeformed().withDualQuatSkinned(), model_normalmap_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withDeformed().withDualQuatSkinned(), model_translucent_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_deformeddq },
// Dual quaternion skinned Unlit
{ Key::Builder().withMaterial().withUnlit().withDeformed().withDualQuatSkinned(), model_unlit_deformeddq },
{ Key::Builder().withMaterial().withTangents().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_translucent_unlit_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_deformeddq },
// Dual quaternion skinned Lightmapped
{ Key::Builder().withMaterial().withLightMap().withDeformed().withDualQuatSkinned(), model_lightmap_deformeddq },
{ Key::Builder().withMaterial().withTangents().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_deformeddq },
// Dual quaternion skinned Fade
{ Key::Builder().withMaterial().withFade().withDeformed().withDualQuatSkinned(), model_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_fade_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withFade().withDeformed().withDualQuatSkinned(), model_translucent_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_fade_deformeddq },
// Dual quaternion skinned Unlit Fade
{ Key::Builder().withMaterial().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_unlit_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_fade_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_translucent_unlit_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_fade_deformeddq },
// Dual quaternion skinned Lightmapped Fade
{ Key::Builder().withMaterial().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_lightmap_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_fade_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_fade_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withFade().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_fade_deformeddq },
};
for (auto& pipeline : pipelines) {
if (pipeline.first.build().isFaded()) {
addPipeline(pipeline.first, pipeline.second, batchSetter, itemSetter);
} else {
addPipeline(pipeline.first, pipeline.second, nullptr, nullptr);
}
}
}
void initForwardPipelines(ShapePlumber& plumber) {
using namespace shader::render_utils;
using namespace shader::render_utils::program;
using Key = render::ShapeKey;
auto addPipelineBind = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4);
@ -218,38 +185,66 @@ void initForwardPipelines(ShapePlumber& plumber) {
// Forward pipelines need the lightBatchSetter for opaques and transparents
forceLightBatchSetter = true;
// Simple Opaques
addPipeline(Key::Builder(), program::forward_simple_textured);
addPipeline(Key::Builder().withUnlit(), program::forward_simple_textured_unlit);
// TOOD: build this list algorithmically so we don't have to maintain it
std::vector<std::pair<render::ShapeKey::Builder, uint32_t>> pipelines = {
// Simple
{ Key::Builder(), simple_forward },
{ Key::Builder().withTranslucent(), simple_translucent_forward },
{ Key::Builder().withUnlit(), simple_unlit_forward },
{ Key::Builder().withTranslucent().withUnlit(), simple_translucent_unlit_forward },
// Simple Translucents
addPipeline(Key::Builder().withTranslucent(), program::forward_simple_textured_transparent);
addPipeline(Key::Builder().withTranslucent().withUnlit(), program::simple_transparent_textured_unlit);
// Unskinned
{ Key::Builder().withMaterial(), model_forward },
{ Key::Builder().withMaterial().withTangents(), model_normalmap_forward },
{ Key::Builder().withMaterial().withTranslucent(), model_translucent_forward },
{ Key::Builder().withMaterial().withTangents().withTranslucent(), model_normalmap_translucent_forward },
// Unskinned Unlit
{ Key::Builder().withMaterial().withUnlit(), model_unlit_forward },
{ Key::Builder().withMaterial().withTangents().withUnlit(), model_normalmap_unlit_forward },
{ Key::Builder().withMaterial().withTranslucent().withUnlit(), model_translucent_unlit_forward },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit(), model_normalmap_translucent_unlit_forward },
// Unskinned Lightmapped
{ Key::Builder().withMaterial().withLightMap(), model_lightmap_forward },
{ Key::Builder().withMaterial().withTangents().withLightMap(), model_normalmap_lightmap_forward },
{ Key::Builder().withMaterial().withTranslucent().withLightMap(), model_translucent_lightmap_forward },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap(), model_normalmap_translucent_lightmap_forward },
// Opaques
addPipeline(Key::Builder().withMaterial(), program::forward_model);
addPipeline(Key::Builder().withMaterial().withLightMap(), program::forward_model_lightmap);
addPipeline(Key::Builder().withMaterial().withUnlit(), program::forward_model_unlit);
addPipeline(Key::Builder().withMaterial().withTangents(), program::forward_model_normal_map);
addPipeline(Key::Builder().withMaterial().withTangents().withLightMap(), program::forward_model_normal_map_lightmap);
// Matrix palette skinned
{ Key::Builder().withMaterial().withDeformed(), model_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withDeformed(), model_normalmap_forward_deformed },
{ Key::Builder().withMaterial().withTranslucent().withDeformed(), model_translucent_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed(), model_normalmap_translucent_forward_deformed },
// Matrix palette skinned Unlit
{ Key::Builder().withMaterial().withUnlit().withDeformed(), model_unlit_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withUnlit().withDeformed(), model_normalmap_unlit_forward_deformed },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed(), model_translucent_unlit_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed(), model_normalmap_translucent_unlit_forward_deformed },
// Matrix palette skinned Lightmapped
{ Key::Builder().withMaterial().withLightMap().withDeformed(), model_lightmap_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withLightMap().withDeformed(), model_normalmap_lightmap_forward_deformed },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed(), model_translucent_lightmap_forward_deformed },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed(), model_normalmap_translucent_lightmap_forward_deformed },
// Deformed Opaques
addPipeline(Key::Builder().withMaterial().withDeformed(), program::forward_deformed_model);
addPipeline(Key::Builder().withMaterial().withDeformed().withTangents(), program::forward_deformed_model_normal_map);
addPipeline(Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), program::forward_deformed_model_dq);
addPipeline(Key::Builder().withMaterial().withDeformed().withTangents().withDualQuatSkinned(), program::forward_deformed_model_normal_map_dq);
// Dual quaternion skinned
{ Key::Builder().withMaterial().withDeformed().withDualQuatSkinned(), model_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withDeformed().withDualQuatSkinned(), model_normalmap_forward_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withDeformed().withDualQuatSkinned(), model_translucent_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_forward_deformeddq },
// Dual quaternion skinned Unlit
{ Key::Builder().withMaterial().withUnlit().withDeformed().withDualQuatSkinned(), model_unlit_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_unlit_forward_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_translucent_unlit_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withUnlit().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_unlit_forward_deformeddq },
// Dual quaternion skinned Lightmapped
{ Key::Builder().withMaterial().withLightMap().withDeformed().withDualQuatSkinned(), model_lightmap_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_lightmap_forward_deformeddq },
{ Key::Builder().withMaterial().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_translucent_lightmap_forward_deformeddq },
{ Key::Builder().withMaterial().withTangents().withTranslucent().withLightMap().withDeformed().withDualQuatSkinned(), model_normalmap_translucent_lightmap_forward_deformeddq },
};
// Translucents
addPipeline(Key::Builder().withMaterial().withTranslucent(), program::forward_model_translucent);
addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), program::forward_model_normal_map_translucent);
// Deformed Translucents
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent(), program::forward_deformed_translucent);
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents(), program::forward_deformed_translucent_normal_map);
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withDualQuatSkinned(), program::forward_deformed_translucent_dq);
addPipeline(Key::Builder().withMaterial().withDeformed().withTranslucent().withTangents().withDualQuatSkinned(), program::forward_deformed_translucent_normal_map_dq);
// FIXME: incorrent pipelines for normal mapped + translucent models
for (auto& pipeline : pipelines) {
addPipeline(pipeline.first, pipeline.second);
}
forceLightBatchSetter = false;
}
@ -300,8 +295,7 @@ void addPlumberPipeline(ShapePlumber& plumber,
baseBatchSetter(pipeline, batch, args);
extraBatchSetter(pipeline, batch, args);
};
}
else {
} else {
finalBatchSetter = baseBatchSetter;
}
plumber.addPipeline(builder.build(), program, state, finalBatchSetter, itemSetter);
@ -362,17 +356,17 @@ void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state, con
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withoutFade(),
gpu::Shader::createProgram(deformed_model_shadow), state);
gpu::Shader::createProgram(model_shadow_deformed), state);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withoutDualQuatSkinned().withFade(),
gpu::Shader::createProgram(deformed_model_shadow_fade), state, extraBatchSetter, itemSetter);
gpu::Shader::createProgram(model_shadow_fade_deformed), state, extraBatchSetter, itemSetter);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withoutFade(),
gpu::Shader::createProgram(deformed_model_shadow_dq), state);
gpu::Shader::createProgram(model_shadow_deformeddq), state);
shapePlumber.addPipeline(
ShapeKey::Filter::Builder().withDeformed().withDualQuatSkinned().withFade(),
gpu::Shader::createProgram(deformed_model_shadow_fade_dq), state, extraBatchSetter, itemSetter);
gpu::Shader::createProgram(model_shadow_fade_deformeddq), state, extraBatchSetter, itemSetter);
}
bool RenderPipelines::bindMaterial(graphics::MaterialPointer& material, gpu::Batch& batch, render::Args::RenderMode renderMode, bool enableTextures) {

View file

@ -1,56 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 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 graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include LightingModel.slh@>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
}

View file

@ -1,53 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 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 graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
}

View file

@ -1,56 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 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 graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
vec3 deformedTangent = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$>
<$transformModelToWorldDir(cam, obj, deformedTangent, _tangentWS.xyz)$>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
}

View file

@ -1,57 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 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@>
<@include render-utils/ShaderConstants.h@>
<$declareStandardTransform()$>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(1, 1, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
vec3 deformedNormal = vec3(0.0, 0.0, 0.0);
vec3 deformedTangent = vec3(0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition, inNormal.xyz, deformedNormal, inTangent.xyz, deformedTangent,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, deformedPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, deformedNormal, _normalWS.xyz)$>
<$transformModelToWorldDir(cam, obj, deformedTangent, _tangentWS.xyz)$>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
}

View file

@ -1,52 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2014 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/Transform.slh@>
<$declareStandardTransform()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, deformedPosition, gl_Position)$>
<$transformModelToWorldPos(obj, deformedPosition, _positionWS)$>
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
_texCoord01 = vec4(0.0, 0.0, 0.0, 0.0);
// If we have an opacity mask than we need the first tex coord
if ((matKey & OPACITY_MASK_MAP_BIT) != 0) {
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
}
}

View file

@ -1,51 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2014 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/Transform.slh@>
<$declareStandardTransform()$>
<@include MeshDeformer.slh@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$>
<$declareMeshDeformerActivation(1, 1)$>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
void main(void) {
vec4 deformedPosition = vec4(0.0, 0.0, 0.0, 0.0);
evalMeshDeformer(inPosition, deformedPosition,
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, deformedPosition, gl_Position)$>
<$transformModelToWorldPos(obj, deformedPosition, _positionWS)$>
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
_texCoord01 = vec4(0.0, 0.0, 0.0, 0.0);
// If we have an opacity mask than we need the first tex coord
if ((matKey & OPACITY_MASK_MAP_BIT) != 0) {
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
}
}

View file

@ -11,15 +11,10 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferRead.slh@>
<@include DeferredGlobalLight.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareEvalLightmappedColor()$>
<@include GlobalLight.slh@>
<$declareEvalAmbientSphereGlobalColor(supportScattering)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;

View file

@ -11,15 +11,14 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include Shadow.slh@>
<@include DeferredBufferRead.slh@>
<@include DeferredGlobalLight.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareEvalLightmappedColor()$>
<@include GlobalLight.slh@>
<$declareEvalAmbientSphereGlobalColor(isScattering)$>
<@include Shadow.slh@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw

View file

@ -11,13 +11,11 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferRead.slh@>
<@include DeferredGlobalLight.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareEvalLightmappedColor()$>
<$declareEvalSkyboxGlobalColor(isScattering)$>
<@include GlobalLight.slh@>
<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy

View file

@ -11,14 +11,13 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//!>
<@include Shadow.slh@>
<@include DeferredBufferRead.slh@>
<@include DeferredGlobalLight.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareEvalLightmappedColor()$>
<$declareEvalSkyboxGlobalColor(isScattering)$>
<@include GlobalLight.slh@>
<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$>
<@include Shadow.slh@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
@ -35,7 +34,6 @@ void main(void) {
vec3 worldLightDirection = getLightDirection(shadowLight);
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
// Light mapped or not ?
if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) {
discard;
} else {

View file

@ -1,40 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 5/9/19
// Copyright 2019 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/ShaderConstants.h@>
<@include gpu/Paint.slh@>
struct Grid {
vec4 period;
vec4 offset;
vec4 edge;
};
LAYOUT(binding=0) uniform gridBuffer {
Grid grid;
};
layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0;
layout(location=GPU_ATTR_COLOR) in vec4 varColor;
layout(location=0) out vec4 _fragColor0;
void main(void) {
float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
float(grid.edge.z == 0.0));
if (alpha < 0.0001) {
discard;
}
_fragColor0 = vec4(varColor.xyz, 1.0);
}

View file

@ -1,41 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 5/9/19
// Copyright 2019 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/ShaderConstants.h@>
<@include gpu/Paint.slh@>
struct Grid {
vec4 period;
vec4 offset;
vec4 edge;
};
LAYOUT(binding=0) uniform gridBuffer {
Grid grid;
};
layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0;
layout(location=GPU_ATTR_COLOR) in vec4 varColor;
layout(location=0) out vec4 _fragColor0;
void main(void) {
float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
float(grid.edge.z == 0.0));
alpha *= varColor.w;
if (alpha < 0.0001) {
discard;
}
_fragColor0 = vec4(varColor.xyz, alpha);
}

View file

@ -1,83 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD 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.rgb;
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)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS);
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusion,
fragPosition,
fragNormal,
albedo,
fresnel,
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
_fragColor0 = color;
}

View file

@ -1,71 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalLightmappedColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<$declareMaterialLightmap()$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragNormal = normalize(_normalWS);
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
1.0,
fragNormal,
albedo,
lightmap),
opacity);
_fragColor0 = color;
}

View file

@ -1,85 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD 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.rgb;
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)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal;
<$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$>
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusion,
fragPosition,
fragNormal,
albedo,
fresnel,
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
_fragColor0 = color;
}

View file

@ -1,74 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalLightmappedColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
<$declareMaterialLightmap()$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal;
<$evalMaterialNormalLOD(fragPosition, normalTex, _normalWS, _tangentWS, fragNormal)$>
TransformCamera cam = getTransformCamera();
vec4 color = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
1.0,
fragNormal,
albedo,
lightmap),
opacity);
_fragColor0 = color;
}

View file

@ -1,81 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include ForwardGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 fragPosition = _positionES.xyz;
vec3 fragNormal = normalize(_normalWS);
TransformCamera cam = getTransformCamera();
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusion,
fragPosition,
fragNormal,
albedo,
fresnel,
metallic,
emissive,
roughness, opacity),
opacity);
}

View file

@ -1,42 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 5/5/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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
Material mat = getMaterial();
BITFIELD 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.rgb;
_fragColor0 = vec4(albedo * isUnlitEnabled(), 1.0);
}

View file

@ -1,18 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 5/9/19
// Copyright 2019 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
//
layout(location=0) in vec4 _color;
layout(location=0) out vec4 _fragColor0;
void main(void) {
_fragColor0 = _color;
}

View file

@ -1,61 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_simple.frag
// fragment shader
//
// Created by Andrzej Kapolka on 9/15/14.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
// the interpolated normal
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
// For retro-compatibility
#define _normal _normalWS
#define _modelNormal _normalMS
#define _position _positionMS
#define _eyePosition _positionES
layout(location=0) out vec4 _fragColor0;
void main(void) {
vec3 normal = normalize(_normalWS.xyz);
vec3 diffuse = _color.rgb;
vec3 specular = DEFAULT_SPECULAR;
float shininess = DEFAULT_SHININESS;
float emissiveAmount = 0.0;
TransformCamera cam = getTransformCamera();
vec3 fragPosition = _positionES.xyz;
_fragColor0 = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normal * (2.0 * float(gl_FrontFacing) - 1.0),
diffuse,
DEFAULT_FRESNEL,
length(specular),
max(0.0, 1.0 - shininess / 128.0)),
1.0);
}

View file

@ -1,58 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_simple_textured.frag
// fragment shader
//
// Created by Clément Brisset on 5/29/15.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include ForwardGlobalLight.slh@>
<$declareEvalSkyboxGlobalColor()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include render-utils/ShaderConstants.h@>
LAYOUT(binding=0) uniform sampler2D originalTexture;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=0) out vec4 _fragColor0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0);
texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0));
vec3 albedo = _color.xyz * texel.xyz;
float metallic = DEFAULT_METALLIC;
vec3 fresnel = getFresnelF0(metallic, albedo);
TransformCamera cam = getTransformCamera();
vec3 fragPosition = _positionES.xyz;
_fragColor0 = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
albedo,
fresnel,
metallic,
DEFAULT_ROUGHNESS),
1.0);
}

View file

@ -1,60 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_simple_textured_transparent.frag
// fragment shader
//
// Created by Clément Brisset on 5/29/15.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include ForwardGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<@include render-utils/ShaderConstants.h@>
LAYOUT(binding=0) uniform sampler2D originalTexture;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=0) out vec4 _fragColor0;
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0);
texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0));
vec3 albedo = _color.xyz * texel.xyz;
float alpha = _color.a * texel.a;
float metallic = DEFAULT_METALLIC;
vec3 fresnel = getFresnelF0(metallic, albedo);
TransformCamera cam = getTransformCamera();
vec3 fragPosition = _positionES.xyz;
_fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragPosition,
normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0),
albedo,
fresnel,
metallic,
DEFAULT_EMISSIVE,
DEFAULT_ROUGHNESS, alpha),
alpha);
}

View file

@ -1,35 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// forward_simple_textured_unlit.frag
// fragment shader
//
// Created by Clément Brisset on 5/29/15.
// Copyright 2014 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 LightingModel.slh@>
<@include gpu/Color.slh@>
<@include render-utils/ShaderConstants.h@>
layout(location=0) out vec4 _fragColor0;
// the albedo texture
LAYOUT(binding=0) uniform sampler2D originalTexture;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
void main(void) {
vec4 texel = texture(originalTexture, _texCoord0.st);
float colorAlpha = _color.a * texel.a;
_fragColor0 = vec4(_color.rgb * texel.rgb * isUnlitEnabled(), colorAlpha);
}

View file

@ -1,34 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Bradley Austin Davis on 2016/07/05
// Copyright 2013-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 render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) in float distanceFromCenter;
layout(location=0) out vec4 _fragColor;
void main(void) {
// The incoming value actually ranges from -1 to 1, so modify it
// so that it goes from 0 -> 1 -> 0 with the solid alpha being at
// the center of the line
float alpha = 1.0 - abs(distanceFromCenter);
// Convert from a linear alpha curve to a sharp peaked one
alpha = _color.a * pow(alpha, 10.0);
// Drop everything where the curve falls off to nearly nothing
if (alpha <= 0.05) {
discard;
}
// Emit the color
_fragColor = vec4(_color.rgb, alpha);
}

View file

@ -1,61 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Bradley Austin Davis on 2016/07/05
// Copyright 2013-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 gpu/Transform.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareStandardTransform()$>
struct LineData {
vec4 p1;
vec4 p2;
vec4 color;
float width;
};
LAYOUT_STD140(binding=0) uniform LineDataBuffer {
LineData _lineData;
};
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
// the distance from the center in 'quad space'
layout(location=0) out float distanceFromCenter;
void main(void) {
_color = _lineData.color;
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
vec4 p1eye, p2eye;
<$transformModelToEyePos(cam, obj, _lineData.p1, p1eye)$>
<$transformModelToEyePos(cam, obj, _lineData.p2, p2eye)$>
p1eye /= p1eye.w;
p2eye /= p2eye.w;
// Find the line direction
vec3 v1 = normalize(p1eye.xyz - p2eye.xyz);
// Find the vector from the eye to one of the points
vec3 v2 = normalize(p1eye.xyz);
// The orthogonal vector is the cross product of these two
vec3 orthogonal = cross(v1, v2) * _lineData.width;
// Deteremine which end to emit based on the vertex id (even / odd)
vec4 eye = mix(p2eye, p1eye, float(gl_VertexID % 2 == 0));
// Add or subtract the orthogonal vector based on a different vertex ID
// calculation
distanceFromCenter = 1.0 - 2.0 * float(gl_VertexID < 2);
eye.xyz += distanceFromCenter * orthogonal;
// Finally, put the eyespace vertex into clip space
<$transformEyeToClipPos(cam, eye, gl_Position)$>
}

View file

@ -1,5 +1,6 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Zach Pomerantz on 2/16/2016.
@ -9,11 +10,15 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@include gpu/ShaderConstants.h@>
<@include gpu/Paint.slh@>
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
<@else@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
struct Grid {
vec4 period;
vec4 offset;
@ -28,13 +33,21 @@ layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0;
layout(location=GPU_ATTR_COLOR) in vec4 varColor;
void main(void) {
float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
float gridLine = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
float(grid.edge.z == 0.0));
if (alpha < 0.0001) {
if (gridLine <= 0.0) {
discard;
}
packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, varColor.xyz);
<@if not HIFI_USE_FORWARD@>
vec3 NORMAL = vec3(1.0, 0.0, 0.0);
<@if not HIFI_USE_TRANSLUCENT@>
packDeferredFragmentUnlit(NORMAL, 1.0, varColor.rgb);
<@else@>
packDeferredFragmentTranslucent(NORMAL, varColor.a, varColor.rgb, DEFAULT_ROUGHNESS);
<@endif@>
<@else@>
_fragColor0 = varColor;
<@endif@>
}

View file

@ -1,41 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 12/22/18
// Copyright 2018 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 gpu/ShaderConstants.h@>
<@include gpu/Paint.slh@>
struct Grid {
vec4 period;
vec4 offset;
vec4 edge;
};
LAYOUT(binding=0) uniform gridBuffer {
Grid grid;
};
layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0;
layout(location=GPU_ATTR_COLOR) in vec4 varColor;
void main(void) {
float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge),
paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy),
float(grid.edge.z == 0.0));
alpha *= varColor.w;
if (alpha < 0.0001) {
discard;
}
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), alpha, varColor.xyz, DEFAULT_ROUGHNESS);
}

View file

@ -29,7 +29,7 @@ LAYOUT_STD140(binding=0) uniform hudBuffer {
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
void main() {
_texCoord01.xy = inTexCoord0.st;
_texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0);
// standard transform
TransformCamera cam = getTransformCamera();

View file

@ -1,6 +1,6 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Andrzej Kapolka on 5/6/14.
@ -10,55 +10,320 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@if not HIFI_USE_SHADOW@>
<@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@>
<@include DefaultMaterials.slh@>
<@include GlobalLight.slh@>
<@if HIFI_USE_LIGHTMAP@>
<$declareEvalLightmappedColor()$>
<@elif HIFI_USE_TRANSLUCENT@>
<@if not HIFI_USE_FORWARD@>
<@include LightLocal.slh@>
<@endif@>
<$declareEvalGlobalLightingAlphaBlended()$>
<@else@>
<$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$>
<@endif@>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
layout(location=0) out vec4 _fragColor0;
<@else@>
<@include DeferredBufferWrite.slh@>
<@endif@>
<@else@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
<@if HIFI_USE_UNLIT@>
<@include LightingModel.slh@>
<@endif@>
<@if HIFI_USE_SHADOW or HIFI_USE_UNLIT@>
<$declareMaterialTextures(ALBEDO)$>
<@else@>
<@if not HIFI_USE_LIGHTMAP@>
<@if HIFI_USE_NORMALMAP and HIFI_USE_TRANSLUCENT@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL , METALLIC, EMISSIVE, OCCLUSION)$>
<@elif HIFI_USE_NORMALMAP@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL , METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@elif HIFI_USE_TRANSLUCENT@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL , METALLIC, EMISSIVE, OCCLUSION)$>
<@else@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL , METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@endif@>
<@else@>
<@if HIFI_USE_NORMALMAP@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
<@else@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<@endif@>
<$declareMaterialLightmap()$>
<@endif@>
<@endif@>
<@if HIFI_USE_FADE@>
<@include Fade.slh@>
<$declareFadeFragment()$>
<@endif@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
<@if not HIFI_USE_SHADOW@>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
<@if HIFI_USE_NORMALMAP@>
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
<@endif@>
<@endif@>
void main(void) {
<@if HIFI_USE_FADE@>
<@if not HIFI_USE_SHADOW@>
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
<@else@>
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFadeClip(fadeParams, _positionWS.xyz);
<@endif@>
<@endif@>
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
<@if HIFI_USE_SHADOW or HIFI_USE_UNLIT@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
<@if HIFI_USE_TRANSLUCENT@>
float opacity = getMaterialOpacity(mat) * _color.a;
<@else@>
float opacity = 1.0;
<@endif@>
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<@if HIFI_USE_TRANSLUCENT@>
<$discardInvisible(opacity)$>;
<@else@>
<$discardTransparent(opacity)$>;
<@endif@>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
<@if not HIFI_USE_SHADOW@>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
<@if HIFI_USE_FADE@>
albedo += fadeEmissive;
<@endif@>
<@endif@>
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
<@if HIFI_USE_SHADOW@>
_fragColor0 = vec4(1.0);
<@elif HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@>
_fragColor0 = vec4(albedo * isUnlitEnabled(), opacity);
<@else@>
packDeferredFragmentUnlit(
normalize(_normalWS),
opacity,
albedo * isUnlitEnabled());
<@endif@>
<@else@>
<@if not HIFI_USE_LIGHTMAP@>
<@if HIFI_USE_NORMALMAP and HIFI_USE_TRANSLUCENT@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, _SCRIBE_NULL)$>
<@elif HIFI_USE_NORMALMAP@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
<@elif HIFI_USE_TRANSLUCENT@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, _SCRIBE_NULL)$>
<@else@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$>
<@endif@>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
<@else@>
<@if HIFI_USE_NORMALMAP@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<@else@>
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<@endif@>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
<@endif@>
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
<@if HIFI_USE_TRANSLUCENT@>
float opacity = getMaterialOpacity(mat) * _color.a;
<@else@>
float opacity = 1.0;
<@endif@>
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<@if HIFI_USE_TRANSLUCENT@>
<$discardInvisible(opacity)$>;
<@else@>
<$discardTransparent(opacity)$>;
<@endif@>
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragment(
normalize(_normalWS),
opacity,
albedo,
roughness,
metallic,
emissive,
occlusion,
scattering);
<@if not HIFI_USE_LIGHTMAP@>
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
<@if not HIFI_USE_TRANSLUCENT@>
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
<@endif@>
<@endif@>
<@if HIFI_USE_NORMALMAP@>
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
<@else@>
vec3 fragNormalWS = _normalWS;
<@endif@>
fragNormalWS = normalize(fragNormalWS);
<@if HIFI_USE_FORWARD@>
TransformCamera cam = getTransformCamera();
vec3 fresnel = getFresnelF0(metallic, albedo);
<@if not HIFI_USE_TRANSLUCENT@>
<@if not HIFI_USE_LIGHTMAP@>
vec4 color = vec4(evalSkyboxGlobalColor(
cam._viewInverse,
1.0,
occlusion,
_positionES.xyz,
fragNormalWS,
albedo,
fresnel,
metallic,
roughness),
opacity);
color.rgb += emissive * isEmissiveEnabled();
_fragColor0 = color;
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@else@>
<@if not HIFI_USE_LIGHTMAP@>
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
cam._viewInverse,
1.0,
occlusion,
_positionES.xyz,
fragNormalWS,
albedo,
fresnel,
metallic,
emissive,
roughness, opacity),
opacity);
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@endif@>
<@else@>
<@if not HIFI_USE_TRANSLUCENT@>
<@if not HIFI_USE_LIGHTMAP@>
packDeferredFragment(
fragNormalWS,
opacity,
albedo,
roughness,
metallic,
emissive
<@if HIFI_USE_FADE@>
+ fadeEmissive
<@endif@>
,
occlusion,
scattering);
<@else@>
packDeferredFragmentLightmap(
fragNormalWS,
evalOpaqueFinalAlpha(getMaterialOpacity(mat), opacity),
albedo,
roughness,
metallic,
lightmap
<@if HIFI_USE_FADE@>
+ fadeEmissive
<@endif@>
);
<@endif@>
<@else@>
TransformCamera cam = getTransformCamera();
<@if not HIFI_USE_LIGHTMAP@>
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 fragPositionWS = _positionWS.xyz;
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
metallic, fresnel, albedo, 0.0,
vec4(0), vec4(0), opacity);
}
_fragColor0 = vec4(evalGlobalLightingAlphaBlended(
cam._viewInverse,
1.0,
occlusion,
_positionES.xyz,
fragNormalWS,
albedo,
fresnel,
metallic,
emissive
<@if HIFI_USE_FADE@>
+ fadeEmissive
<@endif@>
,
surfaceWS, opacity, localLighting.rgb),
opacity);
<@else@>
_fragColor0 = vec4(evalLightmappedColor(
cam._viewInverse,
1.0,
DEFAULT_OCCLUSION,
fragNormalWS,
albedo,
lightmap),
opacity);
<@endif@>
<@endif@>
<@endif@>
<@endif@>
}

View file

@ -1,10 +1,10 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 High Fidelity, Inc.
// Created by Hifi Engine Team
// Copyright 2019 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
@ -12,32 +12,94 @@
<@include gpu/Inputs.slh@>
<@include gpu/Color.slh@>
<@include gpu/Transform.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareStandardTransform()$>
<$declareMaterialTexMapArrayBuffer()$>
<@include render-utils/ShaderConstants.h@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
<@include graphics/MaterialTextures.slh@>
<$declareMaterialTexMapArrayBuffer()$>
<@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@>
<@include MeshDeformer.slh@>
<@if HIFI_USE_DEFORMED@>
<@if HIFI_USE_SHADOW@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<@elif not HIFI_USE_NORMALMAP@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>
<@else@>
<$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$>
<@endif@>
<@else@>
<@if HIFI_USE_SHADOW@>
<$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$>
<@elif not HIFI_USE_NORMALMAP@>
<$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$>
<@else@>
<$declareMeshDeformer(1, 1, 1, 1, 1)$>
<@endif@>
<@endif@>
<$declareMeshDeformerActivation(1, 1)$>
<@endif@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
<@if not HIFI_USE_SHADOW@>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
<@if HIFI_USE_NORMALMAP@>
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS;
<@endif@>
<@endif@>
void main(void) {
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
vec4 positionMS = inPosition;
vec3 normalMS = inNormal.xyz;
vec3 tangentMS = inTangent.xyz;
<@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@>
evalMeshDeformer(inPosition, positionMS,
<@if not HIFI_USE_SHADOW@>
inNormal.xyz, normalMS,
<@if HIFI_USE_NORMALMAP@>
inTangent.xyz, tangentMS,
<@endif@>
<@endif@>
meshDeformer_doSkinning(_drawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,
meshDeformer_doBlendshape(_drawCallInfo.y), gl_VertexID);
<@endif@>
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
<@if not HIFI_USE_SHADOW@>
<$transformModelToWorldAndEyeAndClipPos(cam, obj, positionMS, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, normalMS, _normalWS)$>
<@else@>
<$transformModelToClipPos(cam, obj, positionMS, gl_Position)$>
<$transformModelToWorldPos(obj, positionMS, _positionWS)$>
<@endif@>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
<@if HIFI_USE_NORMALMAP@>
<$transformModelToWorldDir(cam, obj, tangentMS, _tangentWS)$>
<@endif@>
<@if HIFI_USE_SHADOW@>
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
// If we have an opacity mask than we need the first tex coord
if ((matKey & OPACITY_MASK_MAP_BIT) != 0) {
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
_texCoord01.zw = vec2(0.0);
} else {
_texCoord01 = vec4(0.0);
}
<@else@>
_color = color_sRGBAToLinear(inColor);
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
<@endif@>
}

View file

@ -1,73 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, scatteringTex)$>
<$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.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
packDeferredFragment(
normalize(_normalWS),
opacity,
albedo,
roughness,
metallic,
emissive + fadeEmissive,
occlusion,
scattering);
}

View file

@ -1,50 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Samuel Gateau on 11/19/14.
// Copyright 2014 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<$declareMaterialLightmap()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragmentLightmap(
normalize(_normalWS),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap);
}

View file

@ -1,59 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC)$>
<$declareMaterialLightmap()$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
packDeferredFragmentLightmap(
normalize(_normalWS),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap + fadeEmissive);
}

View file

@ -1,55 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Samuel Gateau on 11/19/14.
// Copyright 2014 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
<$declareMaterialLightmap()$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragNormal;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
packDeferredFragmentLightmap(
normalize(fragNormal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap);
}

View file

@ -1,64 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC)$>
<$declareMaterialLightmap()$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$>
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fragNormal;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormal)$>
packDeferredFragmentLightmap(
normalize(fragNormal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedoTex.a),
albedo,
roughness,
metallic,
lightmap + fadeEmissive);
}

View file

@ -1,69 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Andrzej Kapolka on 5/6/14.
// Copyright 2014 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
<$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.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
packDeferredFragment(
normalize(fragNormalWS),
opacity,
albedo,
roughness,
metallic,
emissive,
occlusion,
scattering);
}

View file

@ -1,45 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2013 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@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareStandardTransform()$>
<$declareMaterialTexMapArrayBuffer()$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) out vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color;
void main(void) {
// pass along the color
_color.rgb = color_sRGBToLinear(inColor.rgb);
_color.a = inColor.a;
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$>
<$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$>
<$transformModelToWorldDir(cam, obj, inTangent.xyz, _tangentWS)$>
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01.zw)$>
}

View file

@ -1,78 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION, SCATTERING)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, scatteringTex)$>
<$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.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
float scattering = getMaterialScattering(mat);
<$evalMaterialScattering(scatteringTex, scattering, matKey, scattering)$>;
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
packDeferredFragment(
normalize(fragNormalWS),
opacity,
albedo,
roughness,
metallic,
emissive + fadeEmissive,
occlusion,
scattering);
}

View file

@ -1,34 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Andrzej Kapolka on 3/24/14.
// Copyright 2013 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
// pass-through to set z-buffer
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
}

View file

@ -1,42 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Hifi Engine Team.
// Copyright 2014 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/Transform.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<$declareStandardTransform()$>
<$declareMaterialTexMapArrayBuffer()$>
<@include render-utils/ShaderConstants.h@>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01;
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
TransformObject obj = getTransformObject();
<$transformModelToClipPos(cam, obj, inPosition, gl_Position)$>
<$transformModelToWorldPos(obj, inPosition, _positionWS)$>
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
_texCoord01 = vec4(0.0, 0.0, 0.0, 0.0);
// If we have an opacity mask than we need the first tex coord
if ((matKey & OPACITY_MASK_MAP_BIT) != 0) {
TexMapArray texMapArray = getTexMapArray();
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01.xy)$>
}
}

View file

@ -1,42 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
layout(location=0) out vec4 _fragColor;
void main(void) {
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFadeClip(fadeParams, _positionWS.xyz);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
float opacity = 1.0;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
// pass-through to set z-buffer
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
}

View file

@ -1,96 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 2/15/2016.
// Copyright 2014 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
vec3 fragNormalWS = normalize(_normalWS);
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
metallic, fresnel, albedo, 0.0,
vec4(0), vec4(0), opacity);
}
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusion,
fragPositionES,
fragPositionWS,
albedo,
fresnel,
metallic,
emissive,
surfaceWS, opacity, localLighting.rgb),
opacity);
}

View file

@ -1,104 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, METALLIC, EMISSIVE, OCCLUSION)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardTransparent(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
vec3 fragNormalWS = normalize(_normalWS);
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
metallic, fresnel, albedo, 0.0,
vec4(0), vec4(0), opacity);
}
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusion,
fragPositionES,
fragPositionWS,
albedo,
fresnel,
metallic,
emissive + fadeEmissive,
surfaceWS, opacity, localLighting.rgb),
opacity);
}

View file

@ -1,98 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Olivier Prat on 23/01/2018.
// Copyright 2018 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
metallic, fresnel, albedo, 0.0,
vec4(0), vec4(0), opacity);
}
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusion,
fragPositionES,
fragPositionWS,
albedo,
fresnel,
metallic,
emissive,
surfaceWS, opacity, localLighting.rgb),
opacity);
}

View file

@ -1,106 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Olivier Prat on 23/01/18.
// Copyright 2018 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 DefaultMaterials.slh@>
<@include graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightLocal.slh@>
<@include DeferredGlobalLight.slh@>
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
<@include gpu/Transform.slh@>
<$declareStandardCameraTransform()$>
<$declareMaterialTextures(ALBEDO, ROUGHNESS, NORMAL, METALLIC, EMISSIVE, OCCLUSION)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_TANGENT_WS) in vec3 _tangentWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
int matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
float roughness = getMaterialRoughness(mat);
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
float metallic = getMaterialMetallic(mat);
<$evalMaterialMetallic(metallicTex, metallic, matKey, metallic)$>;
vec3 fresnel = getFresnelF0(metallic, albedo);
vec3 emissive = getMaterialEmissive(mat);
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
float occlusion = DEFAULT_OCCLUSION;
<$evalMaterialOcclusion(occlusionTex, matKey, occlusion)$>;
vec3 fragPositionES = _positionES.xyz;
vec3 fragPositionWS = _positionWS.xyz;
// Lighting is done in world space
vec3 fragNormalWS;
<$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$>
TransformCamera cam = getTransformCamera();
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
SurfaceData surfaceWS = initSurfaceData(roughness, normalize(fragNormalWS), fragToEyeDirWS);
vec4 localLighting = vec4(0.0);
<$fetchClusterInfo(_positionWS)$>;
if (hasLocalLights(numLights, clusterPos, dims)) {
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
metallic, fresnel, albedo, 0.0,
vec4(0), vec4(0), opacity);
}
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
cam._viewInverse,
1.0,
occlusion,
fragPositionES,
fragPositionWS,
albedo,
fresnel,
metallic,
emissive + fadeEmissive,
surfaceWS, opacity, localLighting.rgb),
opacity);
}

View file

@ -1,42 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=0) out vec4 _fragColor;
void main(void) {
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
_fragColor = vec4(albedo * isUnlitEnabled(), opacity);
}

View file

@ -1,52 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
<@include Fade.slh@>
<$declareFadeFragment()$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=0) out vec4 _fragColor;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD matKey = getMaterialKey(mat);
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
float opacity = getMaterialOpacity(mat) * _color.a;
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
<$discardInvisible(opacity)$>;
vec3 albedo = getMaterialAlbedo(mat);
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
albedo *= _color.rgb;
albedo += fadeEmissive;
_fragColor = vec4(albedo * isUnlitEnabled(), opacity);
}

View file

@ -1,45 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gateau on 5/5/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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
Material mat = getMaterial();
BITFIELD 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.rgb;
packDeferredFragmentUnlit(
normalize(_normalWS),
opacity,
albedo * isUnlitEnabled());
}

View file

@ -1,55 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// 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 graphics/Material.slh@>
<@include graphics/MaterialTextures.slh@>
<@include render-utils/ShaderConstants.h@>
<@include DeferredBufferWrite.slh@>
<@include LightingModel.slh@>
<@include Fade.slh@>
<$declareFadeFragment()$>
<$declareMaterialTextures(ALBEDO)$>
layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS;
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
#define _texCoord0 _texCoord01.xy
#define _texCoord1 _texCoord01.zw
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
void main(void) {
vec3 fadeEmissive;
FadeObjectParams fadeParams;
<$fetchFadeObjectParams(fadeParams)$>
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
Material mat = getMaterial();
BITFIELD 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.rgb;
albedo += fadeEmissive;
packDeferredFragmentUnlit(
normalize(_normalWS),
opacity,
albedo * isUnlitEnabled());
}

View file

@ -1,5 +1,6 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 7/18/2018
@ -9,10 +10,22 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include DeferredBufferWrite.slh@>
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
<@else@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
layout(location=0) in vec4 _color;
void main(void) {
packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, _color.rgb);
<@if not HIFI_USE_FORWARD@>
<@if not HIFI_USE_TRANSLUCENT@>
packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, _color.rgb);
<@else@>
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS);
<@endif@>
<@else@>
_fragColor0 = _color;
<@endif@>
}

View file

@ -1,18 +0,0 @@
<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Sam Gondelman on 9/10/2018
// Copyright 2018 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@>
layout(location=0) in vec4 _color;
void main(void) {
packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), _color.a, _color.rgb, DEFAULT_ROUGHNESS);
}

View file

@ -68,7 +68,6 @@
#define RENDER_UTILS_BUFFER_LIGHT_CLUSTER_CONTENT 12
// Haze
#define RENDER_UTILS_BUFFER_HAZE_PARAMS 7
#define RENDER_UTILS_TEXTURE_HAZE_COLOR 0
#define RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH 1
@ -143,7 +142,6 @@ enum Buffer {
DeferredFrameTransform = RENDER_UTILS_BUFFER_DEFERRED_FRAME_TRANSFORM,
LightModel = RENDER_UTILS_BUFFER_LIGHT_MODEL,
AmbientLight = RENDER_UTILS_BUFFER_AMBIENT_LIGHT,
HazeParams = RENDER_UTILS_BUFFER_HAZE_PARAMS,
FadeParameters = RENDER_UTILS_BUFFER_FADE_PARAMS,
FadeObjectParameters = RENDER_UTILS_BUFFER_FADE_OBJECT_PARAMS,
LightClusterFrustumGrid = RENDER_UTILS_BUFFER_LIGHT_CLUSTER_FRUSTUM_GRID,

View file

@ -1,2 +0,0 @@
VERTEX deformed_model
FRAGMENT model

View file

@ -1,2 +0,0 @@
VERTEX deformed_model_dq
FRAGMENT model

Some files were not shown because too many files have changed in this diff Show more