From 6111c8a108bc59b50a15e4f9ae0bebe7f7c8c19c Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 3 Jun 2019 19:11:11 -0700 Subject: [PATCH 01/10] initial work on combining shader variants --- cmake/macros/AutoScribeShader.cmake | 160 +++++++- interface/src/raypick/ParabolaPointer.cpp | 2 +- .../src/RenderableShapeEntityItem.cpp | 9 +- .../src/RenderableWebEntityItem.cpp | 9 +- .../src/entities-renderer/paintStroke.slp | 1 + .../entities-renderer/paintStroke_forward.slp | 1 - .../src/entities-renderer/polyvox.slp | 1 + .../src/entities-renderer/polyvox_fade.slp | 0 .../entities-renderer/src/paintStroke.slf | 30 +- .../entities-renderer/src/paintStroke.slv | 9 +- .../src/paintStroke_forward.slf | 35 -- libraries/entities-renderer/src/polyvox.slf | 130 +++++-- libraries/entities-renderer/src/polyvox.slv | 40 +- .../entities-renderer/src/polyvox_fade.slf | 73 ---- .../entities-renderer/src/polyvox_fade.slv | 33 -- .../render-utils/src/ForwardGlobalLight.slh | 247 ------------ libraries/render-utils/src/GeometryCache.cpp | 75 ++-- libraries/render-utils/src/GeometryCache.h | 10 +- ...eferredGlobalLight.slh => GlobalLight.slh} | 58 ++- .../render-utils/src/RenderPipelines.cpp | 352 +++++++++--------- libraries/render-utils/src/deferred_light.slv | 2 +- libraries/render-utils/src/deformed_model.slv | 56 --- .../render-utils/src/deformed_model_dq.slv | 53 --- .../src/deformed_model_normal_map.slv | 56 --- .../src/deformed_model_normal_map_dq.slv | 57 --- .../src/deformed_model_shadow.slv | 52 --- .../src/deformed_model_shadow_dq.slv | 51 --- .../src/directional_ambient_light.slf | 2 +- .../src/directional_ambient_light_shadow.slf | 2 +- .../src/directional_skybox_light.slf | 2 +- .../src/directional_skybox_light_shadow.slf | 2 +- libraries/render-utils/src/forward_grid.slf | 40 -- .../src/forward_grid_translucent.slf | 41 -- libraries/render-utils/src/forward_model.slf | 83 ----- .../src/forward_model_lightmap.slf | 71 ---- .../src/forward_model_normal_map.slf | 85 ----- .../src/forward_model_normal_map_lightmap.slf | 74 ---- .../src/forward_model_translucent.slf | 81 ---- .../render-utils/src/forward_model_unlit.slf | 42 --- .../render-utils/src/forward_parabola.slf | 18 - .../render-utils/src/forward_sdf_text3D.slf | 57 --- libraries/render-utils/src/forward_simple.slf | 61 --- .../src/forward_simple_textured.slf | 58 --- .../forward_simple_textured_transparent.slf | 60 --- .../src/forward_simple_textured_unlit.slf | 35 -- libraries/render-utils/src/glowLine.slf | 34 -- libraries/render-utils/src/glowLine.slv | 61 --- libraries/render-utils/src/grid.slf | 23 +- .../render-utils/src/grid_translucent.slf | 41 -- libraries/render-utils/src/hmd_ui.slv | 2 +- libraries/render-utils/src/model.slf | 322 ++++++++++++++-- libraries/render-utils/src/model.slv | 106 ++++-- libraries/render-utils/src/model_fade.slf | 73 ---- libraries/render-utils/src/model_lightmap.slf | 50 --- .../render-utils/src/model_lightmap_fade.slf | 59 --- .../src/model_lightmap_normal_map.slf | 55 --- .../src/model_lightmap_normal_map_fade.slf | 64 ---- .../render-utils/src/model_normal_map.slf | 69 ---- .../render-utils/src/model_normal_map.slv | 45 --- .../src/model_normal_map_fade.slf | 78 ---- libraries/render-utils/src/model_shadow.slf | 34 -- libraries/render-utils/src/model_shadow.slv | 42 --- .../render-utils/src/model_shadow_fade.slf | 42 --- .../render-utils/src/model_translucent.slf | 96 ----- .../src/model_translucent_fade.slf | 104 ------ .../src/model_translucent_normal_map.slf | 98 ----- .../src/model_translucent_normal_map_fade.slf | 106 ------ .../src/model_translucent_unlit.slf | 42 --- .../src/model_translucent_unlit_fade.slf | 52 --- libraries/render-utils/src/model_unlit.slf | 45 --- .../render-utils/src/model_unlit_fade.slf | 55 --- libraries/render-utils/src/parabola.slf | 17 +- .../render-utils/src/parabola_translucent.slf | 18 - .../src/render-utils/deformed_model.slp | 2 - .../src/render-utils/deformed_model_dq.slp | 2 - .../src/render-utils/deformed_model_fade.slp | 2 - .../render-utils/deformed_model_fade_dq.slp | 2 - .../deformed_model_normal_map.slp | 2 - .../deformed_model_normal_map_dq.slp | 2 - .../deformed_model_normal_map_fade.slp | 2 - .../deformed_model_normal_map_fade_dq.slp | 2 - .../deformed_model_normal_map_translucent.slp | 2 - ...formed_model_normal_map_translucent_dq.slp | 2 - ...rmed_model_normal_map_translucent_fade.slp | 2 - ...d_model_normal_map_translucent_fade_dq.slp | 2 - .../render-utils/deformed_model_shadow.slp | 2 - .../render-utils/deformed_model_shadow_dq.slp | 2 - .../deformed_model_shadow_fade.slp | 2 - .../deformed_model_shadow_fade_dq.slp | 2 - .../deformed_model_translucent.slp | 2 - .../deformed_model_translucent_dq.slp | 2 - .../deformed_model_translucent_fade.slp | 2 - .../deformed_model_translucent_fade_dq.slp | 2 - .../render-utils/forward_deformed_model.slp | 2 - .../forward_deformed_model_dq.slp | 2 - .../forward_deformed_model_normal_map.slp | 2 - .../forward_deformed_model_normal_map_dq.slp | 2 - .../forward_deformed_translucent.slp | 2 - .../forward_deformed_translucent_dq.slp | 2 - ...orward_deformed_translucent_normal_map.slp | 2 - ...ard_deformed_translucent_normal_map_dq.slp | 2 - .../src/render-utils/forward_grid.slp | 1 - .../render-utils/forward_grid_translucent.slp | 1 - .../src/render-utils/forward_model.slp | 1 - .../render-utils/forward_model_lightmap.slp | 1 - .../render-utils/forward_model_normal_map.slp | 1 - .../forward_model_normal_map_lightmap.slp | 1 - .../forward_model_normal_map_translucent.slp | 2 - .../forward_model_translucent.slp | 1 - .../src/render-utils/forward_model_unlit.slp | 1 - .../src/render-utils/forward_parabola.slp | 1 - .../src/render-utils/forward_sdf_text3D.slp | 1 - .../render-utils/forward_simple_textured.slp | 1 - .../forward_simple_textured_transparent.slp | 1 - .../forward_simple_textured_unlit.slp | 1 - .../src/render-utils/glowLine.slp | 0 .../render-utils/src/render-utils/grid.slp | 1 + .../src/render-utils/grid_translucent.slp | 1 - .../render-utils/src/render-utils/model.slp | 1 + .../src/render-utils/model_fade.slp | 1 - .../src/render-utils/model_lightmap.slp | 1 - .../src/render-utils/model_lightmap_fade.slp | 1 - .../model_lightmap_normal_map.slp | 1 - .../model_lightmap_normal_map_fade.slp | 1 - .../src/render-utils/model_normal_map.slp | 0 .../render-utils/model_normal_map_fade.slp | 1 - .../src/render-utils/model_shadow.slp | 0 .../src/render-utils/model_shadow_fade.slp | 1 - .../src/render-utils/model_translucent.slp | 1 - .../render-utils/model_translucent_fade.slp | 1 - .../model_translucent_normal_map.slp | 1 - .../model_translucent_normal_map_fade.slp | 1 - .../render-utils/model_translucent_unlit.slp | 1 - .../model_translucent_unlit_fade.slp | 1 - .../src/render-utils/model_unlit.slp | 1 - .../src/render-utils/model_unlit_fade.slp | 1 - .../src/render-utils/parabola.slp | 1 + .../src/render-utils/parabola_translucent.slp | 1 - .../src/render-utils/sdf_text3D.slp | 1 + .../render-utils/sdf_text3D_transparent.slp | 1 - .../render-utils/src/render-utils/simple.slp | 1 + .../simple_opaque_web_browser.slp | 1 - .../src/render-utils/simple_procedural.slp | 1 + .../src/render-utils/simple_textured.slp | 1 - .../src/render-utils/simple_textured_fade.slp | 1 - .../render-utils/simple_textured_unlit.slp | 1 - .../simple_textured_unlit_fade.slp | 1 - .../src/render-utils/simple_transparent.slp | 1 - .../simple_transparent_textured.slp | 1 - .../simple_transparent_textured_fade.slp | 1 - .../simple_transparent_textured_unlit.slp | 1 - ...simple_transparent_textured_unlit_fade.slp | 1 - .../simple_transparent_web_browser.slp | 1 - .../src/render-utils/web_browser.slp | 1 + libraries/render-utils/src/sdf_text3D.slf | 70 +++- libraries/render-utils/src/sdf_text3D.slv | 15 +- .../src/sdf_text3D_transparent.slf | 58 --- libraries/render-utils/src/simple.slf | 237 ++++++------ libraries/render-utils/src/simple.slv | 34 +- ..._transparent.slf => simple_procedural.slf} | 72 +++- ...{simple_fade.slv => simple_procedural.slv} | 28 +- .../render-utils/src/simple_textured.slf | 44 --- .../render-utils/src/simple_textured_fade.slf | 66 ---- .../src/simple_textured_unlit.slf | 49 --- .../src/simple_textured_unlit_fade.slf | 61 --- .../src/simple_transparent_textured.slf | 60 --- .../src/simple_transparent_textured_fade.slf | 72 ---- .../src/simple_transparent_textured_unlit.slf | 36 -- ...simple_transparent_textured_unlit_fade.slf | 48 --- .../src/simple_transparent_web_browser.slf | 38 -- libraries/render-utils/src/text/Font.cpp | 4 +- ...opaque_web_browser.slf => web_browser.slf} | 30 +- libraries/render-utils/src/web_browser.slv | 32 ++ tools/shadergen.py | 46 ++- 174 files changed, 1356 insertions(+), 4100 deletions(-) delete mode 100644 libraries/entities-renderer/src/entities-renderer/paintStroke_forward.slp delete mode 100644 libraries/entities-renderer/src/entities-renderer/polyvox_fade.slp delete mode 100644 libraries/entities-renderer/src/paintStroke_forward.slf delete mode 100644 libraries/entities-renderer/src/polyvox_fade.slf delete mode 100644 libraries/entities-renderer/src/polyvox_fade.slv delete mode 100644 libraries/render-utils/src/ForwardGlobalLight.slh rename libraries/render-utils/src/{DeferredGlobalLight.slh => GlobalLight.slh} (86%) delete mode 100644 libraries/render-utils/src/deformed_model.slv delete mode 100644 libraries/render-utils/src/deformed_model_dq.slv delete mode 100644 libraries/render-utils/src/deformed_model_normal_map.slv delete mode 100644 libraries/render-utils/src/deformed_model_normal_map_dq.slv delete mode 100644 libraries/render-utils/src/deformed_model_shadow.slv delete mode 100644 libraries/render-utils/src/deformed_model_shadow_dq.slv delete mode 100644 libraries/render-utils/src/forward_grid.slf delete mode 100644 libraries/render-utils/src/forward_grid_translucent.slf delete mode 100644 libraries/render-utils/src/forward_model.slf delete mode 100644 libraries/render-utils/src/forward_model_lightmap.slf delete mode 100644 libraries/render-utils/src/forward_model_normal_map.slf delete mode 100644 libraries/render-utils/src/forward_model_normal_map_lightmap.slf delete mode 100644 libraries/render-utils/src/forward_model_translucent.slf delete mode 100644 libraries/render-utils/src/forward_model_unlit.slf delete mode 100644 libraries/render-utils/src/forward_parabola.slf delete mode 100644 libraries/render-utils/src/forward_sdf_text3D.slf delete mode 100644 libraries/render-utils/src/forward_simple.slf delete mode 100644 libraries/render-utils/src/forward_simple_textured.slf delete mode 100644 libraries/render-utils/src/forward_simple_textured_transparent.slf delete mode 100644 libraries/render-utils/src/forward_simple_textured_unlit.slf delete mode 100644 libraries/render-utils/src/glowLine.slf delete mode 100644 libraries/render-utils/src/glowLine.slv delete mode 100644 libraries/render-utils/src/grid_translucent.slf delete mode 100644 libraries/render-utils/src/model_fade.slf delete mode 100644 libraries/render-utils/src/model_lightmap.slf delete mode 100644 libraries/render-utils/src/model_lightmap_fade.slf delete mode 100644 libraries/render-utils/src/model_lightmap_normal_map.slf delete mode 100644 libraries/render-utils/src/model_lightmap_normal_map_fade.slf delete mode 100644 libraries/render-utils/src/model_normal_map.slf delete mode 100644 libraries/render-utils/src/model_normal_map.slv delete mode 100644 libraries/render-utils/src/model_normal_map_fade.slf delete mode 100644 libraries/render-utils/src/model_shadow.slf delete mode 100644 libraries/render-utils/src/model_shadow.slv delete mode 100644 libraries/render-utils/src/model_shadow_fade.slf delete mode 100644 libraries/render-utils/src/model_translucent.slf delete mode 100644 libraries/render-utils/src/model_translucent_fade.slf delete mode 100644 libraries/render-utils/src/model_translucent_normal_map.slf delete mode 100644 libraries/render-utils/src/model_translucent_normal_map_fade.slf delete mode 100644 libraries/render-utils/src/model_translucent_unlit.slf delete mode 100644 libraries/render-utils/src/model_translucent_unlit_fade.slf delete mode 100644 libraries/render-utils/src/model_unlit.slf delete mode 100644 libraries/render-utils/src/model_unlit_fade.slf delete mode 100644 libraries/render-utils/src/parabola_translucent.slf delete mode 100644 libraries/render-utils/src/render-utils/deformed_model.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_fade_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_fade_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_normal_map_translucent_fade_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_shadow.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_shadow_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_shadow_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_shadow_fade_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_translucent_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_translucent_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/deformed_model_translucent_fade_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_model.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_model_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_model_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_model_normal_map_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_translucent_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_deformed_translucent_normal_map_dq.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_grid.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_grid_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_lightmap.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_normal_map_lightmap.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_normal_map_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_model_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_parabola.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_sdf_text3D.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_simple_textured.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_simple_textured_transparent.slp delete mode 100644 libraries/render-utils/src/render-utils/forward_simple_textured_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/glowLine.slp delete mode 100644 libraries/render-utils/src/render-utils/grid_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/model_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_lightmap.slp delete mode 100644 libraries/render-utils/src/render-utils/model_lightmap_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_lightmap_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/model_lightmap_normal_map_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/model_normal_map_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_shadow.slp delete mode 100644 libraries/render-utils/src/render-utils/model_shadow_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent_normal_map.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent_normal_map_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/model_translucent_unlit_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/model_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/model_unlit_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/parabola_translucent.slp delete mode 100644 libraries/render-utils/src/render-utils/sdf_text3D_transparent.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_opaque_web_browser.slp create mode 100644 libraries/render-utils/src/render-utils/simple_procedural.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_textured.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_textured_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_textured_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_textured_unlit_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent_textured.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent_textured_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent_textured_unlit.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent_textured_unlit_fade.slp delete mode 100644 libraries/render-utils/src/render-utils/simple_transparent_web_browser.slp create mode 100644 libraries/render-utils/src/render-utils/web_browser.slp delete mode 100644 libraries/render-utils/src/sdf_text3D_transparent.slf rename libraries/render-utils/src/{simple_transparent.slf => simple_procedural.slf} (79%) rename libraries/render-utils/src/{simple_fade.slv => simple_procedural.slv} (70%) delete mode 100644 libraries/render-utils/src/simple_textured.slf delete mode 100644 libraries/render-utils/src/simple_textured_fade.slf delete mode 100644 libraries/render-utils/src/simple_textured_unlit.slf delete mode 100644 libraries/render-utils/src/simple_textured_unlit_fade.slf delete mode 100644 libraries/render-utils/src/simple_transparent_textured.slf delete mode 100644 libraries/render-utils/src/simple_transparent_textured_fade.slf delete mode 100644 libraries/render-utils/src/simple_transparent_textured_unlit.slf delete mode 100644 libraries/render-utils/src/simple_transparent_textured_unlit_fade.slf delete mode 100644 libraries/render-utils/src/simple_transparent_web_browser.slf rename libraries/render-utils/src/{simple_opaque_web_browser.slf => web_browser.slf} (54%) create mode 100644 libraries/render-utils/src/web_browser.slv 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) From 476f0ed012eb171860275942507c8a3c0be8354c Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Mon, 3 Jun 2019 20:45:46 -0700 Subject: [PATCH 02/10] cleanup and fixing some issues --- .../src/RenderableGridEntityItem.cpp | 2 +- libraries/entities-renderer/src/polyvox.slf | 2 +- libraries/render-utils/src/grid.slf | 15 +++++++-------- libraries/render-utils/src/model.slf | 10 +++++++++- libraries/render-utils/src/simple.slv | 11 ++++++++--- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp index 31969e36fc..d8f0d93bb6 100644 --- a/libraries/entities-renderer/src/RenderableGridEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableGridEntityItem.cpp @@ -122,7 +122,7 @@ void GridEntityRenderer::doRender(RenderArgs* args) { forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == Args::RenderMethod::FORWARD; }); - if (!_visible) { + if (!_visible || color.a == 0.0f) { return; } diff --git a/libraries/entities-renderer/src/polyvox.slf b/libraries/entities-renderer/src/polyvox.slf index b703a6868c..37cc7bcbbc 100644 --- a/libraries/entities-renderer/src/polyvox.slf +++ b/libraries/entities-renderer/src/polyvox.slf @@ -94,7 +94,7 @@ void main(void) { DEFAULT_METALLIC, DEFAULT_EMISSIVE <@if HIFI_USE_FADE@> - + fadeEmissive + + fadeEmissive <@endif@> , DEFAULT_OCCLUSION, diff --git a/libraries/render-utils/src/grid.slf b/libraries/render-utils/src/grid.slf index 68e6d019c0..f0a0741e5a 100644 --- a/libraries/render-utils/src/grid.slf +++ b/libraries/render-utils/src/grid.slf @@ -33,21 +33,20 @@ layout(location=GPU_ATTR_TEXCOORD0) in vec2 varTexCoord0; layout(location=GPU_ATTR_COLOR) in vec4 varColor; void main(void) { - float alpha = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), + float gridLine = mix(paintGridMajorMinor(varTexCoord0, grid.offset, grid.period, grid.edge), paintGrid(varTexCoord0, grid.offset.xy, grid.period.xy, grid.edge.xy), float(grid.edge.z == 0.0)); + if (gridLine <= 0.0) { + discard; + } <@if not HIFI_USE_FORWARD@> <@if not HIFI_USE_TRANSLUCENT@> - packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), alpha, varColor.rgb); + packDeferredFragmentUnlit(vec3(1.0, 0.0, 0.0), 1.0, varColor.rgb); <@else@> - packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), alpha, varColor.rgb, DEFAULT_ROUGHNESS); + packDeferredFragmentTranslucent(vec3(1.0, 0.0, 0.0), varColor.a, varColor.rgb, DEFAULT_ROUGHNESS); <@endif@> <@else@> - const float EPSILON = 0.0001; - if (alpha < EPSILON) { - discard; - } - _fragColor0 = vec4(varColor.rgb, alpha); + _fragColor0 = varColor; <@endif@> } diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 7803974ec8..374248765d 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -104,7 +104,11 @@ void main(void) { <@if HIFI_USE_SHADOW or HIFI_USE_UNLIT@> <$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$> + <@if HIFI_USE_TRANSLUCENT@> + float opacity = getMaterialOpacity(mat) * _color.a; + <@else@> float opacity = 1.0; + <@endif@> <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <@if HIFI_USE_TRANSLUCENT@> <$discardInvisible(opacity)$>; @@ -152,7 +156,11 @@ void main(void) { <$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmap)$> <@endif@> + <@if HIFI_USE_TRANSLUCENT@> + float opacity = getMaterialOpacity(mat) * _color.a; + <@else@> float opacity = 1.0; + <@endif@> <$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>; <@if HIFI_USE_TRANSLUCENT@> <$discardInvisible(opacity)$>; @@ -301,7 +309,7 @@ void main(void) { metallic, emissive <@if HIFI_USE_FADE@> - + fadeEmissive + + fadeEmissive <@endif@> , surfaceWS, opacity, localLighting.rgb), diff --git a/libraries/render-utils/src/simple.slv b/libraries/render-utils/src/simple.slv index f766acceda..e47af5d23f 100644 --- a/libraries/render-utils/src/simple.slv +++ b/libraries/render-utils/src/simple.slv @@ -17,14 +17,18 @@ <@include render-utils/ShaderConstants.h@> +<@if HIFI_USE_FADE@> + <@include Fade.slh@> + <$declareFadeVertexInstanced()$> + + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; +<@endif@> + <@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_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; @@ -47,6 +51,7 @@ void main(void) { <@if HIFI_USE_FADE@> <$transformModelToWorldPos(obj, inPosition, _positionWS)$> + <$passThroughFadeObjectParams()$> <@endif@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> } \ No newline at end of file From 7573c1207b3e6128ea0839298ffdacca7623862c Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Wed, 26 Jun 2019 11:21:52 -0700 Subject: [PATCH 03/10] remove extra alpha check in deferred sdf_text3D.slf --- libraries/render-utils/src/sdf_text3D.slf | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index ab67447d04..a581bf4650 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -80,10 +80,6 @@ void main() { alpha); <@endif@> <@else@> - if (alpha <= 0.0) { - discard; - } - packDeferredFragment( normalize(_normalWS), alpha, @@ -94,4 +90,4 @@ void main() { DEFAULT_OCCLUSION, DEFAULT_SCATTERING); <@endif@> -} \ No newline at end of file +} From 68b2c8c2fbde0fdf58f1ce004c2a9f4bbcbe4f6f Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 9 Jul 2019 00:46:24 -0700 Subject: [PATCH 04/10] wip adding haze to forward rendering --- libraries/render-utils/src/GlobalLight.slh | 68 +------------------ .../src/directional_ambient_light.slf | 7 +- .../src/directional_ambient_light_shadow.slf | 7 +- .../src/directional_skybox_light.slf | 4 +- .../src/directional_skybox_light_shadow.slf | 8 +-- libraries/render-utils/src/model.slf | 6 +- libraries/render-utils/src/sdf_text3D.slf | 4 +- libraries/render-utils/src/simple.slf | 4 +- .../render-utils/src/simple_procedural.slf | 4 +- 9 files changed, 19 insertions(+), 93 deletions(-) diff --git a/libraries/render-utils/src/GlobalLight.slh b/libraries/render-utils/src/GlobalLight.slh index 1cc357fe5f..1c8914adf3 100644 --- a/libraries/render-utils/src/GlobalLight.slh +++ b/libraries/render-utils/src/GlobalLight.slh @@ -1,5 +1,5 @@ -<@if not HIFI_USE_FORWARD@> <@include Haze.slh@> -<@endif@> <@func declareEvalSkyboxGlobalColor(supportScattering)@> @@ -142,12 +140,10 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu 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; } @@ -184,61 +180,7 @@ 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)$> - - SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); - - color = prevLighting; - color += emissive * isEmissiveEnabled(); - - // Ambient - vec3 ambientDiffuse; - vec3 ambientSpecular; - evalLightingAmbient(ambientDiffuse, ambientSpecular, lightAmbient, surfaceWS, metallic, fresnel, albedo, obscurance); - color += ambientDiffuse; - - // Directional - vec3 directionalDiffuse; - vec3 directionalSpecular; - evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation); - color += directionalDiffuse; - color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); - - return color; -} - -<@endfunc@> - -<@func declareEvalGlobalLightingAlphaBlendedWithHaze()@> - -<$declareLightingAmbient(1, 1, 1)$> -<$declareLightingDirectional()$> - -vec3 evalGlobalLightingAlphaBlendedWithHaze( +vec3 evalGlobalLightingAlphaBlended( mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) { @@ -261,7 +203,6 @@ 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( @@ -273,12 +214,11 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color = mix(color.rgb, hazeColor.rgb, hazeColor.a); } -<@endif@> return color; } -vec3 evalGlobalLightingAlphaBlendedWithHaze( +vec3 evalGlobalLightingAlphaBlended( mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS, vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting) { @@ -300,7 +240,6 @@ 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( @@ -312,7 +251,6 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( color = mix(color.rgb, hazeColor.rgb, hazeColor.a); } -<@endif@> return color; } diff --git a/libraries/render-utils/src/directional_ambient_light.slf b/libraries/render-utils/src/directional_ambient_light.slf index ecacff38f6..dd1b59f43e 100644 --- a/libraries/render-utils/src/directional_ambient_light.slf +++ b/libraries/render-utils/src/directional_ambient_light.slf @@ -11,15 +11,10 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - - - <@include DeferredBufferRead.slh@> -<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> - +<@include GlobalLight.slh@> <$declareEvalAmbientSphereGlobalColor(supportScattering)$> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; diff --git a/libraries/render-utils/src/directional_ambient_light_shadow.slf b/libraries/render-utils/src/directional_ambient_light_shadow.slf index c6763eb372..34018125af 100644 --- a/libraries/render-utils/src/directional_ambient_light_shadow.slf +++ b/libraries/render-utils/src/directional_ambient_light_shadow.slf @@ -11,15 +11,14 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - -<@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> +<@include GlobalLight.slh@> <$declareEvalAmbientSphereGlobalColor(isScattering)$> +<@include Shadow.slh@> + layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index f6044b2d89..4ef7621b36 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -11,12 +11,10 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // - <@include DeferredBufferRead.slh@> -<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> +<@include GlobalLight.slh@> <$declareEvalSkyboxGlobalColor(isScattering)$> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index 7af0eafd9a..217cf3ba05 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -11,15 +11,14 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html //!> - -<@include Shadow.slh@> <@include DeferredBufferRead.slh@> -<@include GlobalLight.slh@> <@include render-utils/ShaderConstants.h@> -<$declareEvalLightmappedColor()$> +<@include GlobalLight.slh@> <$declareEvalSkyboxGlobalColor(isScattering)$> +<@include Shadow.slh@> + layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw @@ -35,7 +34,6 @@ void main(void) { vec3 worldLightDirection = getLightDirection(shadowLight); float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal); - // Light mapped or not ? if (frag.mode == FRAG_MODE_UNLIT || frag.mode == FRAG_MODE_LIGHTMAPPED) { discard; } else { diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index 374248765d..b3167dd598 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -23,10 +23,8 @@ <@elif HIFI_USE_TRANSLUCENT@> <@if not HIFI_USE_FORWARD@> <@include LightLocal.slh@> - <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> - <@else@> - <$declareEvalGlobalLightingAlphaBlended()$> <@endif@> + <$declareEvalGlobalLightingAlphaBlended()$> <@else@> <$declareEvalSkyboxGlobalColor()$> <@endif@> @@ -298,7 +296,7 @@ void main(void) { vec4(0), vec4(0), opacity); } - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, occlusion, diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index c56c8b6436..a5a7cfb6a4 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -16,7 +16,7 @@ <@if HIFI_USE_FORWARD@> <$declareEvalSkyboxGlobalColor()$> <@else@> - <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <$declareEvalGlobalLightingAlphaBlended()$> <@endif@> <@include gpu/Transform.slh@> @@ -78,7 +78,7 @@ void main() { DEFAULT_ROUGHNESS), alpha); <@else@> - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, DEFAULT_OCCLUSION, diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index ce063cd7e7..ac7deedff0 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -31,7 +31,7 @@ <$declareEvalSkyboxGlobalColor()$> <@elif HIFI_USE_TRANSLUCENT@> <@include GlobalLight.slh@> - <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <$declareEvalGlobalLightingAlphaBlended()$> <@else@> <@include DeferredBufferWrite.slh@> <@endif@> @@ -101,7 +101,7 @@ void main(void) { DEFAULT_ROUGHNESS), texel.a); <@elif HIFI_USE_TRANSLUCENT@> - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, DEFAULT_OCCLUSION, diff --git a/libraries/render-utils/src/simple_procedural.slf b/libraries/render-utils/src/simple_procedural.slf index ae5b72012f..5b0eb62cca 100644 --- a/libraries/render-utils/src/simple_procedural.slf +++ b/libraries/render-utils/src/simple_procedural.slf @@ -16,7 +16,7 @@ <@include DefaultMaterials.slh@> <@include GlobalLight.slh@> - <$declareEvalGlobalLightingAlphaBlendedWithHaze()$> + <$declareEvalGlobalLightingAlphaBlended()$> layout(location=0) out vec4 _fragColor0; <@endif@> @@ -167,7 +167,7 @@ void main(void) { if (emissiveAmount > 0.0) { _fragColor0 = vec4(diffuse, alpha); } else { - _fragColor0 = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, occlusion, From d545ba5bc6543e575064e9b700873465d21acdbd Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 10 Jul 2019 18:32:43 -0700 Subject: [PATCH 05/10] haze on most entities, working on skybox --- cmake/macros/AutoScribeShader.cmake | 9 +- interface/src/graphics/GraphicsEngine.cpp | 2 +- .../RenderableParticleEffectEntityItem.cpp | 2 +- .../src/RenderablePolyVoxEntityItem.cpp | 75 ++++++++--------- .../entities-renderer/src/paintStroke.slf | 2 +- libraries/entities-renderer/src/polyvox.slf | 8 +- libraries/graphics/src/graphics/Haze.cpp | 2 +- .../src => graphics/src/graphics}/Haze.slh | 5 +- .../graphics/src/graphics/ShaderConstants.h | 5 +- libraries/graphics/src/graphics/Skybox.cpp | 32 +++---- libraries/graphics/src/graphics/Skybox.h | 4 +- libraries/graphics/src/graphics/skybox.slf | 12 ++- libraries/graphics/src/graphics/skybox.slp | 1 + libraries/graphics/src/graphics/skybox.slv | 4 +- .../src/procedural/ProceduralSkybox.cpp | 9 +- .../src/procedural/ProceduralSkybox.h | 4 +- .../render-utils/src/BackgroundStage.cpp | 17 +++- libraries/render-utils/src/BackgroundStage.h | 3 +- .../src/DeferredLightingEffect.cpp | 3 +- libraries/render-utils/src/DrawHaze.cpp | 2 +- libraries/render-utils/src/GlobalLight.slh | 84 +++++++++++++------ libraries/render-utils/src/Haze.slf | 2 +- .../render-utils/src/RenderCommonTask.cpp | 14 +++- libraries/render-utils/src/RenderCommonTask.h | 5 +- .../render-utils/src/RenderDeferredTask.cpp | 10 +-- .../render-utils/src/RenderForwardTask.cpp | 25 ++++-- .../render-utils/src/RenderForwardTask.h | 2 +- .../render-utils/src/RenderHUDLayerTask.cpp | 5 +- .../render-utils/src/RenderHUDLayerTask.h | 4 +- .../src/directional_skybox_light.slf | 2 +- .../src/directional_skybox_light_shadow.slf | 2 +- libraries/render-utils/src/model.slf | 9 +- .../src/render-utils/ShaderConstants.h | 2 - libraries/render-utils/src/sdf_text3D.slf | 32 +++---- libraries/render-utils/src/simple.slf | 34 ++++---- libraries/render-utils/src/web_browser.slf | 4 +- libraries/render-utils/src/web_browser.slv | 7 +- libraries/render/src/render/ShapePipeline.cpp | 4 +- libraries/render/src/render/ShapePipeline.h | 2 +- 39 files changed, 268 insertions(+), 182 deletions(-) rename libraries/{render-utils/src => graphics/src/graphics}/Haze.slh (97%) diff --git a/cmake/macros/AutoScribeShader.cmake b/cmake/macros/AutoScribeShader.cmake index f5a497962c..63f7c0c7d6 100755 --- a/cmake/macros/AutoScribeShader.cmake +++ b/cmake/macros/AutoScribeShader.cmake @@ -268,6 +268,7 @@ macro(AUTOSCRIBE_SHADER_LIB) set(PROGRAM_ENUMS "namespace program { enum {\n") foreach(PROGRAM_FILE ${SHADER_PROGRAM_FILES}) get_filename_component(PROGRAM_NAME ${PROGRAM_FILE} NAME_WE) + get_filename_component(PROGRAM_FOLDER ${PROGRAM_FILE} DIRECTORY) file(READ ${PROGRAM_FILE} PROGRAM_CONFIG) set(AUTOSCRIBE_PROGRAM_VERTEX ${PROGRAM_NAME}) set(AUTOSCRIBE_PROGRAM_FRAGMENT ${PROGRAM_NAME}) @@ -315,7 +316,9 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_FRAGMENT EQUAL -1) set(DEFINES "${VERTEX_DEFINES}") set(SHADER_LIST "") - set(SHADER_FILE "${SRC_FOLDER}/${VERTEX_NAME}.slv") + unset(SHADER_FILE) + unset(SHADER_FILE CACHE) + find_file(SHADER_FILE "${VERTEX_NAME}.slv" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}") else() @@ -331,7 +334,9 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_VERTEX EQUAL -1) set(DEFINES "${FRAGMENT_DEFINES}") set(SHADER_LIST "") - set(SHADER_FILE "${SRC_FOLDER}/${FRAGMENT_NAME}.slf") + unset(SHADER_FILE) + unset(SHADER_FILE CACHE) + find_file(SHADER_FILE "${FRAGMENT_NAME}.slf" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}") else() diff --git a/interface/src/graphics/GraphicsEngine.cpp b/interface/src/graphics/GraphicsEngine.cpp index 7f9a612697..284118a52a 100644 --- a/interface/src/graphics/GraphicsEngine.cpp +++ b/interface/src/graphics/GraphicsEngine.cpp @@ -259,7 +259,7 @@ void GraphicsEngine::render_performFrame() { batch.enableSkybox(true); batch.enableStereo(isStereo); batch.setViewportTransform({ 0, 0, finalFramebuffer->getSize() }); - _splashScreen->render(batch, viewFrustum); + _splashScreen->render(batch, viewFrustum, renderArgs._renderMethod == RenderArgs::RenderMethod::FORWARD); }); } else { { diff --git a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp index d517ecd026..36f8ccf8f6 100644 --- a/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableParticleEffectEntityItem.cpp @@ -23,7 +23,7 @@ static uint8_t CUSTOM_PIPELINE_NUMBER = 0; static gpu::Stream::FormatPointer _vertexFormat; static std::weak_ptr _texturedPipeline; -static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { +static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) { auto texturedPipeline = _texturedPipeline.lock(); if (!texturedPipeline) { auto state = std::make_shared(); diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index adf0a2d162..3adeecabcc 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -34,9 +34,7 @@ #include "EntityTreeRenderer.h" -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT -# include -#endif +#include #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push @@ -1553,52 +1551,49 @@ using namespace render; using namespace render::entities; static uint8_t CUSTOM_PIPELINE_NUMBER; -static gpu::PipelinePointer _pipelines[2]; -static gpu::PipelinePointer _wireframePipelines[2]; +static std::map, ShapePipelinePointer> _pipelines; static gpu::Stream::FormatPointer _vertexFormat; -ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) { - if (!_pipelines[0]) { +ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args) { + // FIXME: custom pipelines like this don't handle shadows or renderLayers correctly + + if (_pipelines.empty()) { using namespace shader::entities_renderer::program; - int programsIds[2] = { polyvox, polyvox_fade }; - auto state = std::make_shared(); - state->setCullMode(gpu::State::CULL_BACK); - state->setDepthTest(true, true, gpu::LESS_EQUAL); - PrepareStencil::testMaskDrawShape(*state); + static const std::vector> keys = { + std::make_tuple(false, false, polyvox), std::make_tuple(true, false, polyvox_forward) +#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT + , std::make_tuple(false, true, polyvox_fade), std::make_tuple(true, true, polyvox_forward_fade) +#else + , std::make_tuple(false, true, polyvox), std::make_tuple(true, true, polyvox_forward) +#endif + }; + for (auto& key : keys) { + for (int i = 0; i < 2; ++i) { + bool wireframe = i != 0; - auto wireframeState = std::make_shared(); - wireframeState->setCullMode(gpu::State::CULL_BACK); - wireframeState->setDepthTest(true, true, gpu::LESS_EQUAL); - wireframeState->setFillMode(gpu::State::FILL_LINE); - PrepareStencil::testMaskDrawShape(*wireframeState); + auto state = std::make_shared(); + state->setCullMode(gpu::State::CULL_BACK); + state->setDepthTest(true, true, gpu::LESS_EQUAL); + PrepareStencil::testMaskDrawShape(*state); - // Two sets of pipelines: normal and fading - for (auto i = 0; i < 2; i++) { - gpu::ShaderPointer program = gpu::Shader::createProgram(programsIds[i]); - _pipelines[i] = gpu::Pipeline::create(program, state); - _wireframePipelines[i] = gpu::Pipeline::create(program, wireframeState); + if (wireframe) { + state->setFillMode(gpu::State::FILL_LINE); + } + + auto pipeline = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state); + if (std::get<1>(key)) { + _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared(pipeline, nullptr, nullptr, nullptr); + } else { + const auto& fadeEffect = DependencyManager::get(); + _pipelines[std::make_tuple(std::get<0>(key), std::get<1>(key), wireframe)] = std::make_shared(pipeline, nullptr, + fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); + } + } } } -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT - if (key.isFaded()) { - const auto& fadeEffect = DependencyManager::get(); - if (key.isWireframe()) { - return std::make_shared(_wireframePipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); - } else { - return std::make_shared(_pipelines[1], nullptr, fadeEffect->getBatchSetter(), fadeEffect->getItemUniformSetter()); - } - } else { -#endif - if (key.isWireframe()) { - return std::make_shared(_wireframePipelines[0], nullptr, nullptr, nullptr); - } else { - return std::make_shared(_pipelines[0], nullptr, nullptr, nullptr); - } -#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT - } -#endif + return _pipelines[std::make_tuple(args->_renderMethod == Args::RenderMethod::FORWARD, key.isFaded(), key.isWireframe())]; } PolyVoxEntityRenderer::PolyVoxEntityRenderer(const EntityItemPointer& entity) : Parent(entity) { diff --git a/libraries/entities-renderer/src/paintStroke.slf b/libraries/entities-renderer/src/paintStroke.slf index 045c5bd088..837291efe6 100644 --- a/libraries/entities-renderer/src/paintStroke.slf +++ b/libraries/entities-renderer/src/paintStroke.slf @@ -22,7 +22,7 @@ LAYOUT(binding=0) uniform sampler2D _texture; <@if not HIFI_USE_FORWARD@> -layout(location=0) in vec3 _normalWS; + layout(location=0) in vec3 _normalWS; <@endif@> layout(location=1) in vec2 _texCoord; layout(location=2) in vec4 _color; diff --git a/libraries/entities-renderer/src/polyvox.slf b/libraries/entities-renderer/src/polyvox.slf index 37cc7bcbbc..f08728dbcb 100644 --- a/libraries/entities-renderer/src/polyvox.slf +++ b/libraries/entities-renderer/src/polyvox.slf @@ -28,7 +28,7 @@ <@include DefaultMaterials.slh@> <@include GlobalLight.slh@> - <$declareEvalSkyboxGlobalColor()$> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> @@ -52,7 +52,9 @@ LAYOUT(binding=0) uniform polyvoxParamsBuffer { PolyvoxParams params; }; -<@else@> +<@endif@> + +<@if HIFI_USE_SHADOW or HIFI_USE_FORWARD@> layout(location=0) out vec4 _fragColor0; <@endif@> @@ -101,7 +103,7 @@ void main(void) { DEFAULT_SCATTERING); <@else@> TransformCamera cam = getTransformCamera(); - vec4 color = vec4(evalSkyboxGlobalColor( + _fragColor0 = vec4(evalSkyboxGlobalColor( cam._viewInverse, 1.0, DEFAULT_OCCLUSION, diff --git a/libraries/graphics/src/graphics/Haze.cpp b/libraries/graphics/src/graphics/Haze.cpp index d9bee7507f..9e3cc15c57 100644 --- a/libraries/graphics/src/graphics/Haze.cpp +++ b/libraries/graphics/src/graphics/Haze.cpp @@ -98,7 +98,7 @@ void Haze::setHazeGlareColor(const glm::vec3 hazeGlareColor) { void Haze::setHazeActive(const bool isHazeActive) { auto& params = _hazeParametersBuffer.get(); - if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE )&& !isHazeActive) { + if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) && !isHazeActive) { _hazeParametersBuffer.edit().hazeMode &= ~HAZE_MODE_IS_ACTIVE; } else if (((params.hazeMode & HAZE_MODE_IS_ACTIVE) != HAZE_MODE_IS_ACTIVE) && isHazeActive) { _hazeParametersBuffer.edit().hazeMode |= HAZE_MODE_IS_ACTIVE; diff --git a/libraries/render-utils/src/Haze.slh b/libraries/graphics/src/graphics/Haze.slh similarity index 97% rename from libraries/render-utils/src/Haze.slh rename to libraries/graphics/src/graphics/Haze.slh index e2285febe4..a2d8bb0523 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/graphics/src/graphics/Haze.slh @@ -10,7 +10,7 @@ <@if not HAZE_SLH@> <@def HAZE_SLH@> -<@include render-utils/ShaderConstants.h@> +<@include graphics/ShaderConstants.h@> const int HAZE_MODE_IS_ACTIVE = 1 << 0; const int HAZE_MODE_IS_ALTITUDE_BASED = 1 << 1; @@ -38,8 +38,7 @@ struct HazeParams { float hazeKeyLightAltitudeFactor; }; -// See ShapePipeline::Slot::BUFFER in ShapePipeline.h -LAYOUT_STD140(binding=RENDER_UTILS_BUFFER_HAZE_PARAMS) uniform hazeBuffer { +LAYOUT_STD140(binding=GRAPHICS_BUFFER_HAZE_PARAMS) uniform hazeBuffer { HazeParams hazeParams; }; diff --git a/libraries/graphics/src/graphics/ShaderConstants.h b/libraries/graphics/src/graphics/ShaderConstants.h index 0aff0a7077..3a614d26cd 100644 --- a/libraries/graphics/src/graphics/ShaderConstants.h +++ b/libraries/graphics/src/graphics/ShaderConstants.h @@ -32,6 +32,8 @@ #define GRAPHICS_TEXTURE_SKYBOX 11 #define GRAPHICS_BUFFER_SKYBOX_PARAMS 5 +#define GRAPHICS_BUFFER_HAZE_PARAMS 7 + // (); +static std::map _pipelines; + +void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Skybox& skybox, bool forward) { + if (_pipelines.empty()) { + static const std::vector> keys = { + std::make_tuple(false, shader::graphics::program::skybox), + std::make_tuple(true, shader::graphics::program::skybox_forward) + }; + for (auto& key : keys) { + auto state = std::make_shared(); // Must match PrepareStencil::STENCIL_BACKGROUND const int8_t STENCIL_BACKGROUND = 0; - skyState->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL, + state->setStencilTest(true, 0xFF, gpu::State::StencilTest(STENCIL_BACKGROUND, 0xFF, gpu::EQUAL, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP, gpu::State::STENCIL_OP_KEEP)); - thePipeline = gpu::Pipeline::create(skyShader, skyState); + _pipelines[std::get<0>(key)] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<1>(key)), state); } - }); - + } // Render glm::mat4 projMat; @@ -111,7 +111,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky batch.setViewTransform(viewTransform); batch.setModelTransform(Transform()); // only for Mac - batch.setPipeline(thePipeline); + batch.setPipeline(_pipelines[forward]); skybox.prepare(batch); batch.draw(gpu::TRIANGLE_STRIP, 4); diff --git a/libraries/graphics/src/graphics/Skybox.h b/libraries/graphics/src/graphics/Skybox.h index 50189f4c51..5668604c8b 100755 --- a/libraries/graphics/src/graphics/Skybox.h +++ b/libraries/graphics/src/graphics/Skybox.h @@ -44,9 +44,9 @@ public: virtual void clear(); void prepare(gpu::Batch& batch) const; - virtual void render(gpu::Batch& batch, const ViewFrustum& frustum) const; + virtual void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const; - static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox); + static void render(gpu::Batch& batch, const ViewFrustum& frustum, const Skybox& skybox, bool forward); const UniformBufferView& getSchemaBuffer() const { return _schemaBuffer; } diff --git a/libraries/graphics/src/graphics/skybox.slf b/libraries/graphics/src/graphics/skybox.slf index 801fc33c28..0dea1d7882 100755 --- a/libraries/graphics/src/graphics/skybox.slf +++ b/libraries/graphics/src/graphics/skybox.slf @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// skybox.frag -// fragment shader // // Created by Sam Gateau on 5/5/2015. // Copyright 2015 High Fidelity, Inc. @@ -12,6 +11,10 @@ // <@include graphics/ShaderConstants.h@> +<@if HIFI_USE_FORWARD@> + <@include graphics/Haze.slh@> +<@endif@> + LAYOUT(binding=GRAPHICS_TEXTURE_SKYBOX) uniform samplerCube cubeMap; struct Skybox { @@ -36,4 +39,9 @@ void main(void) { vec3 skyboxColor = skybox.color.rgb; _fragColor = vec4(mix(vec3(1.0), skyboxTexel, float(skybox.color.a > 0.0)) * mix(vec3(1.0), skyboxColor, float(skybox.color.a < 1.0)), 1.0); + +<@if HIFI_USE_FORWARD@> + _fragColor = vec4(hazeParams.hazeColor, 1); +<@endif@> + } diff --git a/libraries/graphics/src/graphics/skybox.slp b/libraries/graphics/src/graphics/skybox.slp index e69de29bb2..e9908ffd1b 100644 --- a/libraries/graphics/src/graphics/skybox.slp +++ b/libraries/graphics/src/graphics/skybox.slp @@ -0,0 +1 @@ +DEFINES forward:f \ No newline at end of file diff --git a/libraries/graphics/src/graphics/skybox.slv b/libraries/graphics/src/graphics/skybox.slv index 4b14872df2..a6e6930d22 100755 --- a/libraries/graphics/src/graphics/skybox.slv +++ b/libraries/graphics/src/graphics/skybox.slv @@ -1,8 +1,7 @@ <@include gpu/Config.slh@> <$VERSION_HEADER$> +// <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> -// skybox.vert -// vertex shader // // Created by Sam Gateau on 5/5/2015. // Copyright 2015 High Fidelity, Inc. @@ -12,7 +11,6 @@ // <@include gpu/Transform.slh@> - <$declareStandardTransform()$> layout(location=0) out vec3 _normal; diff --git a/libraries/procedural/src/procedural/ProceduralSkybox.cpp b/libraries/procedural/src/procedural/ProceduralSkybox.cpp index 53df1532dc..5e8c6f4865 100644 --- a/libraries/procedural/src/procedural/ProceduralSkybox.cpp +++ b/libraries/procedural/src/procedural/ProceduralSkybox.cpp @@ -18,6 +18,7 @@ #include ProceduralSkybox::ProceduralSkybox(uint64_t created) : graphics::Skybox(), _created(created) { + // FIXME: support forward rendering for procedural skyboxes (needs haze calculation) _procedural._vertexSource = gpu::Shader::createVertex(shader::graphics::vertex::skybox)->getSource(); _procedural._opaqueFragmentSource = shader::Source::get(shader::procedural::fragment::proceduralSkybox); // Adjust the pipeline state for background using the stencil test @@ -40,15 +41,15 @@ void ProceduralSkybox::clear() { Skybox::clear(); } -void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum) const { +void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const { if (_procedural.isReady()) { - ProceduralSkybox::render(batch, frustum, (*this)); + ProceduralSkybox::render(batch, frustum, (*this), forward); } else { - Skybox::render(batch, frustum); + Skybox::render(batch, frustum, forward); } } -void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox) { +void ProceduralSkybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const ProceduralSkybox& skybox, bool forward) { glm::mat4 projMat; viewFrustum.evalProjectionMatrix(projMat); diff --git a/libraries/procedural/src/procedural/ProceduralSkybox.h b/libraries/procedural/src/procedural/ProceduralSkybox.h index a1d7ea8fa7..983b432089 100644 --- a/libraries/procedural/src/procedural/ProceduralSkybox.h +++ b/libraries/procedural/src/procedural/ProceduralSkybox.h @@ -26,8 +26,8 @@ public: bool empty() override; void clear() override; - void render(gpu::Batch& batch, const ViewFrustum& frustum) const override; - static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox); + void render(gpu::Batch& batch, const ViewFrustum& frustum, bool forward) const override; + static void render(gpu::Batch& batch, const ViewFrustum& frustum, const ProceduralSkybox& skybox, bool forward); uint64_t getCreated() const { return _created; } diff --git a/libraries/render-utils/src/BackgroundStage.cpp b/libraries/render-utils/src/BackgroundStage.cpp index ca643b9f14..91b766d90b 100644 --- a/libraries/render-utils/src/BackgroundStage.cpp +++ b/libraries/render-utils/src/BackgroundStage.cpp @@ -13,6 +13,8 @@ #include +#include + std::string BackgroundStage::_stageName { "BACKGROUND_STAGE"}; const BackgroundStage::Index BackgroundStage::INVALID_INDEX { render::indexed_container::INVALID_INDEX }; @@ -71,6 +73,8 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, } } + const auto& hazeFrame = inputs.get2(); + if (skybox && !skybox->empty()) { PerformanceTimer perfTimer("skybox"); auto args = renderContext->args; @@ -91,7 +95,18 @@ void DrawBackgroundStage::run(const render::RenderContextPointer& renderContext, batch.setProjectionTransform(projMat); batch.setViewTransform(viewMat); - skybox->render(batch, args->getViewFrustum()); + // If we're using forward rendering, we need to calculate haze + if (args->_renderMethod == render::Args::RenderMethod::FORWARD) { + const auto& hazeStage = args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); + if (hazePointer) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + } + } + } + + skybox->render(batch, args->getViewFrustum(), args->_renderMethod == render::Args::RenderMethod::FORWARD); }); args->_batch = nullptr; } diff --git a/libraries/render-utils/src/BackgroundStage.h b/libraries/render-utils/src/BackgroundStage.h index 61ca576ca8..3015b721b1 100644 --- a/libraries/render-utils/src/BackgroundStage.h +++ b/libraries/render-utils/src/BackgroundStage.h @@ -16,6 +16,7 @@ #include #include #include +#include "HazeStage.h" #include "LightingModel.h" @@ -81,7 +82,7 @@ public: class DrawBackgroundStage { public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using JobModel = render::Job::ModelI; DrawBackgroundStage() {} diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index 3ab9340906..3b7c66d42d 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -432,7 +432,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, if (hazeStage && hazeFrame->_hazes.size() > 0) { const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); if (hazePointer) { - batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); } } @@ -655,7 +655,6 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { if (!_defaultHaze) { auto hazeStage = renderContext->_scene->getStage(); if (hazeStage) { - auto haze = std::make_shared(); _defaultHaze = haze; diff --git a/libraries/render-utils/src/DrawHaze.cpp b/libraries/render-utils/src/DrawHaze.cpp index db80cbecae..f7be5160b6 100644 --- a/libraries/render-utils/src/DrawHaze.cpp +++ b/libraries/render-utils/src/DrawHaze.cpp @@ -78,7 +78,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu batch.setModelTransform(gpu::Framebuffer::evalSubregionTexcoordTransform(outputFramebufferSize, args->_viewport)); batch.setPipeline(_hazePipeline); - batch.setUniformBuffer(ru::Buffer::HazeParams, haze->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); batch.setUniformBuffer(ru::Buffer::DeferredFrameTransform, transformBuffer->getFrameTransformBuffer()); batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); diff --git a/libraries/render-utils/src/GlobalLight.slh b/libraries/render-utils/src/GlobalLight.slh index 1c8914adf3..6702270a5a 100644 --- a/libraries/render-utils/src/GlobalLight.slh +++ b/libraries/render-utils/src/GlobalLight.slh @@ -98,9 +98,9 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa <@endfunc@> -<@include Haze.slh@> +<@include graphics/Haze.slh@> -<@func declareEvalSkyboxGlobalColor(supportScattering)@> +<@func declareEvalSkyboxGlobalColor(supportScattering, computeHaze)@> <$declareLightingAmbient(_SCRIBE_NULL, 1, _SCRIBE_NULL, $supportScattering$)$> <$declareLightingDirectional($supportScattering$)$> @@ -109,13 +109,13 @@ vec3 evalAmbientSphereGlobalColor(mat4 invViewMat, float shadowAttenuation, floa <$declareDeferredCurvature()$> <@endif@> -vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 position, vec3 normal, +vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, vec3 albedo, vec3 fresnel, float metallic, float roughness <@if supportScattering@> , float scattering, vec4 midNormalCurvature, vec4 lowNormalCurvature <@endif@> ) { - <$prepareGlobalLight(position, normal)$> + <$prepareGlobalLight(positionES, normalWS)$> SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragEyeDirWS); @@ -130,6 +130,7 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu color += ambientDiffuse; color += ambientSpecular; + // Directional vec3 directionalDiffuse; vec3 directionalSpecular; evalLightingDirectional(directionalDiffuse, directionalSpecular, lightDirection, lightIrradiance, surfaceWS, metallic, fresnel, albedo, shadowAttenuation @@ -140,9 +141,24 @@ vec3 evalSkyboxGlobalColor(mat4 invViewMat, float shadowAttenuation, float obscu color += directionalDiffuse; color += directionalSpecular; - // Attenuate the light if haze effect selected - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { - color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + // Haze + if (isHazeEnabled() > 0.0) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } + +<@if computeHaze@> + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } +<@endif@> } return color; @@ -181,8 +197,8 @@ vec3 evalLightmappedColor(mat4 invViewMat, float shadowAttenuation, float obscur <$declareLightingDirectional()$> vec3 evalGlobalLightingAlphaBlended( - mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, - vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, float roughness, float opacity) + 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)$> @@ -204,23 +220,29 @@ vec3 evalGlobalLightingAlphaBlended( color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); // Haze - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { - vec4 hazeColor = computeHazeColor( - positionES, // fragment position in eye coordinates - fragPositionWS, // fragment position in world coordinates - invViewMat[3].xyz, // eye position in world coordinates - lightDirection // keylight direction vector in world coordinates - ); + if (isHazeEnabled() > 0.0) { + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } - color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } } return color; } vec3 evalGlobalLightingAlphaBlended( - mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 positionWS, - vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting) + mat4 invViewMat, float shadowAttenuation, float obscurance, vec3 positionES, vec3 normalWS, + vec3 albedo, vec3 fresnel, float metallic, vec3 emissive, SurfaceData surface, float opacity, vec3 prevLighting) { <$fetchGlobalLight()$> @@ -241,15 +263,23 @@ vec3 evalGlobalLightingAlphaBlended( color += evalSpecularWithOpacity(ambientSpecular + directionalSpecular, opacity); // Haze - if ((isHazeEnabled() > 0.0) && (hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { - vec4 hazeColor = computeHazeColor( - positionES, // fragment position in eye coordinates - positionWS, // fragment position in world coordinates - invViewMat[3].xyz, // eye position in world coordinates - lightDirection // keylight direction vector - ); + if (isHazeEnabled() > 0.0) { + vec3 fragPositionWS = vec3(invViewMat * vec4(positionES, 1.0)); - color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + if ((hazeParams.hazeMode & HAZE_MODE_IS_KEYLIGHT_ATTENUATED) == HAZE_MODE_IS_KEYLIGHT_ATTENUATED) { + color = computeHazeColorKeyLightAttenuation(color, lightDirection, fragPositionWS); + } + + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + positionES, // fragment position in eye coordinates + fragPositionWS, // fragment position in world coordinates + invViewMat[3].xyz, // eye position in world coordinates + lightDirection // keylight direction vector in world coordinates + ); + + color = mix(color.rgb, hazeColor.rgb, hazeColor.a); + } } return color; diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 170e69eb2d..951841ad49 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -19,7 +19,7 @@ <@include LightingModel.slh@> <$declareLightBuffer()$> -<@include Haze.slh@> +<@include graphics/Haze.slh@> LAYOUT(binding=RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH) uniform sampler2D linearDepthMap; diff --git a/libraries/render-utils/src/RenderCommonTask.cpp b/libraries/render-utils/src/RenderCommonTask.cpp index 54e43abc07..9ea4ac9f3c 100644 --- a/libraries/render-utils/src/RenderCommonTask.cpp +++ b/libraries/render-utils/src/RenderCommonTask.cpp @@ -59,13 +59,21 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs& const auto& inItems = inputs.get0(); const auto& lightingModel = inputs.get1(); - const auto jitter = inputs.get2(); + const auto& hazeFrame = inputs.get2(); + const auto jitter = inputs.get3(); config->setNumDrawn((int)inItems.size()); emit config->numDrawnChanged(); RenderArgs* args = renderContext->args; + graphics::HazePointer haze; + const auto& hazeStage = renderContext->args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + // We use _hazes.back() here because the last haze object will always have haze disabled. + haze = hazeStage->getHaze(hazeFrame->_hazes.back()); + } + // Clear the framebuffer without stereo // Needs to be distinct from the other batch because using the clear call // while stereo is enabled triggers a warning @@ -96,6 +104,10 @@ void DrawLayered3D::run(const RenderContextPointer& renderContext, const Inputs& batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT()); + if (haze) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); + } + if (_opaquePass) { renderStateSortShapes(renderContext, _shapePlumber, inItems, _maxDrawn); } else { diff --git a/libraries/render-utils/src/RenderCommonTask.h b/libraries/render-utils/src/RenderCommonTask.h index 756445a30f..ec50fbf2cc 100644 --- a/libraries/render-utils/src/RenderCommonTask.h +++ b/libraries/render-utils/src/RenderCommonTask.h @@ -11,10 +11,9 @@ #include #include "LightStage.h" +#include "HazeStage.h" #include "LightingModel.h" - - class BeginGPURangeTimer { public: using JobModel = render::Job::ModelO; @@ -62,7 +61,7 @@ protected: class DrawLayered3D { public: - using Inputs = render::VaryingSet3; + using Inputs = render::VaryingSet4; using Config = DrawLayered3DConfig; using JobModel = render::Job::ModelI; diff --git a/libraries/render-utils/src/RenderDeferredTask.cpp b/libraries/render-utils/src/RenderDeferredTask.cpp index e513fb7282..c26f3b613c 100644 --- a/libraries/render-utils/src/RenderDeferredTask.cpp +++ b/libraries/render-utils/src/RenderDeferredTask.cpp @@ -207,7 +207,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("RenderDeferred", deferredLightingInputs); // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job - const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying(); + const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying(); task.addJob("DrawBackgroundDeferred", backgroundInputs); const auto drawHazeInputs = render::Varying(DrawHaze::Inputs(hazeFrame, lightingFramebuffer, linearDepthTarget, deferredFrameTransform, lightingModel, lightFrame)); @@ -225,8 +225,8 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren task.addJob("HighlightRangeTimer", outlineRangeTimer); // Layered Over (in front) - const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, jitter).asVarying(); - const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, jitter).asVarying(); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, jitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, jitter).asVarying(); task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); @@ -254,7 +254,7 @@ void RenderDeferredTask::build(JobModel& task, const render::Varying& input, ren const auto primaryFramebuffer = task.addJob("PrimaryBufferUpscale", toneMappedBuffer); // HUD Layer - const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying(); + const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); task.addJob("RenderHUDLayer", renderHUDLayerInputs); } @@ -506,7 +506,7 @@ void RenderTransparentDeferred::run(const RenderContextPointer& renderContext, c if (hazeStage && hazeFrame->_hazes.size() > 0) { const auto& hazePointer = hazeStage->getHaze(hazeFrame->_hazes.front()); if (hazePointer) { - batch.setUniformBuffer(ru::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, hazePointer->getHazeParametersBuffer()); } } diff --git a/libraries/render-utils/src/RenderForwardTask.cpp b/libraries/render-utils/src/RenderForwardTask.cpp index ef3dcee15f..b6b17ee376 100755 --- a/libraries/render-utils/src/RenderForwardTask.cpp +++ b/libraries/render-utils/src/RenderForwardTask.cpp @@ -90,6 +90,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto currentStageFrames = lightingStageInputs.get0(); const auto lightFrame = currentStageFrames[0]; const auto backgroundFrame = currentStageFrames[1]; + const auto hazeFrame = currentStageFrames[2]; const auto& zones = lightingStageInputs[1]; @@ -111,21 +112,21 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend task.addJob("PrepareStencil", scaledPrimaryFramebuffer); // Draw opaques forward - const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel).asVarying(); + const auto opaqueInputs = DrawForward::Inputs(opaques, lightingModel, hazeFrame).asVarying(); task.addJob("DrawOpaques", opaqueInputs, shapePlumber, true); // Similar to light stage, background stage has been filled by several potential render items and resolved for the frame in this job - const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame).asVarying(); + const auto backgroundInputs = DrawBackgroundStage::Inputs(lightingModel, backgroundFrame, hazeFrame).asVarying(); task.addJob("DrawBackgroundForward", backgroundInputs); // Draw transparent objects forward - const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel).asVarying(); + const auto transparentInputs = DrawForward::Inputs(transparents, lightingModel, hazeFrame).asVarying(); task.addJob("DrawTransparents", transparentInputs, shapePlumber, false); // Layered const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, nullJitter).asVarying(); - const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, nullJitter).asVarying(); + const auto inFrontOpaquesInputs = DrawLayered3D::Inputs(inFrontOpaque, lightingModel, hazeFrame, nullJitter).asVarying(); + const auto inFrontTransparentsInputs = DrawLayered3D::Inputs(inFrontTransparent, lightingModel, hazeFrame, nullJitter).asVarying(); task.addJob("DrawInFrontOpaque", inFrontOpaquesInputs, true); task.addJob("DrawInFrontTransparent", inFrontTransparentsInputs, false); @@ -167,7 +168,7 @@ void RenderForwardTask::build(JobModel& task, const render::Varying& input, rend const auto primaryFramebuffer = task.addJob("PrimaryBufferUpscale", toneMappedBuffer); // HUD Layer - const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent).asVarying(); + const auto renderHUDLayerInputs = RenderHUDLayerTask::Input(primaryFramebuffer, lightingModel, hudOpaque, hudTransparent, hazeFrame).asVarying(); task.addJob("RenderHUDLayer", renderHUDLayerInputs); } @@ -258,11 +259,17 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i const auto& inItems = inputs.get0(); const auto& lightingModel = inputs.get1(); + const auto& hazeFrame = inputs.get2(); + + graphics::HazePointer haze; + const auto& hazeStage = renderContext->args->_scene->getStage(); + if (hazeStage && hazeFrame->_hazes.size() > 0) { + haze = hazeStage->getHaze(hazeFrame->_hazes.front()); + } gpu::doInBatch("DrawForward::run", args->_context, [&](gpu::Batch& batch) { args->_batch = &batch; - // Setup projection glm::mat4 projMat; Transform viewMat; @@ -276,6 +283,10 @@ void DrawForward::run(const RenderContextPointer& renderContext, const Inputs& i batch.setUniformBuffer(ru::Buffer::LightModel, lightingModel->getParametersBuffer()); batch.setResourceTexture(ru::Texture::AmbientFresnel, lightingModel->getAmbientFresnelLUT()); + if (haze) { + batch.setUniformBuffer(graphics::slot::buffer::Buffer::HazeParams, haze->getHazeParametersBuffer()); + } + // From the lighting model define a global shapeKey ORED with individiual keys ShapeKey::Builder keyBuilder; if (lightingModel->isWireframeEnabled()) { diff --git a/libraries/render-utils/src/RenderForwardTask.h b/libraries/render-utils/src/RenderForwardTask.h index baf7f66c6c..2abf248692 100755 --- a/libraries/render-utils/src/RenderForwardTask.h +++ b/libraries/render-utils/src/RenderForwardTask.h @@ -96,7 +96,7 @@ private: class DrawForward{ public: - using Inputs = render::VaryingSet2; + using Inputs = render::VaryingSet3; using JobModel = render::Job::ModelI; DrawForward(const render::ShapePlumberPointer& shapePlumber, bool opaquePass) : _shapePlumber(shapePlumber), _opaquePass(opaquePass) {} diff --git a/libraries/render-utils/src/RenderHUDLayerTask.cpp b/libraries/render-utils/src/RenderHUDLayerTask.cpp index 840d9e8002..743e59eebc 100644 --- a/libraries/render-utils/src/RenderHUDLayerTask.cpp +++ b/libraries/render-utils/src/RenderHUDLayerTask.cpp @@ -47,14 +47,15 @@ void RenderHUDLayerTask::build(JobModel& task, const render::Varying& input, ren const auto& lightingModel = inputs[1]; const auto& hudOpaque = inputs[2]; const auto& hudTransparent = inputs[3]; + const auto& hazeFrame = inputs[4]; // Composite the HUD and HUD overlays task.addJob("HUD", primaryFramebuffer); // And HUD Layer objects const auto nullJitter = Varying(glm::vec2(0.0f, 0.0f)); - const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, nullJitter).asVarying(); - const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, nullJitter).asVarying(); + const auto hudOpaquesInputs = DrawLayered3D::Inputs(hudOpaque, lightingModel, hazeFrame, nullJitter).asVarying(); + const auto hudTransparentsInputs = DrawLayered3D::Inputs(hudTransparent, lightingModel, hazeFrame, nullJitter).asVarying(); task.addJob("DrawHUDOpaque", hudOpaquesInputs, true); task.addJob("DrawHUDTransparent", hudTransparentsInputs, false); } diff --git a/libraries/render-utils/src/RenderHUDLayerTask.h b/libraries/render-utils/src/RenderHUDLayerTask.h index 78cd009636..c30b0498a8 100644 --- a/libraries/render-utils/src/RenderHUDLayerTask.h +++ b/libraries/render-utils/src/RenderHUDLayerTask.h @@ -10,7 +10,7 @@ #define hifi_RenderHUDLayerTask_h #include "LightingModel.h" - +#include "HazeStage.h" class CompositeHUD { public: @@ -25,7 +25,7 @@ public: class RenderHUDLayerTask { public: // Framebuffer where to draw, lighting model, opaque items, transparent items - using Input = render::VaryingSet4; + using Input = render::VaryingSet5; using JobModel = render::Task::ModelI; void build(JobModel& task, const render::Varying& input, render::Varying& output); diff --git a/libraries/render-utils/src/directional_skybox_light.slf b/libraries/render-utils/src/directional_skybox_light.slf index 4ef7621b36..8e2b38b478 100644 --- a/libraries/render-utils/src/directional_skybox_light.slf +++ b/libraries/render-utils/src/directional_skybox_light.slf @@ -15,7 +15,7 @@ <@include render-utils/ShaderConstants.h@> <@include GlobalLight.slh@> -<$declareEvalSkyboxGlobalColor(isScattering)$> +<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$> layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy diff --git a/libraries/render-utils/src/directional_skybox_light_shadow.slf b/libraries/render-utils/src/directional_skybox_light_shadow.slf index 217cf3ba05..2f289ed00f 100644 --- a/libraries/render-utils/src/directional_skybox_light_shadow.slf +++ b/libraries/render-utils/src/directional_skybox_light_shadow.slf @@ -15,7 +15,7 @@ <@include render-utils/ShaderConstants.h@> <@include GlobalLight.slh@> -<$declareEvalSkyboxGlobalColor(isScattering)$> +<$declareEvalSkyboxGlobalColor(isScattering, _SCRIBE_NULL)$> <@include Shadow.slh@> diff --git a/libraries/render-utils/src/model.slf b/libraries/render-utils/src/model.slf index b3167dd598..3e4711dac8 100644 --- a/libraries/render-utils/src/model.slf +++ b/libraries/render-utils/src/model.slf @@ -26,7 +26,7 @@ <@endif@> <$declareEvalGlobalLightingAlphaBlended()$> <@else@> - <$declareEvalSkyboxGlobalColor()$> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> <@endif@> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> @@ -195,6 +195,7 @@ void main(void) { <@else@> vec3 fragNormalWS = _normalWS; <@endif@> + fragNormalWS = normalize(fragNormalWS); <@if HIFI_USE_FORWARD@> TransformCamera cam = getTransformCamera(); @@ -253,7 +254,7 @@ void main(void) { <@if not HIFI_USE_TRANSLUCENT@> <@if not HIFI_USE_LIGHTMAP@> packDeferredFragment( - normalize(fragNormalWS), + fragNormalWS, opacity, albedo, roughness, @@ -267,7 +268,7 @@ void main(void) { scattering); <@else@> packDeferredFragmentLightmap( - normalize(fragNormalWS), + fragNormalWS, evalOpaqueFinalAlpha(getMaterialOpacity(mat), opacity), albedo, roughness, @@ -301,7 +302,7 @@ void main(void) { 1.0, occlusion, _positionES.xyz, - fragPositionWS, + fragNormalWS, albedo, fresnel, metallic, diff --git a/libraries/render-utils/src/render-utils/ShaderConstants.h b/libraries/render-utils/src/render-utils/ShaderConstants.h index 76c8dd4981..19eb4dd249 100644 --- a/libraries/render-utils/src/render-utils/ShaderConstants.h +++ b/libraries/render-utils/src/render-utils/ShaderConstants.h @@ -68,7 +68,6 @@ #define RENDER_UTILS_BUFFER_LIGHT_CLUSTER_CONTENT 12 // Haze -#define RENDER_UTILS_BUFFER_HAZE_PARAMS 7 #define RENDER_UTILS_TEXTURE_HAZE_COLOR 0 #define RENDER_UTILS_TEXTURE_HAZE_LINEAR_DEPTH 1 @@ -143,7 +142,6 @@ enum Buffer { DeferredFrameTransform = RENDER_UTILS_BUFFER_DEFERRED_FRAME_TRANSFORM, LightModel = RENDER_UTILS_BUFFER_LIGHT_MODEL, AmbientLight = RENDER_UTILS_BUFFER_AMBIENT_LIGHT, - HazeParams = RENDER_UTILS_BUFFER_HAZE_PARAMS, FadeParameters = RENDER_UTILS_BUFFER_FADE_PARAMS, FadeObjectParameters = RENDER_UTILS_BUFFER_FADE_OBJECT_PARAMS, LightClusterFrustumGrid = RENDER_UTILS_BUFFER_LIGHT_CLUSTER_FRUSTUM_GRID, diff --git a/libraries/render-utils/src/sdf_text3D.slf b/libraries/render-utils/src/sdf_text3D.slf index a5a7cfb6a4..ac064e5c8f 100644 --- a/libraries/render-utils/src/sdf_text3D.slf +++ b/libraries/render-utils/src/sdf_text3D.slf @@ -13,10 +13,10 @@ <@include DefaultMaterials.slh@> <@include GlobalLight.slh@> - <@if HIFI_USE_FORWARD@> - <$declareEvalSkyboxGlobalColor()$> - <@else@> + <@if HIFI_USE_TRANSLUCENT@> <$declareEvalGlobalLightingAlphaBlended()$> + <@else@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> <@endif@> <@include gpu/Transform.slh@> @@ -65,19 +65,7 @@ void main() { 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@> + <@if HIFI_USE_TRANSLUCENT@> _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, @@ -90,6 +78,18 @@ void main() { DEFAULT_EMISSIVE, DEFAULT_ROUGHNESS, alpha), alpha); + <@else@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS), + _color.rgb, + DEFAULT_FRESNEL, + DEFAULT_METALLIC, + DEFAULT_ROUGHNESS), + alpha); <@endif@> <@else@> packDeferredFragment( diff --git a/libraries/render-utils/src/simple.slf b/libraries/render-utils/src/simple.slf index ac7deedff0..9760216682 100644 --- a/libraries/render-utils/src/simple.slf +++ b/libraries/render-utils/src/simple.slf @@ -26,12 +26,12 @@ <@endif@> <@if not HIFI_USE_UNLIT@> - <@if HIFI_USE_FORWARD@> - <@include GlobalLight.slh@> - <$declareEvalSkyboxGlobalColor()$> - <@elif HIFI_USE_TRANSLUCENT@> + <@if HIFI_USE_TRANSLUCENT@> <@include GlobalLight.slh@> <$declareEvalGlobalLightingAlphaBlended()$> + <@elif HIFI_USE_FORWARD@> + <@include GlobalLight.slh@> + <$declareEvalSkyboxGlobalColor(_SCRIBE_NULL, HIFI_USE_FORWARD)$> <@else@> <@include DeferredBufferWrite.slh@> <@endif@> @@ -88,19 +88,7 @@ void main(void) { <@endif@> <@if not HIFI_USE_UNLIT@> - <@if HIFI_USE_FORWARD@> - _fragColor0 = vec4(evalSkyboxGlobalColor( - cam._viewInverse, - 1.0, - DEFAULT_OCCLUSION, - fragPosition, - normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), - texel.rgb, - fresnel, - metallic, - DEFAULT_ROUGHNESS), - texel.a); - <@elif HIFI_USE_TRANSLUCENT@> + <@if HIFI_USE_TRANSLUCENT@> _fragColor0 = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, @@ -117,6 +105,18 @@ void main(void) { , DEFAULT_ROUGHNESS, texel.a), texel.a); + <@elif HIFI_USE_FORWARD@> + _fragColor0 = vec4(evalSkyboxGlobalColor( + cam._viewInverse, + 1.0, + DEFAULT_OCCLUSION, + fragPosition, + normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), + texel.rgb, + fresnel, + metallic, + DEFAULT_ROUGHNESS), + texel.a); <@else@> packDeferredFragment( normalize(_normalWS) * (2.0 * float(gl_FrontFacing) - 1.0), diff --git a/libraries/render-utils/src/web_browser.slf b/libraries/render-utils/src/web_browser.slf index 7898df1c4c..73745edf9e 100644 --- a/libraries/render-utils/src/web_browser.slf +++ b/libraries/render-utils/src/web_browser.slf @@ -21,7 +21,9 @@ LAYOUT(binding=0) uniform sampler2D webTexture; -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; +<@if not HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; +<@endif@> layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01; #define _texCoord0 _texCoord01.xy diff --git a/libraries/render-utils/src/web_browser.slv b/libraries/render-utils/src/web_browser.slv index 019486fbf3..d8da7d730b 100644 --- a/libraries/render-utils/src/web_browser.slv +++ b/libraries/render-utils/src/web_browser.slv @@ -17,7 +17,9 @@ <@include render-utils/ShaderConstants.h@> -layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +<@if not HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; +<@endif@> layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; layout(location=RENDER_UTILS_ATTR_TEXCOORD01) out vec4 _texCoord01; @@ -28,5 +30,8 @@ void main(void) { TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> + +<@if not HIFI_USE_FORWARD@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> +<@endif@> } \ No newline at end of file diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 21af30c584..12947f5291 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -104,7 +104,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p locations->fadeMaskTextureUnit = reflection.validTexture(render_utils::slot::texture::FadeMask); locations->fadeParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::FadeParameters); locations->fadeObjectParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::FadeObjectParameters); - locations->hazeParameterBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::HazeParams); + locations->hazeParameterBufferUnit = reflection.validUniformBuffer(graphics::slot::buffer::HazeParams); if (key.isTranslucent()) { locations->lightClusterGridBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::LightClusterGrid); locations->lightClusterContentBufferUnit = reflection.validUniformBuffer(render_utils::slot::buffer::LightClusterContent); @@ -134,7 +134,7 @@ const ShapePipelinePointer ShapePlumber::pickPipeline(RenderArgs* args, const Ke auto factoryIt = ShapePipeline::_globalCustomFactoryMap.find(key.getCustom()); if ((factoryIt != ShapePipeline::_globalCustomFactoryMap.end()) && (factoryIt)->second) { // found a factory for the custom key, can now generate a shape pipeline for this case: - addPipelineHelper(Filter(key), key, 0, (factoryIt)->second(*this, key, *(args->_batch))); + addPipelineHelper(Filter(key), key, 0, (factoryIt)->second(*this, key, args)); return pickPipeline(args, key); } else { diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index ad91ea61ef..cf41c85dd9 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -272,7 +272,7 @@ protected: ItemSetter _itemSetter; public: using CustomKey = uint8_t; - using CustomFactory = std::function (const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch)>; + using CustomFactory = std::function (const ShapePlumber& plumber, const ShapeKey& key, RenderArgs* args)>; using CustomFactoryMap = std::map; static CustomFactoryMap _globalCustomFactoryMap; From 953966474944028f8818321d44f7c14a6144da0b Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 11 Jul 2019 10:58:48 -0700 Subject: [PATCH 06/10] add haze to skybox --- cmake/macros/AutoScribeShader.cmake | 2 ++ libraries/graphics/src/graphics/skybox.slf | 25 ++++++++++++++++++++-- libraries/render-utils/src/Haze.slf | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/cmake/macros/AutoScribeShader.cmake b/cmake/macros/AutoScribeShader.cmake index 63f7c0c7d6..f0f1fe1d05 100755 --- a/cmake/macros/AutoScribeShader.cmake +++ b/cmake/macros/AutoScribeShader.cmake @@ -319,6 +319,7 @@ macro(AUTOSCRIBE_SHADER_LIB) unset(SHADER_FILE) unset(SHADER_FILE CACHE) find_file(SHADER_FILE "${VERTEX_NAME}.slv" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") + message("boop ${SHADER_FILE} ${VERTEX_NAME} ${PROGRAM_FOLDER}") AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}") else() @@ -337,6 +338,7 @@ macro(AUTOSCRIBE_SHADER_LIB) unset(SHADER_FILE) unset(SHADER_FILE CACHE) find_file(SHADER_FILE "${FRAGMENT_NAME}.slf" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") + message("boop2 ${SHADER_FILE} ${FRAGMENT_NAME} ${PROGRAM_FOLDER}") AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}") else() diff --git a/libraries/graphics/src/graphics/skybox.slf b/libraries/graphics/src/graphics/skybox.slf index 0dea1d7882..4ae53a657f 100755 --- a/libraries/graphics/src/graphics/skybox.slf +++ b/libraries/graphics/src/graphics/skybox.slf @@ -12,6 +12,12 @@ <@include graphics/ShaderConstants.h@> <@if HIFI_USE_FORWARD@> + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + <@include graphics/Light.slh@> + <$declareLightBuffer()$> + <@include graphics/Haze.slh@> <@endif@> @@ -35,13 +41,28 @@ void main(void) { // mix(skyboxColor, skyboxTexel, skybox.color.a) // and the blend factor should be user controlled - vec3 skyboxTexel = texture(cubeMap, normalize(_normal)).rgb; + vec3 normal = normalize(_normal); + vec3 skyboxTexel = texture(cubeMap, normal).rgb; vec3 skyboxColor = skybox.color.rgb; _fragColor = vec4(mix(vec3(1.0), skyboxTexel, float(skybox.color.a > 0.0)) * mix(vec3(1.0), skyboxColor, float(skybox.color.a < 1.0)), 1.0); <@if HIFI_USE_FORWARD@> - _fragColor = vec4(hazeParams.hazeColor, 1); + // FIXME: either move this elsewhere or give it access to isHazeEnabled() (which is in render-utils/LightingModel.slh) + if (/*(isHazeEnabled() > 0.0) && */(hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + TransformCamera cam = getTransformCamera(); + vec4 eyePositionWS = cam._viewInverse[3]; + // We choose an arbitrary large number > BLEND_DISTANCE in Haze.slh + const float SKYBOX_DISTANCE = 32000.0; + vec4 fragPositionWS = eyePositionWS + SKYBOX_DISTANCE * vec4(normal, 0.0); + vec4 fragPositionES = cam._view * fragPositionWS; + + Light light = getKeyLight(); + vec3 lightDirectionWS = getLightDirection(light); + + vec4 hazeColor = computeHazeColor(fragPositionES.xyz, fragPositionWS.xyz, eyePositionWS.xyz, lightDirectionWS); + _fragColor.rgb = mix(_fragColor.rgb, hazeColor.rgb, hazeColor.a); + } <@endif@> } diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 951841ad49..899f36b8eb 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -15,9 +15,9 @@ <$declareDeferredFrameTransform()$> <@include graphics/Light.slh@> +<$declareLightBuffer()$> <@include LightingModel.slh@> -<$declareLightBuffer()$> <@include graphics/Haze.slh@> From 22a7a97a9aadafd606b91081cfdb739aa5fd45bb Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 11 Jul 2019 12:23:04 -0700 Subject: [PATCH 07/10] fix forward web + parabola blending --- interface/src/raypick/ParabolaPointer.cpp | 6 ++---- libraries/render-utils/src/GeometryCache.cpp | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/interface/src/raypick/ParabolaPointer.cpp b/interface/src/raypick/ParabolaPointer.cpp index 961ce627a4..0589124db8 100644 --- a/interface/src/raypick/ParabolaPointer.cpp +++ b/interface/src/raypick/ParabolaPointer.cpp @@ -405,7 +405,8 @@ 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, parabola_forward), std::make_tuple(true, false, parabola_translucent) + std::make_tuple(false, false, parabola), std::make_tuple(false, true, parabola_forward), + std::make_tuple(true, false, parabola_translucent), std::make_tuple(true, true, parabola_forward) // The forward opaque/translucent pipelines are the same for now }; for (auto& key : keys) { @@ -423,9 +424,6 @@ gpu::PipelinePointer ParabolaPointer::RenderState::ParabolaRenderItem::getParabo _parabolaPipelines[{std::get<0>(key), std::get<1>(key)}] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state); } - - // The forward opaque/translucent pipelines are the same for now - _parabolaPipelines[{ true, true }] = _parabolaPipelines[{ false, true}]; } return _parabolaPipelines[{ _parabolaData.color.a < 1.0f, forward }]; } diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 0553bb56a3..2bd656a664 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -2119,7 +2119,7 @@ gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent, bool 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) + std::make_tuple(true, false, web_browser_translucent), std::make_tuple(true, true, web_browser_forward) // The forward opaque/translucent pipelines are the same for now }; for (auto& key : keys) { @@ -2134,9 +2134,6 @@ gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent, bool _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 }]; From 7793e07eeb4693dc38dfb77600c8e96a42870d7b Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 11 Jul 2019 13:34:58 -0700 Subject: [PATCH 08/10] fix polyvox --- libraries/entities-renderer/src/polyvox.slf | 3 +-- libraries/entities-renderer/src/polyvox.slv | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/libraries/entities-renderer/src/polyvox.slf b/libraries/entities-renderer/src/polyvox.slf index f08728dbcb..3456823081 100644 --- a/libraries/entities-renderer/src/polyvox.slf +++ b/libraries/entities-renderer/src/polyvox.slf @@ -39,7 +39,6 @@ <@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; @@ -81,7 +80,7 @@ void main(void) { vec4 xzDiffuse = texture(yMap, vec2(-inPositionX, inPositionZ)); vec4 yzDiffuse = texture(zMap, vec2(inPositionZ, -inPositionY)); - vec3 normalMS = normalize(_normalMS); + vec3 normalMS = normalize(cross(dFdy(_positionMS.xyz), dFdx(_positionMS.xyz))); vec3 xyDiffuseScaled = xyDiffuse.rgb * abs(normalMS.z); vec3 xzDiffuseScaled = xzDiffuse.rgb * abs(normalMS.y); vec3 yzDiffuseScaled = yzDiffuse.rgb * abs(normalMS.x); diff --git a/libraries/entities-renderer/src/polyvox.slv b/libraries/entities-renderer/src/polyvox.slv index 82ae741888..34547cef1a 100644 --- a/libraries/entities-renderer/src/polyvox.slv +++ b/libraries/entities-renderer/src/polyvox.slv @@ -24,7 +24,6 @@ <@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) { @@ -41,7 +40,6 @@ void main(void) { <@endif@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> - _normalMS = inNormal.xyz; _positionMS = inPosition.xyz; <@endif@> <@if HIFI_USE_FADE@> From 046b25ab67ecdeee8dc2276135afba24b7adb66c Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 11 Jul 2019 14:56:17 -0700 Subject: [PATCH 09/10] fix haze on web entities, deferred and forward --- libraries/render-utils/src/GeometryCache.cpp | 16 +++--- .../src/render-utils/web_browser.slp | 2 +- libraries/render-utils/src/web_browser.slf | 50 +++++++++++++++---- libraries/render-utils/src/web_browser.slv | 10 ++-- 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/libraries/render-utils/src/GeometryCache.cpp b/libraries/render-utils/src/GeometryCache.cpp index 2bd656a664..997f87b8d6 100644 --- a/libraries/render-utils/src/GeometryCache.cpp +++ b/libraries/render-utils/src/GeometryCache.cpp @@ -2117,22 +2117,24 @@ void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent, b 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), std::make_tuple(true, true, web_browser_forward) // The forward opaque/translucent pipelines are the same for now - }; + const int NUM_WEB_PIPELINES = 4; + for (int i = 0; i < NUM_WEB_PIPELINES; ++i) { + bool transparent = i & 1; + bool forward = i & 2; + + // For any non-opaque or non-deferred pipeline, we use web_browser_forward + auto pipeline = (transparent || forward) ? web_browser_forward : web_browser; - 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), + state->setBlendFunction(transparent, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); state->setCullMode(gpu::State::CULL_NONE); - _webPipelines[{std::get<0>(key), std::get<1>(key)}] = gpu::Pipeline::create(gpu::Shader::createProgram(std::get<2>(key)), state); + _webPipelines[{ transparent, forward }] = gpu::Pipeline::create(gpu::Shader::createProgram(pipeline), state); } } diff --git a/libraries/render-utils/src/render-utils/web_browser.slp b/libraries/render-utils/src/render-utils/web_browser.slp index e9942be5cd..e283f4edcb 100644 --- a/libraries/render-utils/src/render-utils/web_browser.slp +++ b/libraries/render-utils/src/render-utils/web_browser.slp @@ -1 +1 @@ -DEFINES translucent:f/forward:f \ No newline at end of file +DEFINES forward \ No newline at end of file diff --git a/libraries/render-utils/src/web_browser.slf b/libraries/render-utils/src/web_browser.slf index 73745edf9e..f746916d3d 100644 --- a/libraries/render-utils/src/web_browser.slf +++ b/libraries/render-utils/src/web_browser.slf @@ -13,15 +13,27 @@ <@include gpu/Color.slh@> <@include render-utils/ShaderConstants.h@> -<@if not HIFI_USE_FORWARD@> - <@include DeferredBufferWrite.slh@> -<@else@> +<@if HIFI_USE_FORWARD@> + <@include LightingModel.slh@> + <@include graphics/Haze.slh@> + + <@include gpu/Transform.slh@> + <$declareStandardCameraTransform()$> + + <@include graphics/Light.slh@> + <$declareLightBuffer()$> + layout(location=0) out vec4 _fragColor0; +<@else@> + <@include DeferredBufferWrite.slh@> <@endif@> LAYOUT(binding=0) uniform sampler2D webTexture; -<@if not HIFI_USE_FORWARD@> +<@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; + layout(location=RENDER_UTILS_ATTR_POSITION_ES) in vec4 _positionES; +<@else@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS; <@endif@> layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color; @@ -34,13 +46,29 @@ void main(void) { texel = color_sRGBAToLinear(texel); 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@> +<@if HIFI_USE_FORWARD@> _fragColor0 = texel; + + if (isHazeEnabled() > 0.0) { + // no light attenuation because we're unlit + + TransformCamera cam = getTransformCamera(); + + Light light = getKeyLight(); + vec3 lightDirectionWS = getLightDirection(light); + + if ((hazeParams.hazeMode & HAZE_MODE_IS_ACTIVE) == HAZE_MODE_IS_ACTIVE) { + vec4 hazeColor = computeHazeColor( + _positionES.xyz, + _positionWS.xyz, + cam._viewInverse[3].xyz, + lightDirectionWS + ); + + _fragColor0.xyz = mix(_fragColor0.rgb, hazeColor.rgb, hazeColor.a); + } + } +<@else@> + packDeferredFragmentUnlit(normalize(_normalWS), 1.0, texel.rgb); <@endif@> } diff --git a/libraries/render-utils/src/web_browser.slv b/libraries/render-utils/src/web_browser.slv index d8da7d730b..07b4d7d3d7 100644 --- a/libraries/render-utils/src/web_browser.slv +++ b/libraries/render-utils/src/web_browser.slv @@ -17,7 +17,10 @@ <@include render-utils/ShaderConstants.h@> -<@if not HIFI_USE_FORWARD@> +<@if HIFI_USE_FORWARD@> + layout(location=RENDER_UTILS_ATTR_POSITION_WS) out vec4 _positionWS; + layout(location=RENDER_UTILS_ATTR_POSITION_ES) out vec4 _positionES; +<@else@> layout(location=RENDER_UTILS_ATTR_NORMAL_WS) out vec3 _normalWS; <@endif@> layout(location=RENDER_UTILS_ATTR_COLOR) out vec4 _color; @@ -29,9 +32,10 @@ void main(void) { TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); +<@if HIFI_USE_FORWARD@> + <$transformModelToWorldAndEyeAndClipPos(cam, obj, inPosition, _positionWS, _positionES, gl_Position)$> +<@else@> <$transformModelToClipPos(cam, obj, inPosition, gl_Position)$> - -<@if not HIFI_USE_FORWARD@> <$transformModelToWorldDir(cam, obj, inNormal.xyz, _normalWS)$> <@endif@> } \ No newline at end of file From bda87aa13ff93826050161e55f6f3193bb9472c2 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 11 Jul 2019 16:32:35 -0700 Subject: [PATCH 10/10] trying to fix android --- cmake/macros/AutoScribeShader.cmake | 17 +++++++++-------- libraries/entities-renderer/src/paintStroke.slv | 3 --- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cmake/macros/AutoScribeShader.cmake b/cmake/macros/AutoScribeShader.cmake index f0f1fe1d05..20aa334134 100755 --- a/cmake/macros/AutoScribeShader.cmake +++ b/cmake/macros/AutoScribeShader.cmake @@ -316,10 +316,11 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_FRAGMENT EQUAL -1) set(DEFINES "${VERTEX_DEFINES}") set(SHADER_LIST "") - unset(SHADER_FILE) - unset(SHADER_FILE CACHE) - find_file(SHADER_FILE "${VERTEX_NAME}.slv" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") - message("boop ${SHADER_FILE} ${VERTEX_NAME} ${PROGRAM_FOLDER}") + set(SHADER_FILE "${PROGRAM_FOLDER}/${VERTEX_NAME}.slv") + if (NOT EXISTS "${SHADER_FILE}") + set(SHADER_FILE "${PROGRAM_FOLDER}/../${VERTEX_NAME}.slv") + endif() + find_file(SHADER_FILE "" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES ".." NO_DEFAULT_PATH) AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT VERTEX_ENUMS "${VERTEX_ENUMS}" "${SHADER_LIST}") else() @@ -335,10 +336,10 @@ macro(AUTOSCRIBE_SHADER_LIB) if (HAS_VERTEX EQUAL -1) set(DEFINES "${FRAGMENT_DEFINES}") set(SHADER_LIST "") - unset(SHADER_FILE) - unset(SHADER_FILE CACHE) - find_file(SHADER_FILE "${FRAGMENT_NAME}.slf" PATHS "${PROGRAM_FOLDER}" PATH_SUFFIXES "..") - message("boop2 ${SHADER_FILE} ${FRAGMENT_NAME} ${PROGRAM_FOLDER}") + set(SHADER_FILE "${PROGRAM_FOLDER}/${FRAGMENT_NAME}.slf") + if (NOT EXISTS "${SHADER_FILE}") + set(SHADER_FILE "${PROGRAM_FOLDER}/../${FRAGMENT_NAME}.slf") + endif() AUTOSCRIBE_SHADER(${ALL_SHADER_HEADERS}) string(CONCAT FRAGMENT_ENUMS "${FRAGMENT_ENUMS}" "${SHADER_LIST}") else() diff --git a/libraries/entities-renderer/src/paintStroke.slv b/libraries/entities-renderer/src/paintStroke.slv index 2a2025e59f..9a44223dd4 100644 --- a/libraries/entities-renderer/src/paintStroke.slv +++ b/libraries/entities-renderer/src/paintStroke.slv @@ -3,9 +3,6 @@ // <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // -// paintStroke.vert -// vertex shader -// // Created by Eric Levin on 7/20/15. // Copyright 2014 High Fidelity, Inc. //