diff --git a/cmake/macros/AutoScribeShader.cmake b/cmake/macros/AutoScribeShader.cmake index c5bb2b4054..9a18005424 100755 --- a/cmake/macros/AutoScribeShader.cmake +++ b/cmake/macros/AutoScribeShader.cmake @@ -66,6 +66,9 @@ macro(AUTOSCRIBE_PLATFORM_SHADER) list(APPEND SHADER_GEN_LINE ${TEMP_PATH}) file(RELATIVE_PATH TEMP_PATH ${CMAKE_SOURCE_DIR} ${AUTOSCRIBE_OUTPUT_FILE}) list(APPEND SHADER_GEN_LINE ${TEMP_PATH}) + if (NOT("${DEFINES}" STREQUAL "")) + list(APPEND SHADER_GEN_LINE "defines:${DEFINES}") + endif() list(APPEND SHADER_GEN_LINE ${AUTOSCRIBE_SHADER_SEEN_LIBS}) string(CONCAT AUTOSCRIBE_SHADERGEN_COMMANDS "${AUTOSCRIBE_SHADERGEN_COMMANDS}" "${SHADER_GEN_LINE}\n") endmacro() @@ -108,6 +111,10 @@ macro(AUTOSCRIBE_SHADER) set(SHADER_TYPE geom) endif() + if (NOT("${DEFINES}" STREQUAL "")) + string(CONCAT SHADER_NAME "${SHADER_NAME}" "_${DEFINES}") + endif() + set(SCRIBE_ARGS -D GLPROFILE ${GLPROFILE} -T ${SHADER_TYPE} ${SCRIBE_INCLUDES} ) # SHADER_SCRIBED -> the output of scribe @@ -135,11 +142,72 @@ macro(AUTOSCRIBE_SHADER) endif() endif() - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${SHADER_NAME} = ${SHADER_COUNT},\n") + string(CONCAT SHADER_LIST "${SHADER_LIST}" "${SHADER_NAME} = ${SHADER_COUNT},\n") string(CONCAT SHADER_SHADERS_ARRAY "${SHADER_SHADERS_ARRAY}" "${SHADER_COUNT},\n") MATH(EXPR SHADER_COUNT "${SHADER_COUNT}+1") endmacro() +function(GENERATE_DEFINES_LIST_HELPER INPUT_LIST RETURN_LIST) + string(LENGTH "${INPUT_LIST}" STR_LENGTH) + set(OPEN_INDEX -1) + set(STR_INDEX 0) + set(NESTED_DEPTH 0) + while ("${STR_INDEX}" LESS "${STR_LENGTH}") + string(SUBSTRING "${INPUT_LIST}" ${STR_INDEX} 1 CURRENT_CHAR) + + if (("${CURRENT_CHAR}" STREQUAL "(") AND (OPEN_INDEX EQUAL -1)) + set(OPEN_INDEX ${STR_INDEX}) + MATH(EXPR STR_INDEX "${STR_INDEX}+1") + continue() + elseif (("${CURRENT_CHAR}" STREQUAL "(") AND NOT(OPEN_INDEX EQUAL -1)) + MATH(EXPR NESTED_DEPTH "${NESTED_DEPTH}+1") + MATH(EXPR STR_INDEX "${STR_INDEX}+1") + continue() + elseif (("${CURRENT_CHAR}" STREQUAL ")") AND NOT(OPEN_INDEX EQUAL -1) AND (NESTED_DEPTH GREATER 0)) + MATH(EXPR NESTED_DEPTH "${NESTED_DEPTH}-1") + MATH(EXPR STR_INDEX "${STR_INDEX}+1") + continue() + elseif (("${CURRENT_CHAR}" STREQUAL ")") AND NOT(OPEN_INDEX EQUAL -1) AND (NESTED_DEPTH EQUAL 0)) + MATH(EXPR OPEN_INDEX "${OPEN_INDEX}+1") + MATH(EXPR SUBSTR_LENGTH "${STR_INDEX}-${OPEN_INDEX}") + string(SUBSTRING "${INPUT_LIST}" ${OPEN_INDEX} ${SUBSTR_LENGTH} GROUP_STR) + GENERATE_DEFINES_LIST_HELPER("${GROUP_STR}" EXPANDED_GROUP_LIST) + string(REPLACE ";" "/" EXPANDED_GROUP_LIST "${EXPANDED_GROUP_LIST}") + string(REPLACE "(${GROUP_STR})" "${EXPANDED_GROUP_LIST}" INPUT_LIST "${INPUT_LIST}") + MATH(EXPR STR_INDEX "${OPEN_INDEX}-1") + set(OPEN_INDEX -1) + string(LENGTH "${INPUT_LIST}" STR_LENGTH) + continue() + endif() + + MATH(EXPR STR_INDEX "${STR_INDEX}+1") + endwhile() + + list(LENGTH INPUT_LIST NUM_DEFINES) + if (NUM_DEFINES EQUAL 1) + string(REPLACE "/" ";" INPUT_LIST "${INPUT_LIST}") + set(${RETURN_LIST} ${INPUT_LIST} PARENT_SCOPE) + elseif (NUM_DEFINES GREATER 1) + list(GET INPUT_LIST 0 CURRENT_DEFINES) + string(REPLACE "/" ";" CURRENT_DEFINES "${CURRENT_DEFINES}") + list(REMOVE_AT INPUT_LIST 0) + GENERATE_DEFINES_LIST_HELPER("${INPUT_LIST}" REMAINING_DEFINES_LIST) + set(TO_RETURN_LIST "${CURRENT_DEFINES}") + foreach(REMAINING_DEFINES ${REMAINING_DEFINES_LIST}) + list(APPEND TO_RETURN_LIST "${REMAINING_DEFINES}") + foreach(CURRENT_DEFINE ${CURRENT_DEFINES}) + list(APPEND TO_RETURN_LIST "${CURRENT_DEFINE}_${REMAINING_DEFINES}") + endforeach() + endforeach() + set(${RETURN_LIST} ${TO_RETURN_LIST} PARENT_SCOPE) + endif() +endfunction() + +macro(GENERATE_DEFINES_LIST) + set(DEFINES_LIST "") + GENERATE_DEFINES_LIST_HELPER("${ARGV0}" DEFINES_LIST) +endmacro() + macro(AUTOSCRIBE_SHADER_LIB) if (NOT ("${TARGET_NAME}" STREQUAL "shaders")) message(FATAL_ERROR "AUTOSCRIBE_SHADER_LIB can only be used by the shaders library") @@ -164,24 +232,24 @@ macro(AUTOSCRIBE_SHADER_LIB) if (SHADER_VERTEX_FILES) source_group("${SHADER_LIB}/Vertex" FILES ${SHADER_VERTEX_FILES}) list(APPEND ALL_SCRIBE_SHADERS ${SHADER_VERTEX_FILES}) - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace vertex { enum {\n") - foreach(SHADER_FILE ${SHADER_VERTEX_FILES}) + set(SHADER_LIST "namespace vertex { enum {\n") + foreach(SHADER_FILE ${SHADER_VERTEX_FILES}) AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) endforeach() - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // vertex \n") + set(VERTEX_ENUMS "${SHADER_LIST}") endif() file(GLOB_RECURSE SHADER_FRAGMENT_FILES ${SRC_FOLDER}/*.slf) if (SHADER_FRAGMENT_FILES) source_group("${SHADER_LIB}/Fragment" FILES ${SHADER_FRAGMENT_FILES}) list(APPEND ALL_SCRIBE_SHADERS ${SHADER_FRAGMENT_FILES}) - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace fragment { enum {\n") - foreach(SHADER_FILE ${SHADER_FRAGMENT_FILES}) + set(SHADER_LIST "namespace fragment { enum {\n") + foreach(SHADER_FILE ${SHADER_FRAGMENT_FILES}) AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) endforeach() - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // fragment \n") + set(FRAGMENT_ENUMS "${SHADER_LIST}") endif() - + # FIXME add support for geometry, compute and tesselation shaders #file(GLOB_RECURSE SHADER_GEOMETRY_FILES ${SRC_FOLDER}/*.slg) #file(GLOB_RECURSE SHADER_COMPUTE_FILES ${SRC_FOLDER}/*.slc) @@ -191,13 +259,13 @@ macro(AUTOSCRIBE_SHADER_LIB) if (SHADER_PROGRAM_FILES) source_group("${SHADER_LIB}/Program" FILES ${SHADER_PROGRAM_FILES}) list(APPEND ALL_SCRIBE_SHADERS ${SHADER_PROGRAM_FILES}) - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace program { enum {\n") + set(PROGRAM_ENUMS "namespace program { enum {\n") foreach(PROGRAM_FILE ${SHADER_PROGRAM_FILES}) get_filename_component(PROGRAM_NAME ${PROGRAM_FILE} NAME_WE) - set(AUTOSCRIBE_PROGRAM_FRAGMENT ${PROGRAM_NAME}) file(READ ${PROGRAM_FILE} PROGRAM_CONFIG) set(AUTOSCRIBE_PROGRAM_VERTEX ${PROGRAM_NAME}) set(AUTOSCRIBE_PROGRAM_FRAGMENT ${PROGRAM_NAME}) + set(AUTOSCRIBE_PROGRAM_DEFINES "") if (NOT("${PROGRAM_CONFIG}" STREQUAL "")) string(REGEX MATCH ".*VERTEX +([_\\:A-Z0-9a-z]+)" MVERT ${PROGRAM_CONFIG}) @@ -208,6 +276,12 @@ macro(AUTOSCRIBE_SHADER_LIB) if (CMAKE_MATCH_1) set(AUTOSCRIBE_PROGRAM_FRAGMENT ${CMAKE_MATCH_1}) endif() + string(REGEX MATCH ".*DEFINES +([a-zA-Z\(\)/: ]+)" MDEF ${PROGRAM_CONFIG}) + if (CMAKE_MATCH_1) + set(AUTOSCRIBE_PROGRAM_DEFINES ${CMAKE_MATCH_1}) + string(TOLOWER AUTOSCRIBE_PROGRAM_DEFINES "${AUTOSCRIBE_PROGRAM_DEFINES}") + string(REGEX REPLACE " +" ";" AUTOSCRIBE_PROGRAM_DEFINES "${AUTOSCRIBE_PROGRAM_DEFINES}") + endif() endif() if (NOT (${AUTOSCRIBE_PROGRAM_VERTEX} MATCHES ".*::.*")) @@ -216,12 +290,72 @@ macro(AUTOSCRIBE_SHADER_LIB) if (NOT (${AUTOSCRIBE_PROGRAM_FRAGMENT} MATCHES ".*::.*")) set(AUTOSCRIBE_PROGRAM_FRAGMENT "fragment::${AUTOSCRIBE_PROGRAM_FRAGMENT}") endif() + string(REGEX REPLACE ".*::" "" VERTEX_NAME "${AUTOSCRIBE_PROGRAM_VERTEX}") + string(REGEX REPLACE ".*::" "" FRAGMENT_NAME "${AUTOSCRIBE_PROGRAM_FRAGMENT}") - set(PROGRAM_ENTRY "${PROGRAM_NAME} = (${AUTOSCRIBE_PROGRAM_VERTEX} << 16) | ${AUTOSCRIBE_PROGRAM_FRAGMENT},\n") - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${PROGRAM_ENTRY}") + GENERATE_DEFINES_LIST("${AUTOSCRIBE_PROGRAM_DEFINES}") + + string(CONCAT PROGRAM_ENUMS "${PROGRAM_ENUMS}" "${PROGRAM_NAME} = (${AUTOSCRIBE_PROGRAM_VERTEX} << 16) | ${AUTOSCRIBE_PROGRAM_FRAGMENT},\n") string(CONCAT SHADER_PROGRAMS_ARRAY "${SHADER_PROGRAMS_ARRAY} ${SHADER_NAMESPACE}::program::${PROGRAM_NAME},\n") + + foreach(DEFINES ${DEFINES_LIST}) + set(ORIG_DEFINES "${DEFINES}") + + string(REPLACE ":v" "" VERTEX_DEFINES "${ORIG_DEFINES}") + string(FIND "${ORIG_DEFINES}" ":f" HAS_FRAGMENT) + if (HAS_FRAGMENT EQUAL -1) + set(DEFINES "${VERTEX_DEFINES}") + set(SHADER_LIST "") + set(SHADER_FILE "${SRC_FOLDER}/${VERTEX_NAME}.slv") + AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) + string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}") + else() + string(REGEX REPLACE "_*[^_]*:f" "" VERTEX_DEFINES "${VERTEX_DEFINES}") + endif() + + if (NOT("${VERTEX_DEFINES}" STREQUAL "") AND NOT("${VERTEX_DEFINES}" MATCHES "^_.*")) + set(VERTEX_DEFINES "_${VERTEX_DEFINES}") + endif() + + string(REPLACE ":f" "" FRAGMENT_DEFINES "${ORIG_DEFINES}") + string(FIND "${ORIG_DEFINES}" ":v" HAS_VERTEX) + if (HAS_VERTEX EQUAL -1) + set(DEFINES "${FRAGMENT_DEFINES}") + set(SHADER_LIST "") + set(SHADER_FILE "${SRC_FOLDER}/${FRAGMENT_NAME}.slf") + AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) + string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}") + else() + string(REGEX REPLACE "_*[^_]*:v" "" FRAGMENT_DEFINES "${FRAGMENT_DEFINES}") + endif() + + if (NOT("${FRAGMENT_DEFINES}" STREQUAL "") AND NOT("${FRAGMENT_DEFINES}" MATCHES "^_.*")) + set(FRAGMENT_DEFINES "_${FRAGMENT_DEFINES}") + endif() + + string(REGEX REPLACE ":(f|v)" "" PROGRAM_DEFINES "${ORIG_DEFINES}") + + if (NOT("${PROGRAM_DEFINES}" STREQUAL "")) + string(CONCAT PROGRAM_ENUMS "${PROGRAM_ENUMS}" "${PROGRAM_NAME}_${PROGRAM_DEFINES} = (${AUTOSCRIBE_PROGRAM_VERTEX}${VERTEX_DEFINES} << 16) | ${AUTOSCRIBE_PROGRAM_FRAGMENT}${FRAGMENT_DEFINES},\n") + string(CONCAT SHADER_PROGRAMS_ARRAY "${SHADER_PROGRAMS_ARRAY} ${SHADER_NAMESPACE}::program::${PROGRAM_NAME}_${PROGRAM_DEFINES},\n") + endif() + endforeach() endforeach() - string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // program \n") + endif() + + if (SHADER_VERTEX_FILES) + string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "}; } // vertex \n") + string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${VERTEX_ENUMS}") + endif() + + if (SHADER_FRAGMENT_FILES) + string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "}; } // fragment \n") + string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${FRAGMENT_ENUMS}") + endif() + + if (SHADER_PROGRAM_FILES) + string(CONCAT PROGRAM_ENUMS "${PROGRAM_ENUMS}" "}; } // program \n") + string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${PROGRAM_ENUMS}") endif() # Finish the shader enums diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 23fc1cb4bd..961ce627a4 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -405,7 +405,7 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo using namespace shader::render_utils::program; static const std::vector> 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) }; for (auto& key : keys) { diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index 6a0d7b001c..ca4154e942 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -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); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 3b615ba467..1493792b19 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -314,12 +314,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())); @@ -327,7 +334,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) { // Turn off jitter for these entities batch.pushProjectionJitter(); - DependencyManager::get()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD); + DependencyManager::get()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward); DependencyManager::get()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId); batch.popProjectionJitter(); batch.setResourceTexture(0, nullptr); diff --git a/libraries/entities-renderer/src/entities-renderer/paintStroke.slp b/libraries/entities-renderer/src/entities-renderer/paintStroke.slp index e69de29bb2..e283f4edcb 100644 --- a/libraries/entities-renderer/src/entities-renderer/paintStroke.slp +++ b/libraries/entities-renderer/src/entities-renderer/paintStroke.slp @@ -0,0 +1 @@ +DEFINES forward \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp b/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp deleted file mode 100644 index 4d49e0d3a4..0000000000 --- a/libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX paintStroke \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/polyvox.slp b/libraries/entities-renderer/src/entities-renderer/polyvox.slp index e69de29bb2..82853b2a91 100644 --- a/libraries/entities-renderer/src/entities-renderer/polyvox.slp +++ b/libraries/entities-renderer/src/entities-renderer/polyvox.slp @@ -0,0 +1 @@ +DEFINES (shadow fade)/forward \ No newline at end of file diff --git a/libraries/entities-renderer/src/entities-renderer/polyvox_fade.slp b/libraries/entities-renderer/src/entities-renderer/polyvox_fade.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/entities-renderer/src/paintStroke.slf b/libraries/entities-renderer/src/paintStroke.slf index 6ea088751f..2767717772 100644 --- a/libraries/entities-renderer/src/paintStroke.slf +++ b/libraries/entities-renderer/src/paintStroke.slf @@ -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,33 @@ // 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; +<@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); - int frontCondition = 1 - 2 * int(gl_FrontFacing); - 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( - float(frontCondition) * _normalWS, - alpha, - color, - DEFAULT_ROUGHNESS); +<@if not HIFI_USE_FORWARD@> + float frontCondition = 1.0 - 2.0 * float(gl_FrontFacing); + packDeferredFragmentTranslucent(frontCondition * _normalWS, texel.a, texel.rgb, DEFAULT_ROUGHNESS); +<@else@> + _fragColor0 = texel; +<@endif@> } diff --git a/libraries/entities-renderer/src/paintStroke.slv b/libraries/entities-renderer/src/paintStroke.slv index f591370186..2a2025e59f 100644 --- a/libraries/entities-renderer/src/paintStroke.slv +++ b/libraries/entities-renderer/src/paintStroke.slv @@ -1,5 +1,6 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // // paintStroke.vert @@ -20,7 +21,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 +53,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@> } } \ No newline at end of file diff --git a/libraries/entities-renderer/src/paintStroke_forward.slf b/libraries/entities-renderer/src/paintStroke_forward.slf deleted file mode 100644 index b949332826..0000000000 --- a/libraries/entities-renderer/src/paintStroke_forward.slf +++ /dev/null @@ -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); -} diff --git a/libraries/entities-renderer/src/polyvox.slf b/libraries/entities-renderer/src/polyvox.slf index 6b1aa25a25..b703a6868c 100644 --- a/libraries/entities-renderer/src/polyvox.slf +++ b/libraries/entities-renderer/src/polyvox.slf @@ -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,110 @@ // 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()$> + + <@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(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; + + 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; + }; +<@else@> + 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(_normalMS); + 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(); + vec4 color = 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@> } diff --git a/libraries/entities-renderer/src/polyvox.slv b/libraries/entities-renderer/src/polyvox.slv index d17974c994..82ae741888 100644 --- a/libraries/entities-renderer/src/polyvox.slv +++ b/libraries/entities-renderer/src/polyvox.slv @@ -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,41 @@ // <@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; + layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; +<@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)$> + _normalMS = inNormal.xyz; + _positionMS = inPosition.xyz; +<@endif@> +<@if HIFI_USE_FADE@> + <$transformModelToWorldPos(obj, inPosition, _positionWS)$> +<@endif@> } diff --git a/libraries/entities-renderer/src/polyvox_fade.slf b/libraries/entities-renderer/src/polyvox_fade.slf deleted file mode 100644 index ae2e05c3dc..0000000000 --- a/libraries/entities-renderer/src/polyvox_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/entities-renderer/src/polyvox_fade.slv b/libraries/entities-renderer/src/polyvox_fade.slv deleted file mode 100644 index 97b98f5840..0000000000 --- a/libraries/entities-renderer/src/polyvox_fade.slv +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/ForwardGlobalLight.slh b/libraries/render-utils/src/ForwardGlobalLight.slh deleted file mode 100644 index cf5f070c55..0000000000 --- a/libraries/render-utils/src/ForwardGlobalLight.slh +++ /dev/null @@ -1,247 +0,0 @@ - -<@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@> diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 7bd6f88d71..3cc43eaa76 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -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, gpu::PipelinePointer> GeometryCache::_webPipelines; std::map, gpu::PipelinePointer> GeometryCache::_gridPipelines; void GeometryCache::computeSimpleHullPointListForShape(const int entityShape, const glm::vec3 &entityExtents, QVector &outPointList) { @@ -2045,7 +2046,7 @@ void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bo const float DEPTH_BIAS = 0.001f; static const std::vector> 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) { @@ -2136,34 +2137,36 @@ 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(); - 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; + static const std::vector> keys = { + std::make_tuple(false, false, web_browser), std::make_tuple(false, true, web_browser_forward), + std::make_tuple(true, false, web_browser_translucent) + }; -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 (auto& key : keys) { + 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(std::get<0>(key), + 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); - return transparent ? _simpleTransparentWebBrowserPipeline : _simpleOpaqueWebBrowserPipeline; + _webPipelines[{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 + _webPipelines[{ true, true }] = _webPipelines[{ false, true }]; + } + + return _webPipelines[{ transparent, forward }]; } void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool transparent, bool culled, bool unlit, bool depthBiased, bool isAntiAliased, bool forward) { @@ -2191,24 +2194,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); }); } diff --git a/libraries/render-utils/src/GeometryCache.h b/libraries/render-utils/src/GeometryCache.h index a42b059a8c..31e1eddc3d 100644 --- a/libraries/render-utils/src/GeometryCache.h +++ b/libraries/render-utils/src/GeometryCache.h @@ -176,8 +176,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, gpu::PipelinePointer> _webPipelines; static void initializeShapePipelines(); @@ -477,11 +478,6 @@ private: static QHash _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, diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/GlobalLight.slh similarity index 86% rename from libraries/render-utils/src/DeferredGlobalLight.slh rename to libraries/render-utils/src/GlobalLight.slh index 03ec18c321..1cc357fe5f 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/GlobalLight.slh @@ -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,7 +98,9 @@ vec3 albedo, vec3 fresnel, float metallic, float roughness <@endfunc@> +<@if not HIFI_USE_FORWARD@> <@include Haze.slh@> +<@endif@> <@func declareEvalSkyboxGlobalColor(supportScattering)@> @@ -123,7 +126,7 @@ 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; @@ -133,16 +136,18 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu 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; +<@if not HIFI_USE_FORWARD@> // 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); } +<@endif@> return color; } @@ -179,6 +184,29 @@ 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) { + <$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 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)$> @@ -202,6 +230,7 @@ vec3 evalGlobalLightingAlphaBlended(mat4 invViewMat, float shadowAttenuation, fl return color; } + <@endfunc@> <@func declareEvalGlobalLightingAlphaBlendedWithHaze()@> @@ -213,7 +242,6 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( 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); @@ -233,6 +261,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color += directionalDiffuse; color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); +<@if not HIFI_USE_FORWARD@> // Haze if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { vec4 hazeColor = computeHazeColor( @@ -244,6 +273,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color = mix(color.rgb, hazeColor.rgb, hazeColor.a); } +<@endif@> return color; } @@ -270,6 +300,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color += ambientDiffuse + directionalDiffuse; color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); +<@if not HIFI_USE_FORWARD@> // Haze if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { vec4 hazeColor = computeHazeColor( @@ -281,6 +312,7 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color = mix(color.rgb, hazeColor.rgb, hazeColor.a); } +<@endif@> return color; } diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index 2817abb4a1..20fb4c6d31 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -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> 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> 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) { diff --git a/libraries/render-utils/src/deferred_light.slv b/libraries/render-utils/src/deferred_light.slv index 164fd9fb3b..31ec378456 100644 --- a/libraries/render-utils/src/deferred_light.slv +++ b/libraries/render-utils/src/deferred_light.slv @@ -26,7 +26,7 @@ void main(void) { ); vec4 pos = UNIT_QUAD[gl_VertexID]; - _texCoord01.xy = (pos.xy + 1.0) * 0.5; + _texCoord01 = vec4((pos.xy + 1.0) * 0.5, 0.0, 0.0); gl_Position = pos; } diff --git a/libraries/render-utils/src/deformed_model.slv b/libraries/render-utils/src/deformed_model.slv deleted file mode 100644 index 8c6d3d049d..0000000000 --- a/libraries/render-utils/src/deformed_model.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/deformed_model_dq.slv b/libraries/render-utils/src/deformed_model_dq.slv deleted file mode 100644 index 56ac1b6558..0000000000 --- a/libraries/render-utils/src/deformed_model_dq.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/deformed_model_normal_map.slv b/libraries/render-utils/src/deformed_model_normal_map.slv deleted file mode 100644 index 85e164b639..0000000000 --- a/libraries/render-utils/src/deformed_model_normal_map.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/deformed_model_normal_map_dq.slv b/libraries/render-utils/src/deformed_model_normal_map_dq.slv deleted file mode 100644 index 807d343643..0000000000 --- a/libraries/render-utils/src/deformed_model_normal_map_dq.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/deformed_model_shadow.slv b/libraries/render-utils/src/deformed_model_shadow.slv deleted file mode 100644 index 827fc69b32..0000000000 --- a/libraries/render-utils/src/deformed_model_shadow.slv +++ /dev/null @@ -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)$> - } -} - diff --git a/libraries/render-utils/src/deformed_model_shadow_dq.slv b/libraries/render-utils/src/deformed_model_shadow_dq.slv deleted file mode 100644 index 646fc12ce9..0000000000 --- a/libraries/render-utils/src/deformed_model_shadow_dq.slv +++ /dev/null @@ -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)$> - } -} diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index b1cfc26c66..ecacff38f6 100644 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -15,7 +15,7 @@ <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> +<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> <$declareEvalLightmappedColor()$> diff --git a/libraries/render-utils/src/directional_ambient_light_shadow.slf b/libraries/render-utils/src/directional_ambient_light_shadow.slf index 6b9fb80232..c6763eb372 100644 --- a/libraries/render-utils/src/directional_ambient_light_shadow.slf +++ b/libraries/render-utils/src/directional_ambient_light_shadow.slf @@ -14,7 +14,7 @@ <@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> +<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> <$declareEvalLightmappedColor()$> diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index b820b3d17f..f6044b2d89 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -13,7 +13,7 @@ // <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> +<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> <$declareEvalLightmappedColor()$> diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index 8716d60d54..7af0eafd9a 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -14,7 +14,7 @@ <@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include DeferredGlobalLight.slh@> +<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> <$declareEvalLightmappedColor()$> diff --git a/libraries/render-utils/src/forward_grid.slf b/libraries/render-utils/src/forward_grid.slf deleted file mode 100644 index e34794bfed..0000000000 --- a/libraries/render-utils/src/forward_grid.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/forward_grid_translucent.slf b/libraries/render-utils/src/forward_grid_translucent.slf deleted file mode 100644 index df0494a22e..0000000000 --- a/libraries/render-utils/src/forward_grid_translucent.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/forward_model.slf b/libraries/render-utils/src/forward_model.slf deleted file mode 100644 index daccd9c6d6..0000000000 --- a/libraries/render-utils/src/forward_model.slf +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/forward_model_lightmap.slf b/libraries/render-utils/src/forward_model_lightmap.slf deleted file mode 100644 index aa1d6dc3b8..0000000000 --- a/libraries/render-utils/src/forward_model_lightmap.slf +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/forward_model_normal_map.slf b/libraries/render-utils/src/forward_model_normal_map.slf deleted file mode 100644 index 33e375c495..0000000000 --- a/libraries/render-utils/src/forward_model_normal_map.slf +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/forward_model_normal_map_lightmap.slf b/libraries/render-utils/src/forward_model_normal_map_lightmap.slf deleted file mode 100644 index c36f3d51c6..0000000000 --- a/libraries/render-utils/src/forward_model_normal_map_lightmap.slf +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/forward_model_translucent.slf b/libraries/render-utils/src/forward_model_translucent.slf deleted file mode 100644 index 080ed7eea3..0000000000 --- a/libraries/render-utils/src/forward_model_translucent.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/forward_model_unlit.slf b/libraries/render-utils/src/forward_model_unlit.slf deleted file mode 100644 index ccd264f0bf..0000000000 --- a/libraries/render-utils/src/forward_model_unlit.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/forward_parabola.slf b/libraries/render-utils/src/forward_parabola.slf deleted file mode 100644 index b0def6db6b..0000000000 --- a/libraries/render-utils/src/forward_parabola.slf +++ /dev/null @@ -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; -} diff --git a/libraries/render-utils/src/forward_sdf_text3D.slf b/libraries/render-utils/src/forward_sdf_text3D.slf deleted file mode 100644 index 09b10c0c42..0000000000 --- a/libraries/render-utils/src/forward_sdf_text3D.slf +++ /dev/null @@ -1,57 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_transparent.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// 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()$> - -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -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() { - float a = evalSDFSuperSampled(_texCoord0); - - float alpha = a * _color.a; - if (alpha <= 0.0) { - discard; - } - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS), - _color.rgb, - DEFAULT_FRESNEL, - DEFAULT_METALLIC, - DEFAULT_ROUGHNESS), - 1.0); -} \ No newline at end of file diff --git a/libraries/render-utils/src/forward_simple.slf b/libraries/render-utils/src/forward_simple.slf deleted file mode 100644 index 677c369033..0000000000 --- a/libraries/render-utils/src/forward_simple.slf +++ /dev/null @@ -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, - diffuse, - DEFAULT_FRESNEL, - length(specular), - max(0.0, 1.0 - shininess / 128.0)), - 1.0); -} diff --git a/libraries/render-utils/src/forward_simple_textured.slf b/libraries/render-utils/src/forward_simple_textured.slf deleted file mode 100644 index 373ab13d1a..0000000000 --- a/libraries/render-utils/src/forward_simple_textured.slf +++ /dev/null @@ -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), - albedo, - fresnel, - metallic, - DEFAULT_ROUGHNESS), - 1.0); -} \ No newline at end of file diff --git a/libraries/render-utils/src/forward_simple_textured_transparent.slf b/libraries/render-utils/src/forward_simple_textured_transparent.slf deleted file mode 100644 index 1b5047507b..0000000000 --- a/libraries/render-utils/src/forward_simple_textured_transparent.slf +++ /dev/null @@ -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), - albedo, - fresnel, - metallic, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/forward_simple_textured_unlit.slf b/libraries/render-utils/src/forward_simple_textured_unlit.slf deleted file mode 100644 index ddbc5ae4d7..0000000000 --- a/libraries/render-utils/src/forward_simple_textured_unlit.slf +++ /dev/null @@ -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); -} \ No newline at end of file diff --git a/libraries/render-utils/src/glowLine.slf b/libraries/render-utils/src/glowLine.slf deleted file mode 100644 index c65d8d6488..0000000000 --- a/libraries/render-utils/src/glowLine.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/glowLine.slv b/libraries/render-utils/src/glowLine.slv deleted file mode 100644 index 1bcb25817c..0000000000 --- a/libraries/render-utils/src/glowLine.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/grid.slf b/libraries/render-utils/src/grid.slf index 50c420bc10..68e6d019c0 100644 --- a/libraries/render-utils/src/grid.slf +++ b/libraries/render-utils/src/grid.slf @@ -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; @@ -32,9 +37,17 @@ void main(void) { paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), float(grid.edge.z == 0.0)); - if (alpha < 0.0001) { +<@if not HIFI_USE_FORWARD@> + <@if not HIFI_USE_TRANSLUCENT@> + packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), alpha, varColor.rgb); + <@else@> + packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), alpha, varColor.rgb, DEFAULT_ROUGHNESS); + <@endif@> +<@else@> + const float EPSILON = 0.0001; + if (alpha < EPSILON) { discard; } - - packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, varColor.xyz); + _fragColor0 = vec4(varColor.rgb, alpha); +<@endif@> } diff --git a/libraries/render-utils/src/grid_translucent.slf b/libraries/render-utils/src/grid_translucent.slf deleted file mode 100644 index bb61126991..0000000000 --- a/libraries/render-utils/src/grid_translucent.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/hmd_ui.slv b/libraries/render-utils/src/hmd_ui.slv index 6e782d1672..75423d1882 100644 --- a/libraries/render-utils/src/hmd_ui.slv +++ b/libraries/render-utils/src/hmd_ui.slv @@ -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(); diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index edf5064324..7803974ec8 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -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,313 @@ // 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@> + <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <@else@> + <$declareEvalGlobalLightingAlphaBlended()$> + <@endif@> + <@else@> + <$declareEvalSkyboxGlobalColor()$> + <@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)$>; + float opacity = 1.0; + <$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)$>; + float opacity = 1.0; + <$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@> + + <@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( + normalize(fragNormalWS), + opacity, + albedo, + roughness, + metallic, + emissive + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + occlusion, + scattering); + <@else@> + packDeferredFragmentLightmap( + normalize(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(evalGlobalLightingAlphaBlendedWithHaze( + cam._viewInverse, + 1.0, + occlusion, + _positionES.xyz, + fragPositionWS, + 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@> } diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv index 88cbd1e18c..319711eac2 100644 --- a/libraries/render-utils/src/model.slv +++ b/libraries/render-utils/src/model.slv @@ -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@> } diff --git a/libraries/render-utils/src/model_fade.slf b/libraries/render-utils/src/model_fade.slf deleted file mode 100644 index e931ec4cf0..0000000000 --- a/libraries/render-utils/src/model_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_lightmap.slf b/libraries/render-utils/src/model_lightmap.slf deleted file mode 100644 index 1be247e3e9..0000000000 --- a/libraries/render-utils/src/model_lightmap.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_lightmap_fade.slf b/libraries/render-utils/src/model_lightmap_fade.slf deleted file mode 100644 index 61568463a7..0000000000 --- a/libraries/render-utils/src/model_lightmap_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slf b/libraries/render-utils/src/model_lightmap_normal_map.slf deleted file mode 100644 index 3d961584c2..0000000000 --- a/libraries/render-utils/src/model_lightmap_normal_map.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf b/libraries/render-utils/src/model_lightmap_normal_map_fade.slf deleted file mode 100644 index f873847474..0000000000 --- a/libraries/render-utils/src/model_lightmap_normal_map_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_normal_map.slf b/libraries/render-utils/src/model_normal_map.slf deleted file mode 100644 index 695fadbca8..0000000000 --- a/libraries/render-utils/src/model_normal_map.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_normal_map.slv b/libraries/render-utils/src/model_normal_map.slv deleted file mode 100644 index 0fd9a8b582..0000000000 --- a/libraries/render-utils/src/model_normal_map.slv +++ /dev/null @@ -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)$> -} diff --git a/libraries/render-utils/src/model_normal_map_fade.slf b/libraries/render-utils/src/model_normal_map_fade.slf deleted file mode 100644 index 07b6f47b55..0000000000 --- a/libraries/render-utils/src/model_normal_map_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_shadow.slf b/libraries/render-utils/src/model_shadow.slf deleted file mode 100644 index 6d8dfb7e2a..0000000000 --- a/libraries/render-utils/src/model_shadow.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_shadow.slv b/libraries/render-utils/src/model_shadow.slv deleted file mode 100644 index d455ea4ade..0000000000 --- a/libraries/render-utils/src/model_shadow.slv +++ /dev/null @@ -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)$> - } -} diff --git a/libraries/render-utils/src/model_shadow_fade.slf b/libraries/render-utils/src/model_shadow_fade.slf deleted file mode 100644 index 1f94d4a0ac..0000000000 --- a/libraries/render-utils/src/model_shadow_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf deleted file mode 100644 index 72f6b4c187..0000000000 --- a/libraries/render-utils/src/model_translucent.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent_fade.slf b/libraries/render-utils/src/model_translucent_fade.slf deleted file mode 100644 index 7e170759c4..0000000000 --- a/libraries/render-utils/src/model_translucent_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent_normal_map.slf b/libraries/render-utils/src/model_translucent_normal_map.slf deleted file mode 100644 index b3a9127acf..0000000000 --- a/libraries/render-utils/src/model_translucent_normal_map.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent_normal_map_fade.slf b/libraries/render-utils/src/model_translucent_normal_map_fade.slf deleted file mode 100644 index 4c56ebda2e..0000000000 --- a/libraries/render-utils/src/model_translucent_normal_map_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent_unlit.slf b/libraries/render-utils/src/model_translucent_unlit.slf deleted file mode 100644 index 37f58d3da9..0000000000 --- a/libraries/render-utils/src/model_translucent_unlit.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_translucent_unlit_fade.slf b/libraries/render-utils/src/model_translucent_unlit_fade.slf deleted file mode 100644 index 04d57b7c47..0000000000 --- a/libraries/render-utils/src/model_translucent_unlit_fade.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/model_unlit.slf b/libraries/render-utils/src/model_unlit.slf deleted file mode 100644 index cbac67a72e..0000000000 --- a/libraries/render-utils/src/model_unlit.slf +++ /dev/null @@ -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()); -} diff --git a/libraries/render-utils/src/model_unlit_fade.slf b/libraries/render-utils/src/model_unlit_fade.slf deleted file mode 100644 index 3097c04c26..0000000000 --- a/libraries/render-utils/src/model_unlit_fade.slf +++ /dev/null @@ -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()); -} diff --git a/libraries/render-utils/src/parabola.slf b/libraries/render-utils/src/parabola.slf index ea51d7e3af..f19f82ec59 100644 --- a/libraries/render-utils/src/parabola.slf +++ b/libraries/render-utils/src/parabola.slf @@ -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@> } diff --git a/libraries/render-utils/src/parabola_translucent.slf b/libraries/render-utils/src/parabola_translucent.slf deleted file mode 100644 index 01f4614172..0000000000 --- a/libraries/render-utils/src/parabola_translucent.slf +++ /dev/null @@ -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); -} diff --git a/libraries/render-utils/src/render-utils/deformed_model.slp b/libraries/render-utils/src/render-utils/deformed_model.slp deleted file mode 100644 index 9db8938e86..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model diff --git a/libraries/render-utils/src/render-utils/deformed_model_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_dq.slp deleted file mode 100644 index ec950ac784..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model diff --git a/libraries/render-utils/src/render-utils/deformed_model_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_fade.slp deleted file mode 100644 index 5818e5e3af..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp deleted file mode 100644 index 9047bc1286..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp deleted file mode 100644 index ad460652ad..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp deleted file mode 100644 index 44d5cd5272..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp deleted file mode 100644 index 99aab59169..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp deleted file mode 100644 index 0ee002b6a1..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp deleted file mode 100644 index f2e2b2e4da..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_translucent_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp deleted file mode 100644 index 577a6c1616..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_translucent_normal_map diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp deleted file mode 100644 index de9591b45f..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT model_translucent_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp deleted file mode 100644 index 3f624f7bf7..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT model_translucent_normal_map_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow.slp deleted file mode 100644 index c8718dff09..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow -FRAGMENT model_shadow diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp deleted file mode 100644 index b0f1449234..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow_dq -FRAGMENT model_shadow diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp deleted file mode 100644 index 1063134d96..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow -FRAGMENT model_shadow_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp deleted file mode 100644 index 25c99c75d1..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_shadow_dq -FRAGMENT model_shadow_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent.slp deleted file mode 100644 index 798fec9a5b..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_translucent diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp deleted file mode 100644 index 8a0b70cfcf..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_translucent diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp deleted file mode 100644 index 68eef3624d..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT model_translucent_fade diff --git a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp b/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp deleted file mode 100644 index 4ce321fa78..0000000000 --- a/libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT model_translucent_fade diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model.slp b/libraries/render-utils/src/render-utils/forward_deformed_model.slp deleted file mode 100644 index 3b7c49705b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT forward_model diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp deleted file mode 100644 index 45d886529a..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT forward_model diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp deleted file mode 100644 index 539ca61193..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT forward_model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp deleted file mode 100644 index c663b671fe..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT forward_model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp deleted file mode 100644 index 605499ebc3..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp deleted file mode 100644 index cd20657b01..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_dq -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp deleted file mode 100644 index 85d08c1943..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp b/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp deleted file mode 100644 index 2f13b16a5b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX deformed_model_normal_map_dq -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_grid.slp b/libraries/render-utils/src/render-utils/forward_grid.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/forward_grid.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/forward_grid_translucent.slp b/libraries/render-utils/src/render-utils/forward_grid_translucent.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/forward_grid_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/forward_model.slp b/libraries/render-utils/src/render-utils/forward_model.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_lightmap.slp b/libraries/render-utils/src/render-utils/forward_model_lightmap.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp b/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp deleted file mode 100644 index 0979918b98..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp +++ /dev/null @@ -1,2 +0,0 @@ -VERTEX model_normal_map -FRAGMENT forward_model_translucent diff --git a/libraries/render-utils/src/render-utils/forward_model_translucent.slp b/libraries/render-utils/src/render-utils/forward_model_translucent.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_model_unlit.slp b/libraries/render-utils/src/render-utils/forward_model_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/forward_model_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/forward_parabola.slp b/libraries/render-utils/src/render-utils/forward_parabola.slp deleted file mode 100644 index ab3f1d4126..0000000000 --- a/libraries/render-utils/src/render-utils/forward_parabola.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX parabola diff --git a/libraries/render-utils/src/render-utils/forward_sdf_text3D.slp b/libraries/render-utils/src/render-utils/forward_sdf_text3D.slp deleted file mode 100644 index 3eea3a0da0..0000000000 --- a/libraries/render-utils/src/render-utils/forward_sdf_text3D.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured.slp b/libraries/render-utils/src/render-utils/forward_simple_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp b/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp b/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/glowLine.slp b/libraries/render-utils/src/render-utils/glowLine.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/grid.slp b/libraries/render-utils/src/render-utils/grid.slp index c81b208f63..5cf10ff674 100644 --- a/libraries/render-utils/src/render-utils/grid.slp +++ b/libraries/render-utils/src/render-utils/grid.slp @@ -1 +1,2 @@ VERTEX standardTransformPNTC +DEFINES translucent:f forward:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/grid_translucent.slp b/libraries/render-utils/src/render-utils/grid_translucent.slp deleted file mode 100644 index c81b208f63..0000000000 --- a/libraries/render-utils/src/render-utils/grid_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX standardTransformPNTC diff --git a/libraries/render-utils/src/render-utils/model.slp b/libraries/render-utils/src/render-utils/model.slp index e69de29bb2..b63ec898eb 100644 --- a/libraries/render-utils/src/render-utils/model.slp +++ b/libraries/render-utils/src/render-utils/model.slp @@ -0,0 +1 @@ +DEFINES (normalmap translucent:f unlit:f/lightmap:f)/shadow fade:f/forward:f deformed:v/deformeddq:v \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_fade.slp b/libraries/render-utils/src/render-utils/model_fade.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap.slp b/libraries/render-utils/src/render-utils/model_lightmap.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap_fade.slp b/libraries/render-utils/src/render-utils/model_lightmap_fade.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp b/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_normal_map.slp b/libraries/render-utils/src/render-utils/model_normal_map.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/model_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_normal_map_fade.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_shadow.slp b/libraries/render-utils/src/render-utils/model_shadow.slp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/render-utils/src/render-utils/model_shadow_fade.slp b/libraries/render-utils/src/render-utils/model_shadow_fade.slp deleted file mode 100644 index f43521cba6..0000000000 --- a/libraries/render-utils/src/render-utils/model_shadow_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_shadow \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent.slp b/libraries/render-utils/src/render-utils/model_translucent.slp deleted file mode 100644 index ea0b2cf566..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp b/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp deleted file mode 100644 index 659899f9f8..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_normal_map.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp deleted file mode 100644 index c50be6285b..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model_normal_map diff --git a/libraries/render-utils/src/render-utils/model_translucent_unlit.slp b/libraries/render-utils/src/render-utils/model_translucent_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp b/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_unlit.slp b/libraries/render-utils/src/render-utils/model_unlit.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/model_unlit_fade.slp b/libraries/render-utils/src/render-utils/model_unlit_fade.slp deleted file mode 100644 index 81ac672062..0000000000 --- a/libraries/render-utils/src/render-utils/model_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX model diff --git a/libraries/render-utils/src/render-utils/parabola.slp b/libraries/render-utils/src/render-utils/parabola.slp index e69de29bb2..e9942be5cd 100644 --- a/libraries/render-utils/src/render-utils/parabola.slp +++ b/libraries/render-utils/src/render-utils/parabola.slp @@ -0,0 +1 @@ +DEFINES translucent:f/forward:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/parabola_translucent.slp b/libraries/render-utils/src/render-utils/parabola_translucent.slp deleted file mode 100644 index ab3f1d4126..0000000000 --- a/libraries/render-utils/src/render-utils/parabola_translucent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX parabola diff --git a/libraries/render-utils/src/render-utils/sdf_text3D.slp b/libraries/render-utils/src/render-utils/sdf_text3D.slp index e69de29bb2..06d27fe4ce 100644 --- a/libraries/render-utils/src/render-utils/sdf_text3D.slp +++ b/libraries/render-utils/src/render-utils/sdf_text3D.slp @@ -0,0 +1 @@ +DEFINES translucent forward \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/sdf_text3D_transparent.slp b/libraries/render-utils/src/render-utils/sdf_text3D_transparent.slp deleted file mode 100644 index 3eea3a0da0..0000000000 --- a/libraries/render-utils/src/render-utils/sdf_text3D_transparent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX sdf_text3D diff --git a/libraries/render-utils/src/render-utils/simple.slp b/libraries/render-utils/src/render-utils/simple.slp index e69de29bb2..5fc7789a21 100644 --- a/libraries/render-utils/src/render-utils/simple.slp +++ b/libraries/render-utils/src/render-utils/simple.slp @@ -0,0 +1 @@ +DEFINES translucent unlit fade/forward \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp b/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_procedural.slp b/libraries/render-utils/src/render-utils/simple_procedural.slp new file mode 100644 index 0000000000..1348d72a8d --- /dev/null +++ b/libraries/render-utils/src/render-utils/simple_procedural.slp @@ -0,0 +1 @@ +DEFINES translucent:f \ No newline at end of file diff --git a/libraries/render-utils/src/render-utils/simple_textured.slp b/libraries/render-utils/src/render-utils/simple_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_textured_fade.slp b/libraries/render-utils/src/render-utils/simple_textured_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_textured_unlit.slp b/libraries/render-utils/src/render-utils/simple_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp b/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent.slp b/libraries/render-utils/src/render-utils/simple_transparent.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp b/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp deleted file mode 100644 index 9be0f525ad..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple_fade diff --git a/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp b/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp deleted file mode 100644 index 10e6b388c4..0000000000 --- a/libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp +++ /dev/null @@ -1 +0,0 @@ -VERTEX simple diff --git a/libraries/render-utils/src/render-utils/web_browser.slp b/libraries/render-utils/src/render-utils/web_browser.slp new file mode 100644 index 0000000000..e9942be5cd --- /dev/null +++ b/libraries/render-utils/src/render-utils/web_browser.slp @@ -0,0 +1 @@ +DEFINES translucent:f/forward:f \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index 91c73e9eec..ab67447d04 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// sdf_text3D.frag -// fragment shader // // Created by Bradley Austin Davis on 2015-02-04 // Based on fragment shader code from @@ -10,12 +9,32 @@ // 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@> +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + <@include DefaultMaterials.slh@> + + <@include GlobalLight.slh@> + <@if HIFI_USE_FORWARD@> + <$declareEvalSkyboxGlobalColor()$> + <@else@> + <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <@endif@> + + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + layout(location=0) out vec4 _fragColor0; +<@else@> + <@include DeferredBufferWrite.slh@> +<@endif@> + <@include render-utils/ShaderConstants.h@> <@include sdf_text3D.slh@> <$declareEvalSDFSuperSampled()$> +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; +<@endif@> 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; @@ -23,15 +42,56 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord1 _texCoord01.zw void main() { - float a = evalSDFSuperSampled(_texCoord0); + float alpha = evalSDFSuperSampled(_texCoord0); + +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + alpha *= _color.a; + if (alpha <= 0.0) { + discard; + } + + TransformCamera cam = getTransformCamera(); + vec3 fragPosition = _positionES.xyz; + + <@if HIFI_USE_FORWARD@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + _color.rgb, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_ROUGHNESS), + alpha); + <@else@> + _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + _color.rgb, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE, + DEFAULT_ROUGHNESS, alpha), + alpha); + <@endif@> +<@else@> + if (alpha <= 0.0) { + discard; + } packDeferredFragment( normalize(_normalWS), - a, + alpha, _color.rgb, DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_EMISSIVE, DEFAULT_OCCLUSION, DEFAULT_SCATTERING); +<@endif@> } \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D.slv b/libraries/render-utils/src/sdf_text3D.slv index 274e09e6ad..731cbc2cad 100644 --- a/libraries/render-utils/src/sdf_text3D.slv +++ b/libraries/render-utils/src/sdf_text3D.slv @@ -19,20 +19,25 @@ <@include sdf_text3D.slh@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main() { - _texCoord01.xy = inTexCoord0.xy; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); _color = color_sRGBAToLinear(params.color); - - // standard transform + TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); +<@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> +<@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> +<@endif@> + const vec3 normal = vec3(0, 0, 1); <$transformModelToWorldDir(cam, obj, normal, _normalWS)$> } \ No newline at end of file diff --git a/libraries/render-utils/src/sdf_text3D_transparent.slf b/libraries/render-utils/src/sdf_text3D_transparent.slf deleted file mode 100644 index c4a80091de..0000000000 --- a/libraries/render-utils/src/sdf_text3D_transparent.slf +++ /dev/null @@ -1,58 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// sdf_text3D_transparent.frag -// fragment shader -// -// Created by Bradley Austin Davis on 2015-02-04 -// Based on fragment shader code from -// https://github.com/paulhoux/Cinder-Samples/blob/master/TextRendering/include/text/Text.cpp -// 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@> -<$declareEvalGlobalLightingAlphaBlended()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include render-utils/ShaderConstants.h@> - -<@include sdf_text3D.slh@> -<$declareEvalSDFSuperSampled()$> - -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() { - float a = evalSDFSuperSampled(_texCoord0); - - float alpha = a * _color.a; - if (alpha <= 0.0) { - discard; - } - - TransformCamera cam = getTransformCamera(); - vec3 fragPosition = _positionES.xyz; - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS), - _color.rgb, - DEFAULT_FRESNEL, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index 469c0976aa..5585c9a7d1 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple.frag -// fragment shader -// // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 High Fidelity, Inc. // @@ -12,133 +10,144 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -<@include DeferredBufferWrite.slh@> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - +<@include gpu/Color.slh@> +<@include DefaultMaterials.slh@> <@include render-utils/ShaderConstants.h@> -// the interpolated normal +<@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + <@if not HIFI_USE_UNLIT@> + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + <@else@> + <@include LightingModel.slh@> +<@endif@> + + layout(location=0) out vec4 _fragColor0; +<@endif@> + +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD@> + <@include GlobalLight.slh@> + <$declareEvalSkyboxGlobalColor()$> + <@elif HIFI_USE_TRANSLUCENT@> + <@include GlobalLight.slh@> + <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <@else@> + <@include DeferredBufferWrite.slh@> + <@endif@> +<@else@> + <@if not HIFI_USE_FORWARD@> + <@if not HIFI_USE_TRANSLUCENT@> + <@include DeferredBufferWrite.slh@> + <@endif@> + <@endif@> +<@endif@> + +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeFragmentInstanced()$> +<@endif@> + +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; + <@endif@> +<@endif@> +<@if HIFI_USE_FADE@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; +<@endif@> 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(binding=0) uniform sampler2D simpleTexture; -<@include procedural/ProceduralCommon.slh@> - -#line 1001 -//PROCEDURAL_BLOCK_BEGIN - -vec3 getProceduralColor() { - return _color.rgb; -} - -float getProceduralColors(inout vec3 diffuse, inout vec3 specular, inout float shininess) { - return 1.0; -} - -float getProceduralFragment(inout ProceduralFragment proceduralData) { - return 1.0; -} - -float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition proceduralData) { - return 1.0; -} - -//PROCEDURAL_BLOCK_END - -#line 2030 void main(void) { - vec3 normal = normalize(_normalWS.xyz); - vec3 diffuse = _color.rgb; - float roughness = DEFAULT_ROUGHNESS; - float metallic = DEFAULT_METALLIC; - vec3 emissive = DEFAULT_EMISSIVE; - float occlusion = DEFAULT_OCCLUSION; - float scattering = DEFAULT_SCATTERING; + vec4 texel = texture(simpleTexture, _texCoord0); + texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); + texel.rgb *= _color.rgb; + texel.a *= abs(_color.a); - float emissiveAmount = 0.0; +<@if HIFI_USE_FADE@> + vec3 fadeEmissive; + FadeObjectParams fadeParams; + <$fetchFadeObjectParamsInstanced(fadeParams)$> + applyFade(fadeParams, _positionWS.xyz, fadeEmissive); +<@endif@> -#if defined(PROCEDURAL_V1) - diffuse = getProceduralColor().rgb; - emissiveAmount = 1.0; - emissive = vec3(1.0); -#elif defined(PROCEDURAL_V2) - vec3 specular = DEFAULT_SPECULAR; - float shininess = DEFAULT_SHININESS; - emissiveAmount = getProceduralColors(diffuse, specular, shininess); - roughness = max(0.0, 1.0 - shininess / 128.0); - metallic = length(specular); - emissive = vec3(clamp(emissiveAmount, 0.0, 1.0)); -#elif defined(PROCEDURAL_V3) || defined(PROCEDURAL_V4) -#if defined(PROCEDURAL_V3) - ProceduralFragment proceduralData = ProceduralFragment( -#else - TransformCamera cam = getTransformCamera(); - vec4 position = cam._viewInverse * _positionES; - ProceduralFragmentWithPosition proceduralData = ProceduralFragmentWithPosition( - position.xyz, -#endif - normal, - diffuse, - DEFAULT_SPECULAR, - emissive, - 1.0, - roughness, - metallic, - occlusion, - scattering - ); +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + float metallic = DEFAULT_METALLIC; + vec3 fresnel = getFresnelF0(metallic, texel.rgb); -#if defined(PROCEDURAL_V3) - emissiveAmount = getProceduralFragment(proceduralData); -#else - emissiveAmount = getProceduralFragmentWithPosition(proceduralData); -#endif - normal = proceduralData.normal; - diffuse = proceduralData.diffuse; - roughness = proceduralData.roughness; - metallic = proceduralData.metallic; - emissive = proceduralData.emissive; - occlusion = proceduralData.occlusion; - scattering = proceduralData.scattering; + TransformCamera cam = getTransformCamera(); + vec3 fragPosition = _positionES.xyz; + <@endif@> +<@endif@> -#if defined(PROCEDURAL_V4) - position = vec4(proceduralData.position, 1.0); - vec4 posClip = cam._projection * (cam._view * position); - gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0); -#endif - -#endif - - if (emissiveAmount > 0.0) { - packDeferredFragmentLightmap( - normal, +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, 1.0, - diffuse, - roughness, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + texel.rgb, + fresnel, metallic, - emissive); - } else { + DEFAULT_ROUGHNESS), + texel.a); + <@elif HIFI_USE_TRANSLUCENT@> + _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + texel.rgb, + fresnel, + metallic, + DEFAULT_EMISSIVE + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + DEFAULT_ROUGHNESS, texel.a), + texel.a); + <@else@> packDeferredFragment( - normal, + normalize(_normalWS), 1.0, - diffuse, - roughness, - metallic, - emissive, - occlusion, - scattering); - } + texel.rgb, + DEFAULT_ROUGHNESS, + DEFAULT_METALLIC, + DEFAULT_EMISSIVE + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , + DEFAULT_OCCLUSION, + DEFAULT_SCATTERING); + <@endif@> +<@else@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + _fragColor0 = isUnlitEnabled() * vec4(texel.rgb + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + , texel.a); + <@else@> + packDeferredFragmentUnlit( + normalize(_normalWS), + 1.0, + texel.rgb + <@if HIFI_USE_FADE@> + + fadeEmissive + <@endif@> + ); + <@endif@> +<@endif@> } diff --git a/libraries/render-utils/src/simple.slv b/libraries/render-utils/src/simple.slv index 460ed53281..f766acceda 100644 --- a/libraries/render-utils/src/simple.slv +++ b/libraries/render-utils/src/simple.slv @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple.vert -// vertex shader -// // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 High Fidelity, Inc. // @@ -19,22 +17,36 @@ <@include render-utils/ShaderConstants.h@> +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; + <@endif@> +<@endif@> +<@if HIFI_USE_FADE@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +<@endif@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; -layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord01.xy = inTexCoord0.st; - _positionMS = inPosition; - _normalMS = inNormal.xyz; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); - <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> +<@if not HIFI_USE_UNLIT@> + <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> + <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> + <@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + <@endif@> +<@else@> + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> +<@endif@> + +<@if HIFI_USE_FADE@> + <$transformModelToWorldPos(obj, inPosition, _positionWS)$> +<@endif@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> } \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent.slf b/libraries/render-utils/src/simple_procedural.slf similarity index 79% rename from libraries/render-utils/src/simple_transparent.slf rename to libraries/render-utils/src/simple_procedural.slf index 6d8348f50c..ef588c4651 100644 --- a/libraries/render-utils/src/simple_transparent.slf +++ b/libraries/render-utils/src/simple_procedural.slf @@ -1,37 +1,39 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple_transparent.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 DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> +<@if not HIFI_USE_TRANSLUCENT@> + <@include DeferredBufferWrite.slh@> +<@else@> + <@include DefaultMaterials.slh@> + + <@include GlobalLight.slh@> + <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + + layout(location=0) out vec4 _fragColor0; +<@endif@> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> <@include render-utils/ShaderConstants.h@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; +layout(location=RENDER_UTILS_ATTR_POSITION_MS) in vec4 _positionMS; +layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; layout(location=RENDER_UTILS_ATTR_NORMAL_MS) in vec3 _normalMS; +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_MS) in vec4 _positionMS; -layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; - -layout(location=0) out vec4 _fragColor0; // For retro-compatibility #define _normal _normalWS @@ -42,7 +44,6 @@ layout(location=0) out vec4 _fragColor0; <@include procedural/ProceduralCommon.slh@> #line 1001 - //PROCEDURAL_BLOCK_BEGIN vec3 getProceduralColor() { @@ -67,19 +68,24 @@ float getProceduralFragmentWithPosition(inout ProceduralFragmentWithPosition pro void main(void) { vec3 normal = normalize(_normalWS.xyz); vec3 diffuse = _color.rgb; - float alpha = _color.a; - float occlusion = DEFAULT_OCCLUSION; vec3 fresnel = DEFAULT_FRESNEL; + float roughness = DEFAULT_ROUGHNESS; float metallic = DEFAULT_METALLIC; vec3 emissive = DEFAULT_EMISSIVE; - float roughness = DEFAULT_ROUGHNESS; + float occlusion = DEFAULT_OCCLUSION; + float scattering = DEFAULT_SCATTERING; float emissiveAmount = 0.0; +<@if HIFI_USE_TRANSLUCENT@> + float alpha = _color.a; TransformCamera cam = getTransformCamera(); vec3 posEye = _positionES.xyz; +<@else@> + float alpha = 1.0; +<@endif@> -#ifdef PROCEDURAL_V1 +#if defined(PROCEDURAL_V1) diffuse = getProceduralColor().rgb; emissiveAmount = 1.0; emissive = vec3(1.0); @@ -94,6 +100,7 @@ void main(void) { #if defined(PROCEDURAL_V3) ProceduralFragment proceduralData = ProceduralFragment( #else + TransformCamera cam = getTransformCamera(); vec4 position = cam._viewInverse * _positionES; ProceduralFragmentWithPosition proceduralData = ProceduralFragmentWithPosition( position.xyz, @@ -106,7 +113,7 @@ void main(void) { roughness, metallic, occlusion, - DEFAULT_SCATTERING + scattering ); #if defined(PROCEDURAL_V3) @@ -114,25 +121,49 @@ void main(void) { #else emissiveAmount = getProceduralFragmentWithPosition(proceduralData); #endif - occlusion = proceduralData.occlusion; normal = proceduralData.normal; diffuse = proceduralData.diffuse; fresnel = proceduralData.specular; + roughness = proceduralData.roughness; metallic = proceduralData.metallic; emissive = proceduralData.emissive; - roughness = proceduralData.roughness; + occlusion = proceduralData.occlusion; + scattering = proceduralData.scattering; alpha = proceduralData.alpha; #if defined(PROCEDURAL_V4) position = vec4(proceduralData.position, 1.0); vec4 posEye4 = cam._view * position; +<@if HIFI_USE_TRANSLUCENT@> posEye = posEye4.xyz; +<@endif@> vec4 posClip = cam._projection * posEye4; gl_FragDepth = 0.5 * (posClip.z / posClip.w + 1.0); #endif #endif +<@if not HIFI_USE_TRANSLUCENT@> + if (emissiveAmount > 0.0) { + packDeferredFragmentLightmap( + normal, + 1.0, + diffuse, + roughness, + metallic, + emissive); + } else { + packDeferredFragment( + normal, + 1.0, + diffuse, + roughness, + metallic, + emissive, + occlusion, + scattering); + } +<@else@> if (emissiveAmount > 0.0) { _fragColor0 = vec4(diffuse, alpha); } else { @@ -149,4 +180,5 @@ void main(void) { roughness, alpha), alpha); } +<@endif@> } diff --git a/libraries/render-utils/src/simple_fade.slv b/libraries/render-utils/src/simple_procedural.slv similarity index 70% rename from libraries/render-utils/src/simple_fade.slv rename to libraries/render-utils/src/simple_procedural.slv index 0bbd8eac39..181afa50bd 100644 --- a/libraries/render-utils/src/simple_fade.slv +++ b/libraries/render-utils/src/simple_procedural.slv @@ -1,12 +1,10 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> // -// simple_fade.vert -// vertex shader -// -// Created by Olivier Prat on 06/04/17. -// Copyright 2017 High Fidelity, Inc. +// 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 @@ -17,31 +15,23 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -<@include Fade.slh@> -<$declareFadeVertexInstanced()$> - <@include render-utils/ShaderConstants.h@> -// the interpolated normal -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; -layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; -layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; -layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; layout(location=RENDER_UTILS_ATTR_POSITION_MS) out vec4 _positionMS; layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; -layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +layout(location=RENDER_UTILS_ATTR_NORMAL_MS) out vec3 _normalMS; +layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; void main(void) { _color = color_sRGBAToLinear(inColor); - _texCoord01.xy = inTexCoord0.st; + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); _positionMS = inPosition; _normalMS = inNormal.xyz; - // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); <$transformModelToEyeAndClipPos(cam, obj, inPosition, _positionES, gl_Position)$> - <$transformModelToWorldPos(obj, inPosition, _positionWS)$> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> - <$passThroughFadeObjectParams()$> } \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured.slf b/libraries/render-utils/src/simple_textured.slf deleted file mode 100644 index dbc49fcb5d..0000000000 --- a/libraries/render-utils/src/simple_textured.slf +++ /dev/null @@ -1,44 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured.frag -// fragment shader -// -// Created by Clement 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 DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -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 - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - - packDeferredFragment( - normalize(_normalWS), - 1.0, - texel.rgb, - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_fade.slf b/libraries/render-utils/src/simple_textured_fade.slf deleted file mode 100644 index 5a9eb0688e..0000000000 --- a/libraries/render-utils/src/simple_textured_fade.slf +++ /dev/null @@ -1,66 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -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_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS), - texel.a, - texel.rgb + fadeEmissive, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragment( - normalize(_normalWS), - 1.0, - texel.rgb, - DEFAULT_ROUGHNESS, - DEFAULT_METALLIC, - DEFAULT_EMISSIVE + fadeEmissive, - DEFAULT_OCCLUSION, - DEFAULT_SCATTERING); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_unlit.slf b/libraries/render-utils/src/simple_textured_unlit.slf deleted file mode 100644 index 475428f0ae..0000000000 --- a/libraries/render-utils/src/simple_textured_unlit.slf +++ /dev/null @@ -1,49 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_unlit.frag -// fragment shader -// -// Created by Clement 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 DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -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 - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS), - texel.a, - texel.rgb, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragmentUnlit( - normalize(_normalWS), - 1.0, - texel.rgb); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_textured_unlit_fade.slf b/libraries/render-utils/src/simple_textured_unlit_fade.slf deleted file mode 100644 index d0ba4c13fe..0000000000 --- a/libraries/render-utils/src/simple_textured_unlit_fade.slf +++ /dev/null @@ -1,61 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_textured_unlit_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -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_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - const float ALPHA_THRESHOLD = 0.999; - if (texel.a < ALPHA_THRESHOLD) { - packDeferredFragmentTranslucent( - normalize(_normalWS), - texel.a, - texel.rgb + fadeEmissive, - DEFAULT_ROUGHNESS); - } else { - packDeferredFragmentUnlit( - normalize(_normalWS), - 1.0, - texel.rgb + fadeEmissive); - } -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured.slf b/libraries/render-utils/src/simple_transparent_textured.slf deleted file mode 100644 index 9f8a88c7c2..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured.slf +++ /dev/null @@ -1,60 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured.frag -// fragment shader -// -// Created by Sam Gateau on 4/3/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 gpu/Color.slh@> -<@include render-utils/ShaderConstants.h@> - -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -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), - albedo, - fresnel, - metallic, - DEFAULT_EMISSIVE, - DEFAULT_ROUGHNESS, alpha), - alpha); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_fade.slf b/libraries/render-utils/src/simple_transparent_textured_fade.slf deleted file mode 100644 index d401989f90..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_fade.slf +++ /dev/null @@ -1,72 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Color.slh@> - -<@include DeferredBufferWrite.slh@> -<@include DeferredGlobalLight.slh@> -<$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - -<@include gpu/Transform.slh@> -<$declareStandardCameraTransform()$> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -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=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - vec3 fragPosition = _positionES.xyz; - vec3 fragNormal = normalize(_normalWS); - - TransformCamera cam = getTransformCamera(); - - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( - cam._viewInverse, - 1.0, - 1.0, - fragPosition, - fragNormal, - texel.rgb, - DEFAULT_FRESNEL, - 0.0f, - fadeEmissive, - DEFAULT_ROUGHNESS, - texel.a), - texel.a); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit.slf b/libraries/render-utils/src/simple_transparent_textured_unlit.slf deleted file mode 100644 index 42a8270274..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_unlit.slf +++ /dev/null @@ -1,36 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_unlit.frag -// fragment shader -// -// Created by Sam Gateau on 4/3/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Color.slh@> - -<@include render-utils/ShaderConstants.h@> - -// 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 - -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)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - _fragColor0 = texel; -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf b/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf deleted file mode 100644 index afc0c94575..0000000000 --- a/libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf +++ /dev/null @@ -1,48 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_textured_unlit_fade.frag -// fragment shader -// -// Created by Olivier Prat on 06/05/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -<@include gpu/Color.slh@> - -<@include Fade.slh@> - -<@include render-utils/ShaderConstants.h@> - -// 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 -layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; - -layout(location=0) out vec4 _fragColor0; - -// Declare after all samplers to prevent sampler location mix up with originalTexture -<$declareFadeFragmentInstanced()$> - -void main(void) { - vec3 fadeEmissive; - FadeObjectParams fadeParams; - - <$fetchFadeObjectParamsInstanced(fadeParams)$> - applyFade(fadeParams, _positionWS.xyz, fadeEmissive); - - vec4 texel = texture(originalTexture, _texCoord0); - texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); - texel.rgb *= _color.rgb; - texel.a *= abs(_color.a); - - _fragColor0 = vec4(texel.rgb + fadeEmissive, texel.a); -} \ No newline at end of file diff --git a/libraries/render-utils/src/simple_transparent_web_browser.slf b/libraries/render-utils/src/simple_transparent_web_browser.slf deleted file mode 100644 index 599fd3d87f..0000000000 --- a/libraries/render-utils/src/simple_transparent_web_browser.slf +++ /dev/null @@ -1,38 +0,0 @@ -<@include gpu/Config.slh@> -<$VERSION_HEADER$> -// Generated on <$_SCRIBE_DATE$> -// -// simple_transparent_web_browser.frag -// fragment shader -// -// Created by Anthony Thibault on 7/25/16. -// 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 gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - -<@include render-utils/ShaderConstants.h@> - -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; - -// the interpolated normal -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 - -void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); - texel = color_sRGBAToLinear(texel); - packDeferredFragmentTranslucent( - normalize(_normalWS), - _color.a * texel.a, - _color.rgb * texel.rgb, - DEFAULT_ROUGHNESS); -} diff --git a/libraries/render-utils/src/text/Font.cpp b/libraries/render-utils/src/text/Font.cpp index c69db5e055..eec65ddf44 100644 --- a/libraries/render-utils/src/text/Font.cpp +++ b/libraries/render-utils/src/text/Font.cpp @@ -233,7 +233,7 @@ void Font::setupGPU() { gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); PrepareStencil::testMaskDrawShape(*state); _deferredPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D), state); - _forwardPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::forward_sdf_text3D), state); + _forwardPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D_forward), state); } { @@ -244,7 +244,7 @@ void Font::setupGPU() { 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::testMask(*state); - _transparentPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D_transparent), state); + _transparentPipeline = gpu::Pipeline::create(gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D_translucent), state); } } diff --git a/libraries/render-utils/src/simple_opaque_web_browser.slf b/libraries/render-utils/src/web_browser.slf similarity index 54% rename from libraries/render-utils/src/simple_opaque_web_browser.slf rename to libraries/render-utils/src/web_browser.slf index df789ee22b..7898df1c4c 100644 --- a/libraries/render-utils/src/simple_opaque_web_browser.slf +++ b/libraries/render-utils/src/web_browser.slf @@ -1,10 +1,8 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// simple_opaque_web_browser.frag -// fragment shader -// // Created by Anthony Thibault on 7/25/16. // Copyright 2016 High Fidelity, Inc. // @@ -13,14 +11,16 @@ // <@include gpu/Color.slh@> -<@include DeferredBufferWrite.slh@> - <@include render-utils/ShaderConstants.h@> -// the albedo texture -LAYOUT(binding=0) uniform sampler2D originalTexture; +<@if not HIFI_USE_FORWARD@> + <@include DeferredBufferWrite.slh@> +<@else@> + layout(location=0) out vec4 _fragColor0; +<@endif@> + +LAYOUT(binding=0) uniform sampler2D webTexture; -// the interpolated normal 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; @@ -28,7 +28,17 @@ layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord1 _texCoord01.zw void main(void) { - vec4 texel = texture(originalTexture, _texCoord0); + vec4 texel = texture(webTexture, _texCoord0); texel = color_sRGBAToLinear(texel); - packDeferredFragmentUnlit(normalize(_normalWS), 1.0, _color.rgb * texel.rgb); + texel *= _color; + +<@if not HIFI_USE_FORWARD@> + <@if not HIFI_USE_TRANSLUCENT@> + packDeferredFragmentUnlit(normalize(_normalWS), 1.0, texel.rgb); + <@else@> + packDeferredFragmentTranslucent(normalize(_normalWS), texel.a, texel.rgb, DEFAULT_ROUGHNESS); + <@endif@> +<@else@> + _fragColor0 = texel; +<@endif@> } diff --git a/libraries/render-utils/src/web_browser.slv b/libraries/render-utils/src/web_browser.slv new file mode 100644 index 0000000000..019486fbf3 --- /dev/null +++ b/libraries/render-utils/src/web_browser.slv @@ -0,0 +1,32 @@ +<@include gpu/Config.slh@> +<$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> +// Generated on <$_SCRIBE_DATE$> +// +// 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 gpu/Inputs.slh@> +<@include gpu/Color.slh@> +<@include gpu/Transform.slh@> +<$declareStandardTransform()$> + +<@include render-utils/ShaderConstants.h@> + +layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; +layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; + +void main(void) { + _color = color_sRGBAToLinear(inColor); + _texCoord01 = vec4(inTexCoord0.st, 0.0, 0.0); + + TransformCamera cam = getTransformCamera(); + TransformObject obj = getTransformObject(); + <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> +} \ No newline at end of file diff --git a/tools/shadergen.py b/tools/shadergen.py index f82b471f17..1f4acae915 100644 --- a/tools/shadergen.py +++ b/tools/shadergen.py @@ -66,7 +66,6 @@ def getExtensionsHeader(dialect, variant, extensions): extensionsHeaderMutex.release() return extensionHeader - def getDialectAndVariantHeaders(dialect, variant, extensions=None): result = [] headerPath = args.source_dir + '/libraries/shaders/headers/' @@ -80,6 +79,14 @@ def getDialectAndVariantHeaders(dialect, variant, extensions=None): result.append(variantHeader) return result +def getDefines(defines): + definesList = [] + if defines: + definesSplit = defines.split("_") + for define in definesSplit: + definesList.append('HIFI_USE_{} 1'.format(define.upper())) + return definesList + class ScribeDependenciesCache: cache = {} lock = Lock() @@ -99,9 +106,9 @@ class ScribeDependenciesCache: with open(self.filename, "w") as f: f.write(json.dumps(self.cache)) - def get(self, scribefile, dialect, variant): + def get(self, scribefile, dialect, variant, defines): self.lock.acquire() - key = self.key(scribefile, dialect, variant) + key = self.key(scribefile, dialect, variant, defines) try: if key in self.cache: return self.cache[key].copy() @@ -109,25 +116,26 @@ class ScribeDependenciesCache: self.lock.release() return None - def key(self, scribeFile, dialect, variant): - return ':'.join([scribeFile, dialect, variant]) + def key(self, scribeFile, dialect, variant, defines): + return ':'.join([scribeFile, dialect, variant, defines]) - def getOrGen(self, scribefile, includeLibs, dialect, variant): - result = self.get(scribefile, dialect, variant) - if (None == result): - result = self.gen(scribefile, includeLibs, dialect, variant) + def getOrGen(self, scribefile, includeLibs, dialect, variant, defines): + result = self.get(scribefile, dialect, variant, defines) + if result is None: + result = self.gen(scribefile, includeLibs, dialect, variant, defines) return result - def gen(self, scribefile, includeLibs, dialect, variant): + def gen(self, scribefile, includeLibs, dialect, variant, defines): scribeArgs = getCommonScribeArgs(scribefile, includeLibs) scribeArgs.extend(['-M']) processResult = subprocess.run(scribeArgs, stdout=subprocess.PIPE) if (0 != processResult.returncode): - raise RuntimeError("Unable to parse scribe dependencies") + raise RuntimeError("Unable to parse scribe dependencies for file {} with defines: {}".format(scribefile, defines)) result = processResult.stdout.decode("utf-8").splitlines(False) result.append(scribefile) result.extend(getDialectAndVariantHeaders(dialect, variant)) - key = self.key(scribefile, dialect, variant) + result.extend(getDefines(defines)) + key = self.key(scribefile, dialect, variant, defines) self.lock.acquire() self.cache[key] = result.copy() self.lock.release() @@ -166,6 +174,10 @@ def processCommand(line): variant = params.pop(0) scribeFile = args.source_dir + '/' + params.pop(0) unoptGlslFile = args.source_dir + '/' + params.pop(0) + defines = "" + if len(params) > 1 and params[0].startswith("defines:"): + defines = params.pop(0) + defines = defines[len("defines:"):] libs = params upoptSpirvFile = unoptGlslFile + '.spv' @@ -184,19 +196,23 @@ def processCommand(line): os.makedirs(scribeOutputDir) folderMutex.release() - scribeDeps = scribeDepCache.getOrGen(scribeFile, libs, dialect, variant) + scribeDeps = scribeDepCache.getOrGen(scribeFile, libs, dialect, variant, defines) # if the scribe sources (slv, slf, slh, etc), or the dialect/ variant headers are out of date # regenerate the scribe GLSL output if args.force or outOfDate(scribeDeps, outputFiles): - print('Processing file {} dialect {} variant {}'.format(scribeFile, dialect, variant)) + print('Processing file {} dialect {} variant {} defines {}'.format(scribeFile, dialect, variant, defines)) if args.dry_run: return True - scribeDepCache.gen(scribeFile, libs, dialect, variant) + scribeDepCache.gen(scribeFile, libs, dialect, variant, defines) scribeArgs = getCommonScribeArgs(scribeFile, libs) for header in getDialectAndVariantHeaders(dialect, variant, args.extensions): scribeArgs.extend(['-H', header]) + for define in getDefines(defines): + defineArgs = ['-D'] + defineArgs.extend(define.split(' ')) + scribeArgs.extend(defineArgs) scribeArgs.extend(['-o', unoptGlslFile]) executeSubprocess(scribeArgs)