mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Moving to cmake time shader compiling
This commit is contained in:
parent
d6bcdcde3f
commit
04e84f1d23
61 changed files with 883 additions and 1111 deletions
|
@ -8,6 +8,12 @@
|
|||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
function(global_append varName varValue)
|
||||
get_property(LOCAL_LIST GLOBAL PROPERTY ${varName})
|
||||
list(APPEND LOCAL_LIST ${varValue})
|
||||
set_property(GLOBAL PROPERTY ${varName} ${LOCAL_LIST})
|
||||
endfunction()
|
||||
|
||||
function(AUTOSCRIBE_SHADER SHADER_FILE)
|
||||
# Grab include files
|
||||
foreach(includeFile ${ARGN})
|
||||
|
@ -45,11 +51,8 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
|
|||
elseif(${SHADER_EXT} STREQUAL .slg)
|
||||
set(SHADER_TYPE geom)
|
||||
endif()
|
||||
set(SHADER_TARGET ${SHADER_TARGET}_${SHADER_TYPE})
|
||||
|
||||
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_TARGET}")
|
||||
set(SHADER_TARGET_HEADER ${SHADER_TARGET}.h)
|
||||
set(SHADER_TARGET_SOURCE ${SHADER_TARGET}.cpp)
|
||||
file(MAKE_DIRECTORY "${SHADERS_DIR}/${SHADER_LIB}")
|
||||
set(SHADER_TARGET "${SHADERS_DIR}/${SHADER_LIB}/${SHADER_TARGET}.${SHADER_TYPE}")
|
||||
set(SCRIBE_COMMAND scribe)
|
||||
|
||||
# Target dependant Custom rule on the SHADER_FILE
|
||||
|
@ -63,65 +66,200 @@ function(AUTOSCRIBE_SHADER SHADER_FILE)
|
|||
else ()
|
||||
set(GLPROFILE PC_GL)
|
||||
endif()
|
||||
set(SCRIBE_ARGS -c++ -T ${SHADER_TYPE} -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
|
||||
set(SCRIBE_ARGS -T ${SHADER_TYPE} -D GLPROFILE ${GLPROFILE} ${SCRIBE_INCLUDES} -o ${SHADER_TARGET} ${SHADER_FILE})
|
||||
add_custom_command(
|
||||
OUTPUT ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE}
|
||||
OUTPUT ${SHADER_TARGET}
|
||||
COMMAND ${SCRIBE_COMMAND} ${SCRIBE_ARGS}
|
||||
DEPENDS ${SCRIBE_COMMAND} ${SHADER_INCLUDE_FILES} ${SHADER_FILE}
|
||||
DEPENDS ${SHADER_FILE} ${SCRIBE_COMMAND} ${SHADER_INCLUDE_FILES}
|
||||
)
|
||||
|
||||
#output the generated file name
|
||||
set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET_HEADER} ${SHADER_TARGET_SOURCE} PARENT_SCOPE)
|
||||
|
||||
file(GLOB INCLUDE_FILES ${SHADER_TARGET_HEADER})
|
||||
|
||||
set(AUTOSCRIBE_SHADER_RETURN ${SHADER_TARGET} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
macro(AUTOSCRIBE_APPEND_SHADER_SOURCES)
|
||||
if (NOT("${ARGN}" STREQUAL ""))
|
||||
set_property(GLOBAL PROPERTY ${TARGET_NAME}_SHADER_SOURCES "${ARGN}")
|
||||
global_append(GLOBAL_SHADER_LIBS ${TARGET_NAME})
|
||||
global_append(GLOBAL_SHADER_SOURCES "${ARGN}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(AUTOSCRIBE_SHADER_LIB)
|
||||
set(GLOBAL_SHADER_SOURCES "")
|
||||
set(HIFI_LIBRARIES_SHADER_INCLUDE_FILES "")
|
||||
set(SRC_FOLDER "${CMAKE_SOURCE_DIR}/libraries/${TARGET_NAME}/src")
|
||||
file(GLOB_RECURSE SHADER_INCLUDE_FILES ${SRC_FOLDER}/*.slh)
|
||||
file(GLOB_RECURSE SHADER_VERTEX_FILES ${SRC_FOLDER}/*.slv)
|
||||
file(GLOB_RECURSE SHADER_FRAGMENT_FILES ${SRC_FOLDER}/*.slf)
|
||||
file(GLOB_RECURSE SHADER_GEOMETRY_FILES ${SRC_FOLDER}/*.slg)
|
||||
file(GLOB_RECURSE SHADER_COMPUTE_FILES ${SRC_FOLDER}/*.slc)
|
||||
|
||||
list(APPEND SHADER_SOURCE_FILES ${SHADER_VERTEX_FILES})
|
||||
list(APPEND SHADER_SOURCE_FILES ${SHADER_FRAGMENT_FILES})
|
||||
list(APPEND SHADER_SOURCE_FILES ${SHADER_GEOMETRY_FILES})
|
||||
list(APPEND SHADER_SOURCE_FILES ${SHADER_COMPUTE_FILES})
|
||||
|
||||
list(APPEND GLOBAL_SHADER_SOURCES ${SHADER_SOURCE_FILES})
|
||||
list(APPEND GLOBAL_SHADER_SOURCES ${SHADER_INCLUDE_FILES})
|
||||
AUTOSCRIBE_APPEND_SHADER_SOURCES(${GLOBAL_SHADER_SOURCES})
|
||||
|
||||
file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}")
|
||||
foreach(HIFI_LIBRARY ${ARGN})
|
||||
#if (NOT TARGET ${HIFI_LIBRARY})
|
||||
# file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}/src/)
|
||||
#endif ()
|
||||
|
||||
#file(GLOB_RECURSE HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src/*.slh)
|
||||
list(APPEND HIFI_LIBRARIES_SHADER_INCLUDE_FILES ${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src)
|
||||
endforeach()
|
||||
#message("${TARGET_NAME} ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES}")
|
||||
endmacro()
|
||||
|
||||
file(GLOB_RECURSE SHADER_INCLUDE_FILES src/*.slh)
|
||||
file(GLOB_RECURSE SHADER_SOURCE_FILES src/*.slv src/*.slf src/*.slg)
|
||||
macro(AUTOSCRIBE_PROGRAM)
|
||||
set(oneValueArgs NAME VERTEX FRAGMENT GEOMETRY COMPUTE)
|
||||
cmake_parse_arguments(AUTOSCRIBE_PROGRAM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
if (NOT (DEFINED AUTOSCRIBE_PROGRAM_NAME))
|
||||
message(FATAL_ERROR "Programs must have a name and both a vertex and fragment shader")
|
||||
endif()
|
||||
if (NOT (DEFINED AUTOSCRIBE_PROGRAM_VERTEX))
|
||||
set(AUTOSCRIBE_PROGRAM_VERTEX ${AUTOSCRIBE_PROGRAM_NAME})
|
||||
endif()
|
||||
if (NOT (DEFINED AUTOSCRIBE_PROGRAM_FRAGMENT))
|
||||
set(AUTOSCRIBE_PROGRAM_FRAGMENT ${AUTOSCRIBE_PROGRAM_NAME})
|
||||
endif()
|
||||
|
||||
#make the shader folder
|
||||
set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders/${TARGET_NAME}")
|
||||
file(MAKE_DIRECTORY ${SHADERS_DIR})
|
||||
if (NOT (${AUTOSCRIBE_PROGRAM_VERTEX} MATCHES ".*::.*"))
|
||||
set(AUTOSCRIBE_PROGRAM_VERTEX "vertex::${AUTOSCRIBE_PROGRAM_VERTEX}")
|
||||
endif()
|
||||
if (NOT (${AUTOSCRIBE_PROGRAM_FRAGMENT} MATCHES ".*::.*"))
|
||||
set(AUTOSCRIBE_PROGRAM_FRAGMENT "fragment::${AUTOSCRIBE_PROGRAM_FRAGMENT}")
|
||||
endif()
|
||||
|
||||
#message("${TARGET_NAME} ${SHADER_INCLUDE_FILES}")
|
||||
set(AUTOSCRIBE_SHADER_SRC "")
|
||||
foreach(SHADER_FILE ${SHADER_SOURCE_FILES})
|
||||
AUTOSCRIBE_SHADER(${SHADER_FILE} ${SHADER_INCLUDE_FILES})
|
||||
unset(AUTOSCRIBE_PROGRAM_MAP)
|
||||
list(APPEND AUTOSCRIBE_PROGRAM_MAP AUTOSCRIBE_PROGRAM_VERTEX)
|
||||
list(APPEND AUTOSCRIBE_PROGRAM_MAP ${AUTOSCRIBE_PROGRAM_VERTEX})
|
||||
list(APPEND AUTOSCRIBE_PROGRAM_MAP AUTOSCRIBE_PROGRAM_FRAGMENT)
|
||||
list(APPEND AUTOSCRIBE_PROGRAM_MAP ${AUTOSCRIBE_PROGRAM_FRAGMENT})
|
||||
global_append(${TARGET_NAME}_PROGRAMS ${AUTOSCRIBE_PROGRAM_NAME})
|
||||
set_property(GLOBAL PROPERTY ${AUTOSCRIBE_PROGRAM_NAME} "${AUTOSCRIBE_PROGRAM_MAP}")
|
||||
endmacro()
|
||||
|
||||
macro(unpack_map)
|
||||
set(MAP_VAR "${ARGN}")
|
||||
list(LENGTH MAP_VAR MAP_SIZE)
|
||||
MATH(EXPR MAP_ENTRY_RANGE "(${MAP_SIZE} / 2) - 1")
|
||||
foreach(INDEX RANGE ${MAP_ENTRY_RANGE})
|
||||
MATH(EXPR INDEX_NAME "${INDEX} * 2")
|
||||
MATH(EXPR INDEX_VAL "${INDEX_NAME} + 1")
|
||||
list(GET MAP_VAR ${INDEX_NAME} VAR_NAME)
|
||||
list(GET MAP_VAR ${INDEX_VAL} VAR_VAL)
|
||||
set(${VAR_NAME} ${VAR_VAL})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
macro(PROCESS_SHADER_FILE)
|
||||
AUTOSCRIBE_SHADER(${SHADER} ${ALL_SHADER_HEADERS} ${HIFI_LIBRARIES_SHADER_INCLUDE_FILES})
|
||||
file(TO_CMAKE_PATH "${AUTOSCRIBE_SHADER_RETURN}" AUTOSCRIBE_GENERATED_FILE)
|
||||
set_property(SOURCE ${AUTOSCRIBE_GENERATED_FILE} PROPERTY SKIP_AUTOMOC ON)
|
||||
list(APPEND AUTOSCRIBE_SHADER_SRC ${AUTOSCRIBE_GENERATED_FILE})
|
||||
endforeach()
|
||||
#message(${TARGET_NAME} ${AUTOSCRIBE_SHADER_SRC})
|
||||
|
||||
if (WIN32)
|
||||
source_group("Shaders" FILES ${SHADER_INCLUDE_FILES})
|
||||
source_group("Shaders" FILES ${SHADER_SOURCE_FILES})
|
||||
source_group("Shaders\\generated" FILES ${AUTOSCRIBE_SHADER_SRC})
|
||||
endif()
|
||||
|
||||
list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${SHADER_INCLUDE_FILES})
|
||||
list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${SHADER_SOURCE_FILES})
|
||||
list(APPEND AUTOSCRIBE_SHADER_LIB_SRC ${AUTOSCRIBE_SHADER_SRC})
|
||||
|
||||
# Link library shaders, if they exist
|
||||
include_directories("${SHADERS_DIR}")
|
||||
|
||||
# Add search directory to find gpu/Shader.h
|
||||
include_directories("${HIFI_LIBRARY_DIR}/gpu/src")
|
||||
|
||||
source_group("Compiled/${SHADER_LIB}" FILES ${AUTOSCRIBE_GENERATED_FILE})
|
||||
list(APPEND COMPILED_SHADERS ${AUTOSCRIBE_GENERATED_FILE})
|
||||
get_filename_component(ENUM_NAME ${SHADER} NAME_WE)
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${ENUM_NAME} = ${SHADER_COUNT},\n")
|
||||
MATH(EXPR SHADER_COUNT "${SHADER_COUNT}+1")
|
||||
endmacro()
|
||||
|
||||
macro(AUTOSCRIBE_SHADER_FINISH)
|
||||
get_property(GLOBAL_SHADER_LIBS GLOBAL PROPERTY GLOBAL_SHADER_LIBS)
|
||||
list(REMOVE_DUPLICATES GLOBAL_SHADER_LIBS)
|
||||
set(SHADER_COUNT 0)
|
||||
set(PROGRAM_COUNT 0)
|
||||
set(SHADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/shaders")
|
||||
set(SHADER_ENUMS "")
|
||||
file(MAKE_DIRECTORY ${SHADERS_DIR})
|
||||
|
||||
unset(COMPILED_SHADERS)
|
||||
foreach(SHADER_LIB ${GLOBAL_SHADER_LIBS})
|
||||
get_property(LIB_SHADER_SOURCES GLOBAL PROPERTY ${SHADER_LIB}_SHADER_SOURCES)
|
||||
get_property(LIB_PROGRAMS GLOBAL PROPERTY ${SHADER_LIB}_PROGRAMS)
|
||||
list(REMOVE_DUPLICATES LIB_SHADER_SOURCES)
|
||||
string(REGEX REPLACE "[-]" "_" SHADER_NAMESPACE ${SHADER_LIB})
|
||||
list(APPEND HIFI_LIBRARIES_SHADER_INCLUDE_FILES "${CMAKE_SOURCE_DIR}/libraries/${SHADER_LIB}/src")
|
||||
|
||||
unset(VERTEX_SHADERS)
|
||||
unset(FRAGMENT_SHADERS)
|
||||
unset(SHADER_HEADERS)
|
||||
|
||||
foreach(SHADER_FILE ${LIB_SHADER_SOURCES})
|
||||
if (SHADER_FILE MATCHES ".*\\.slv")
|
||||
list(APPEND VERTEX_SHADERS ${SHADER_FILE})
|
||||
elseif (SHADER_FILE MATCHES ".*\\.slf")
|
||||
list(APPEND FRAGMENT_SHADERS ${SHADER_FILE})
|
||||
elseif (SHADER_FILE MATCHES ".*\\.slh")
|
||||
list(APPEND SHADER_HEADERS ${SHADER_FILE})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (DEFINED SHADER_HEADERS)
|
||||
source_group("Shaders/${SHADER_LIB}/Headers" FILES ${SHADER_HEADERS})
|
||||
list(APPEND ALL_SHADER_HEADERS ${SHADER_HEADERS})
|
||||
endif()
|
||||
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace ${SHADER_NAMESPACE} {\n")
|
||||
if (DEFINED VERTEX_SHADERS)
|
||||
list(REMOVE_DUPLICATES VERTEX_SHADERS)
|
||||
source_group("Shaders/${SHADER_LIB}/Vertex" FILES ${VERTEX_SHADERS})
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace vertex { enum {\n")
|
||||
foreach(SHADER ${VERTEX_SHADERS})
|
||||
process_shader_file()
|
||||
endforeach()
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // vertex \n")
|
||||
endif()
|
||||
|
||||
if (DEFINED FRAGMENT_SHADERS)
|
||||
list(REMOVE_DUPLICATES FRAGMENT_SHADERS)
|
||||
source_group("Shaders/${SHADER_LIB}/Fragment" FILES ${FRAGMENT_SHADERS})
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace fragment { enum {\n")
|
||||
foreach(SHADER ${FRAGMENT_SHADERS})
|
||||
process_shader_file()
|
||||
endforeach()
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // fragment \n")
|
||||
endif()
|
||||
|
||||
if (DEFINED LIB_PROGRAMS)
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "namespace program { enum {\n")
|
||||
foreach(LIB_PROGRAM ${LIB_PROGRAMS})
|
||||
get_property(LIB_PROGRAM_MAP GLOBAL PROPERTY ${LIB_PROGRAM})
|
||||
unpack_map(${LIB_PROGRAM_MAP})
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "${LIB_PROGRAM} = (${AUTOSCRIBE_PROGRAM_VERTEX} << 16) | ${AUTOSCRIBE_PROGRAM_FRAGMENT},\n")
|
||||
MATH(EXPR PROGRAM_COUNT "${PROGRAM_COUNT}+1")
|
||||
list(APPEND SHADER_ALL_PROGRAMS "${SHADER_NAMESPACE}::program::${LIB_PROGRAM}")
|
||||
endforeach()
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "}; } // program \n")
|
||||
endif()
|
||||
string(CONCAT SHADER_ENUMS "${SHADER_ENUMS}" "} // namespace ${SHADER_NAMESPACE}\n")
|
||||
endforeach()
|
||||
|
||||
set(SHADER_PROGRAMS_ARRAY "")
|
||||
foreach(SHADER_PROGRAM ${SHADER_ALL_PROGRAMS})
|
||||
string(CONCAT SHADER_PROGRAMS_ARRAY "${SHADER_PROGRAMS_ARRAY}" " ${SHADER_PROGRAM},\n")
|
||||
endforeach()
|
||||
|
||||
set(SHADER_COUNT 0)
|
||||
foreach(COMPILED_SHADER ${COMPILED_SHADERS})
|
||||
string(CONCAT SHADER_QRC "${SHADER_QRC}" "<file alias=\"${SHADER_COUNT}\">${COMPILED_SHADER}</file>\n")
|
||||
MATH(EXPR SHADER_COUNT "${SHADER_COUNT}+1")
|
||||
endforeach()
|
||||
|
||||
configure_file(
|
||||
Shaders.cpp.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/shaders/Shaders.cpp
|
||||
)
|
||||
configure_file(
|
||||
Shaders.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/shaders/Shaders.h
|
||||
)
|
||||
configure_file(
|
||||
shaders.qrc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/shaders.qrc
|
||||
)
|
||||
set(AUTOSCRIBE_SHADER_LIB_SRC "${CMAKE_CURRENT_BINARY_DIR}/shaders/Shaders.h;${CMAKE_CURRENT_BINARY_DIR}/shaders/Shaders.cpp")
|
||||
set(QT_RESOURCES_FILE ${CMAKE_CURRENT_BINARY_DIR}/shaders.qrc)
|
||||
get_property(GLOBAL_SHADER_SOURCES GLOBAL PROPERTY GLOBAL_SHADER_SOURCES)
|
||||
list(REMOVE_DUPLICATES GLOBAL_SHADER_SOURCES)
|
||||
#add_custom_target(shader-sources SOURCES ${GLOBAL_SHADER_SOURCES} ${COMPILED_SHADERS} "${CMAKE_BINARY_DIR}/shaders/Shaders.h")
|
||||
endmacro()
|
||||
|
|
|
@ -19,12 +19,8 @@ function(LINK_HIFI_LIBRARIES)
|
|||
endforeach()
|
||||
|
||||
foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK})
|
||||
|
||||
include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src")
|
||||
include_directories("${CMAKE_BINARY_DIR}/libraries/${HIFI_LIBRARY}/shaders")
|
||||
|
||||
#add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY})
|
||||
|
||||
include_directories("${CMAKE_BINARY_DIR}/libraries/${HIFI_LIBRARY}")
|
||||
# link the actual library - it is static so don't bubble it up
|
||||
target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY})
|
||||
endforeach()
|
||||
|
|
|
@ -214,6 +214,7 @@ link_hifi_libraries(
|
|||
controllers plugins image trackers
|
||||
ui-plugins display-plugins input-plugins
|
||||
${PLATFORM_GL_BACKEND}
|
||||
shaders
|
||||
)
|
||||
|
||||
# include the binary directory of render-utils for shader includes
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
|
||||
#include <StencilMaskPass.h>
|
||||
#include <GeometryCache.h>
|
||||
|
||||
#include "render-utils/drawWorkloadProxy_vert.h"
|
||||
#include "render-utils/drawWorkloadView_vert.h"
|
||||
#include "render-utils/drawWorkloadProxy_frag.h"
|
||||
#include "render-utils/drawWorkloadView_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
|
||||
void GameSpaceToRender::configure(const Config& config) {
|
||||
|
@ -149,9 +145,7 @@ void GameWorkloadRenderItem::setAllViews(const workload::Views& views) {
|
|||
|
||||
const gpu::PipelinePointer GameWorkloadRenderItem::getProxiesPipeline() {
|
||||
if (!_drawAllProxiesPipeline) {
|
||||
auto vs = drawWorkloadProxy_vert::getShader();
|
||||
auto ps = drawWorkloadProxy_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::drawWorkloadProxy);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("workloadProxiesBuffer", 0));
|
||||
|
@ -173,9 +167,7 @@ const gpu::PipelinePointer GameWorkloadRenderItem::getProxiesPipeline() {
|
|||
|
||||
const gpu::PipelinePointer GameWorkloadRenderItem::getViewsPipeline() {
|
||||
if (!_drawAllViewsPipeline) {
|
||||
auto vs = drawWorkloadView_vert::getShader();
|
||||
auto ps = drawWorkloadView_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::drawWorkloadView);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("workloadViewsBuffer", 1));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
set(TARGET_NAME display-plugins)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu display-plugins)
|
||||
setup_hifi_library(Gui)
|
||||
link_hifi_libraries(shared plugins ui-plugins gl ui render-utils ${PLATFORM_GL_BACKEND})
|
||||
link_hifi_libraries(shared shaders plugins ui-plugins gl ui render-utils ${PLATFORM_GL_BACKEND})
|
||||
include_hifi_library_headers(gpu)
|
||||
include_hifi_library_headers(model-networking)
|
||||
include_hifi_library_headers(networking)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <gl/OffscreenGLCanvas.h>
|
||||
|
||||
#include <gpu/Texture.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
#include <gpu/gl/GLShared.h>
|
||||
#include <gpu/gl/GLBackend.h>
|
||||
#include <GeometryCache.h>
|
||||
|
@ -391,8 +391,8 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
|
||||
if (!_presentPipeline) {
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTexturePS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawUnitQuadTexcoord);
|
||||
auto ps = gpu::Shader::createPixel(shader::gpu::fragment::DrawTexture);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
@ -402,7 +402,7 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
}
|
||||
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawUnitQuadTexcoord);
|
||||
auto ps = gpu::Shader::createPixel(std::string(SRGB_TO_LINEAR_FRAG));
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
|
@ -413,8 +413,8 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
}
|
||||
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTexturePS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawUnitQuadTexcoord);
|
||||
auto ps = gpu::Shader::createPixel(shader::gpu::fragment::DrawTexture);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
@ -426,8 +426,8 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
}
|
||||
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTextureMirroredXPS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawUnitQuadTexcoord);
|
||||
auto ps = gpu::Shader::createPixel(shader::gpu::fragment::DrawTextureMirroredX);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
@ -439,8 +439,8 @@ void OpenGLDisplayPlugin::customizeContext() {
|
|||
}
|
||||
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTexturePS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawTransformUnitQuad);
|
||||
auto ps = gpu::Shader::createPixel(shader::gpu::fragment::DrawTexture);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#include <gl/GLWidget.h>
|
||||
#include <shared/NsightHelpers.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <gpu/gl/GLBackend.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include <TextureCache.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -34,8 +34,6 @@
|
|||
#include "../CompositorHelper.h"
|
||||
|
||||
#include "DesktopPreviewProvider.h"
|
||||
#include "render-utils/hmd_ui_vert.h"
|
||||
#include "render-utils/hmd_ui_frag.h"
|
||||
|
||||
static const QString MONO_PREVIEW = "Mono Preview";
|
||||
static const QString DISABLE_PREVIEW = "Disable Preview";
|
||||
|
@ -409,9 +407,7 @@ void HmdDisplayPlugin::HUDRenderer::build() {
|
|||
|
||||
void HmdDisplayPlugin::HUDRenderer::updatePipeline() {
|
||||
if (!pipeline) {
|
||||
auto vs = hmd_ui_vert::getShader();
|
||||
auto ps = hmd_ui_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::hmd_ui);
|
||||
gpu::Shader::makeProgram(*program, gpu::Shader::BindingSet());
|
||||
uniformsLocation = program->getUniformBuffers().findLocation("hudBuffer");
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
#include "InterleavedStereoDisplayPlugin.h"
|
||||
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <gpu/Pipeline.h>
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
static const char* INTERLEAVED_SRGB_TO_LINEAR_FRAG = R"SCRIBE(
|
||||
|
||||
|
@ -46,7 +46,7 @@ const QString InterleavedStereoDisplayPlugin::NAME("3D TV - Interleaved");
|
|||
void InterleavedStereoDisplayPlugin::customizeContext() {
|
||||
StereoDisplayPlugin::customizeContext();
|
||||
if (!_interleavedPresentPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto vs = gpu::Shader::createVertex(shader::gpu::vertex::DrawUnitQuadTexcoord);
|
||||
auto ps = gpu::Shader::createPixel(std::string(INTERLEAVED_SRGB_TO_LINEAR_FRAG));
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
set(TARGET_NAME entities-renderer)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics procedural render render-utils)
|
||||
setup_hifi_library(Network Script)
|
||||
link_hifi_libraries(shared workload gpu procedural graphics model-networking script-engine render render-utils image qml ui pointers)
|
||||
link_hifi_libraries(shared workload gpu shaders procedural graphics model-networking script-engine render render-utils image qml ui pointers)
|
||||
include_hifi_library_headers(networking)
|
||||
include_hifi_library_headers(gl)
|
||||
include_hifi_library_headers(ktx)
|
||||
|
@ -18,3 +17,4 @@ include_hifi_library_headers(graphics-scripting) # for Forward.h
|
|||
|
||||
target_bullet()
|
||||
target_polyvox()
|
||||
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
#include <StencilMaskPass.h>
|
||||
|
||||
#include <GeometryCache.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "textured_particle_vert.h"
|
||||
#include "textured_particle_frag.h"
|
||||
|
||||
using namespace render;
|
||||
using namespace render::entities;
|
||||
|
@ -36,10 +35,7 @@ static ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, co
|
|||
gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
PrepareStencil::testMask(*state);
|
||||
|
||||
auto vertShader = textured_particle_vert::getShader();
|
||||
auto fragShader = textured_particle_frag::getShader();
|
||||
|
||||
auto program = gpu::Shader::createProgram(vertShader, fragShader);
|
||||
auto program = gpu::Shader::createProgram(shader::entities_renderer::program::textured_particle);
|
||||
_texturedPipeline = texturedPipeline = gpu::Pipeline::create(program, state);
|
||||
|
||||
batch.runLambda([program] {
|
||||
|
|
|
@ -17,18 +17,13 @@
|
|||
#include <TextureCache.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
//#define POLYLINE_ENTITY_USE_FADE_EFFECT
|
||||
#ifdef POLYLINE_ENTITY_USE_FADE_EFFECT
|
||||
# include <FadeEffect.h>
|
||||
#endif
|
||||
|
||||
#include "paintStroke_vert.h"
|
||||
#include "paintStroke_frag.h"
|
||||
|
||||
#include "paintStroke_fade_vert.h"
|
||||
#include "paintStroke_fade_frag.h"
|
||||
|
||||
using namespace render;
|
||||
using namespace render::entities;
|
||||
|
||||
|
@ -48,9 +43,7 @@ struct PolyLineUniforms {
|
|||
|
||||
static render::ShapePipelinePointer shapePipelineFactory(const render::ShapePlumber& plumber, const render::ShapeKey& key, gpu::Batch& batch) {
|
||||
if (!polylinePipeline) {
|
||||
auto VS = paintStroke_vert::getShader();
|
||||
auto PS = paintStroke_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::entities_renderer::program::paintStroke);
|
||||
#ifdef POLYLINE_ENTITY_USE_FADE_EFFECT
|
||||
auto fadeVS = gpu::Shader::createVertex(std::string(paintStroke_fade_vert));
|
||||
auto fadePS = gpu::Shader::createPixel(std::string(paintStroke_fade_frag));
|
||||
|
|
|
@ -26,12 +26,9 @@
|
|||
#include <PhysicalEntitySimulation.h>
|
||||
#include <StencilMaskPass.h>
|
||||
|
||||
#include "EntityTreeRenderer.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "polyvox_vert.h"
|
||||
#include "polyvox_frag.h"
|
||||
#include "polyvox_fade_vert.h"
|
||||
#include "polyvox_fade_frag.h"
|
||||
#include "EntityTreeRenderer.h"
|
||||
|
||||
#ifdef POLYVOX_ENTITY_USE_FADE_EFFECT
|
||||
# include <FadeEffect.h>
|
||||
|
@ -72,11 +69,6 @@
|
|||
|
||||
#include "EntityTreeRenderer.h"
|
||||
|
||||
#include "polyvox_vert.h"
|
||||
#include "polyvox_frag.h"
|
||||
#include "polyvox_fade_vert.h"
|
||||
#include "polyvox_fade_frag.h"
|
||||
|
||||
#include "RenderablePolyVoxEntityItem.h"
|
||||
#include "EntityEditPacketSender.h"
|
||||
#include "PhysicalEntitySimulation.h"
|
||||
|
@ -1572,8 +1564,8 @@ static gpu::Stream::FormatPointer _vertexFormat;
|
|||
|
||||
ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const ShapeKey& key, gpu::Batch& batch) {
|
||||
if (!_pipelines[0]) {
|
||||
gpu::ShaderPointer vertexShaders[2] = { polyvox_vert::getShader(), polyvox_fade_vert::getShader() };
|
||||
gpu::ShaderPointer pixelShaders[2] = { polyvox_frag::getShader(), polyvox_fade_frag::getShader() };
|
||||
using namespace shader::entities_renderer::program;
|
||||
int programsIds[2] = { polyvox, polyvox_fade };
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), MATERIAL_GPU_SLOT));
|
||||
|
@ -1597,7 +1589,7 @@ ShapePipelinePointer shapePipelineFactory(const ShapePlumber& plumber, const Sha
|
|||
|
||||
// Two sets of pipelines: normal and fading
|
||||
for (auto i = 0; i < 2; i++) {
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShaders[i], pixelShaders[i]);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(programsIds[i]);
|
||||
|
||||
batch.runLambda([program, slotBindings] {
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
|
|
@ -15,12 +15,7 @@
|
|||
#include <StencilMaskPass.h>
|
||||
#include <GeometryCache.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "render-utils/simple_vert.h"
|
||||
#include "render-utils/simple_frag.h"
|
||||
#include "render-utils/simple_transparent_frag.h"
|
||||
#include "render-utils/forward_simple_frag.h"
|
||||
#include "render-utils/forward_simple_transparent_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "RenderPipelines.h"
|
||||
|
||||
|
@ -37,12 +32,12 @@ static const float SPHERE_ENTITY_SCALE = 0.5f;
|
|||
|
||||
|
||||
ShapeEntityRenderer::ShapeEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
|
||||
_procedural._vertexSource = simple_vert::getSource();
|
||||
_procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::render_utils::vertex::simple).getCode();
|
||||
// FIXME: Setup proper uniform slots and use correct pipelines for forward rendering
|
||||
_procedural._opaquefragmentSource = simple_frag::getSource();
|
||||
_procedural._opaquefragmentSource = gpu::Shader::getFragmentShaderSource(shader::render_utils::fragment::simple).getCode();
|
||||
// FIXME: Transparent procedural entities only seem to work if they use the opaque pipelines
|
||||
//_procedural._transparentfragmentSource = simple_transparent_frag::getSource();
|
||||
_procedural._transparentfragmentSource = simple_frag::getSource();
|
||||
_procedural._transparentfragmentSource = _procedural._opaquefragmentSource;
|
||||
_procedural._opaqueState->setCullMode(gpu::State::CULL_NONE);
|
||||
_procedural._opaqueState->setDepthTest(true, true, gpu::LESS_EQUAL);
|
||||
PrepareStencil::testMaskDrawShape(*_procedural._opaqueState);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
set(TARGET_NAME gpu)
|
||||
autoscribe_shader_lib(gpu)
|
||||
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared ktx)
|
||||
link_hifi_libraries(shared ktx shaders)
|
||||
|
||||
target_nsight()
|
||||
|
|
5
libraries/gpu/src/gpu/DrawNada.slf
Normal file
5
libraries/gpu/src/gpu/DrawNada.slf
Normal file
|
@ -0,0 +1,5 @@
|
|||
<@include gpu/Config.slh@>
|
||||
|
||||
<$VERSION_HEADER$>
|
||||
|
||||
void main(void) { }
|
|
@ -13,6 +13,8 @@
|
|||
#include <math.h>
|
||||
#include <QDebug>
|
||||
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "Context.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
@ -62,17 +64,6 @@ Shader::Pointer Shader::createOrReuseDomainShader(Type type, const Source& sourc
|
|||
return shader;
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createVertex(const Source& source) {
|
||||
return createOrReuseDomainShader(VERTEX, source);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createPixel(const Source& source) {
|
||||
return createOrReuseDomainShader(PIXEL, source);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createGeometry(const Source& source) {
|
||||
return createOrReuseDomainShader(GEOMETRY, source);
|
||||
}
|
||||
|
||||
ShaderPointer Shader::createOrReuseProgramShader(Type type, const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader) {
|
||||
PROFILE_RANGE(app, "createOrReuseProgramShader");
|
||||
|
@ -116,15 +107,6 @@ ShaderPointer Shader::createOrReuseProgramShader(Type type, const Pointer& verte
|
|||
return program;
|
||||
}
|
||||
|
||||
|
||||
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& pixelShader) {
|
||||
return createOrReuseProgramShader(PROGRAM, vertexShader, nullptr, pixelShader);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader) {
|
||||
return createOrReuseProgramShader(PROGRAM, vertexShader, geometryShader, pixelShader);
|
||||
}
|
||||
|
||||
void Shader::defineSlots(const SlotSet& uniforms, const SlotSet& uniformBuffers, const SlotSet& resourceBuffers, const SlotSet& textures, const SlotSet& samplers, const SlotSet& inputs, const SlotSet& outputs) {
|
||||
_uniforms = uniforms;
|
||||
_uniformBuffers = uniformBuffers;
|
||||
|
@ -153,3 +135,39 @@ void Shader::incrementCompilationAttempt() const {
|
|||
_numCompilationAttempts++;
|
||||
}
|
||||
|
||||
|
||||
Shader::Source Shader::getShaderSource(Type type, int shaderId) {
|
||||
return shader::loadShaderSource(shaderId);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createVertex(const Source& source) {
|
||||
return createOrReuseDomainShader(VERTEX, source);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createPixel(const Source& source) {
|
||||
return createOrReuseDomainShader(FRAGMENT, source);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createVertex(int id) {
|
||||
return createVertex(getShaderSource(VERTEX, id));
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createPixel(int id) {
|
||||
return createPixel(getShaderSource(FRAGMENT, id));
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& pixelShader) {
|
||||
return createOrReuseProgramShader(PROGRAM, vertexShader, nullptr, pixelShader);
|
||||
}
|
||||
|
||||
Shader::Pointer Shader::createProgram(int programId) {
|
||||
int vertexId = (programId >> 16) & 0xFFFF;
|
||||
int fragmentId = programId & 0xFFFF;
|
||||
auto vertexShader = createVertex(vertexId);
|
||||
auto fragmentShader = createPixel(fragmentId);
|
||||
return createOrReuseProgramShader(PROGRAM, vertexShader, nullptr, fragmentShader);
|
||||
}
|
||||
|
||||
//Shader::Pointer Shader::createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader) {
|
||||
// return createOrReuseProgramShader(PROGRAM, vertexShader, geometryShader, pixelShader);
|
||||
//}
|
||||
|
|
|
@ -26,9 +26,21 @@ public:
|
|||
// unique identifier of a shader
|
||||
using ID = uint32_t;
|
||||
|
||||
enum Type {
|
||||
VERTEX = 0,
|
||||
PIXEL,
|
||||
FRAGMENT = PIXEL,
|
||||
GEOMETRY,
|
||||
NUM_DOMAINS,
|
||||
|
||||
PROGRAM,
|
||||
};
|
||||
|
||||
typedef std::shared_ptr< Shader > Pointer;
|
||||
typedef std::vector< Pointer > Shaders;
|
||||
|
||||
|
||||
|
||||
class Source {
|
||||
public:
|
||||
enum Language {
|
||||
|
@ -52,6 +64,10 @@ public:
|
|||
Language _lang = GLSL;
|
||||
};
|
||||
|
||||
static Source getShaderSource(Type type, int shaderId);
|
||||
static Source getVertexShaderSource(int shaderId) { return getShaderSource(VERTEX, shaderId); }
|
||||
static Source getFragmentShaderSource(int shaderId) { return getShaderSource(FRAGMENT, shaderId); }
|
||||
|
||||
struct CompilationLog {
|
||||
std::string message;
|
||||
bool compiled{ false };
|
||||
|
@ -121,21 +137,17 @@ public:
|
|||
typedef std::set<Binding, Less<Binding>> BindingSet;
|
||||
|
||||
|
||||
enum Type {
|
||||
VERTEX = 0,
|
||||
PIXEL,
|
||||
GEOMETRY,
|
||||
NUM_DOMAINS,
|
||||
|
||||
PROGRAM,
|
||||
};
|
||||
|
||||
static Pointer createVertex(const Source& source);
|
||||
static Pointer createPixel(const Source& source);
|
||||
static Pointer createGeometry(const Source& source);
|
||||
//static Pointer createGeometry(const Source& source);
|
||||
static Pointer createVertex(int shaderId);
|
||||
static Pointer createPixel(int shaderId);
|
||||
static Pointer createGeometry(int shaderId);
|
||||
|
||||
static Pointer createProgram(int programId);
|
||||
static Pointer createProgram(const Pointer& vertexShader, const Pointer& pixelShader);
|
||||
static Pointer createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader);
|
||||
//static Pointer createProgram(int vertexId, int fragmentId);
|
||||
//static Pointer createProgram(const Pointer& vertexShader, const Pointer& geometryShader, const Pointer& pixelShader);
|
||||
|
||||
|
||||
~Shader();
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
//
|
||||
// StandardShaderLib.cpp
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Collection of standard shaders that can be used all over the place
|
||||
//
|
||||
// Created by Sam Gateau on 6/22/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 "StandardShaderLib.h"
|
||||
|
||||
#include "DrawUnitQuadTexcoord_vert.h"
|
||||
#include "DrawTransformUnitQuad_vert.h"
|
||||
#include "DrawTexcoordRectTransformUnitQuad_vert.h"
|
||||
#include "DrawViewportQuadTransformTexcoord_vert.h"
|
||||
#include "DrawVertexPosition_vert.h"
|
||||
#include "DrawTransformVertexPosition_vert.h"
|
||||
|
||||
const char DrawNada_frag[] = "void main(void) {}"; // DrawNada is really simple...
|
||||
|
||||
#include "DrawWhite_frag.h"
|
||||
#include "DrawColor_frag.h"
|
||||
#include "DrawTexture_frag.h"
|
||||
#include "DrawTextureMirroredX_frag.h"
|
||||
#include "DrawTextureOpaque_frag.h"
|
||||
#include "DrawColoredTexture_frag.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
ShaderPointer StandardShaderLib::_drawUnitQuadTexcoordVS;
|
||||
ShaderPointer StandardShaderLib::_drawTransformUnitQuadVS;
|
||||
ShaderPointer StandardShaderLib::_drawTexcoordRectTransformUnitQuadVS;
|
||||
ShaderPointer StandardShaderLib::_drawViewportQuadTransformTexcoordVS;
|
||||
ShaderPointer StandardShaderLib::_drawVertexPositionVS;
|
||||
ShaderPointer StandardShaderLib::_drawTransformVertexPositionVS;
|
||||
ShaderPointer StandardShaderLib::_drawNadaPS;
|
||||
ShaderPointer StandardShaderLib::_drawWhitePS;
|
||||
ShaderPointer StandardShaderLib::_drawColorPS;
|
||||
ShaderPointer StandardShaderLib::_drawTexturePS;
|
||||
ShaderPointer StandardShaderLib::_drawTextureMirroredXPS;
|
||||
ShaderPointer StandardShaderLib::_drawTextureOpaquePS;
|
||||
ShaderPointer StandardShaderLib::_drawColoredTexturePS;
|
||||
StandardShaderLib::ProgramMap StandardShaderLib::_programs;
|
||||
|
||||
ShaderPointer StandardShaderLib::getProgram(GetShader getVS, GetShader getPS) {
|
||||
|
||||
auto programIt = _programs.find(std::pair<GetShader, GetShader>(getVS, getPS));
|
||||
if (programIt != _programs.end()) {
|
||||
return (*programIt).second;
|
||||
} else {
|
||||
auto vs = (getVS)();
|
||||
auto ps = (getPS)();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
if (program) {
|
||||
// Program created, let's try to make it
|
||||
if (gpu::Shader::makeProgram((*program))) {
|
||||
// All good, backup and return that program
|
||||
_programs.insert(ProgramMap::value_type(std::pair<GetShader, GetShader>(getVS, getPS), program));
|
||||
return program;
|
||||
} else {
|
||||
// Failed to make the program probably because vs and ps cannot work together?
|
||||
}
|
||||
} else {
|
||||
// Failed to create the program maybe because ps and vs are not true vertex and pixel shaders?
|
||||
}
|
||||
}
|
||||
return ShaderPointer();
|
||||
}
|
||||
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawUnitQuadTexcoordVS() {
|
||||
if (!_drawUnitQuadTexcoordVS) {
|
||||
_drawUnitQuadTexcoordVS = DrawUnitQuadTexcoord_vert::getShader();
|
||||
}
|
||||
return _drawUnitQuadTexcoordVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTransformUnitQuadVS() {
|
||||
if (!_drawTransformUnitQuadVS) {
|
||||
_drawTransformUnitQuadVS = DrawTransformUnitQuad_vert::getShader();
|
||||
}
|
||||
return _drawTransformUnitQuadVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS() {
|
||||
if (!_drawTexcoordRectTransformUnitQuadVS) {
|
||||
_drawTexcoordRectTransformUnitQuadVS = DrawTexcoordRectTransformUnitQuad_vert::getShader();
|
||||
}
|
||||
return _drawTexcoordRectTransformUnitQuadVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawViewportQuadTransformTexcoordVS() {
|
||||
if (!_drawViewportQuadTransformTexcoordVS) {
|
||||
_drawViewportQuadTransformTexcoordVS = DrawViewportQuadTransformTexcoord_vert::getShader();
|
||||
}
|
||||
return _drawViewportQuadTransformTexcoordVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawVertexPositionVS() {
|
||||
if (!_drawVertexPositionVS) {
|
||||
_drawVertexPositionVS = DrawVertexPosition_vert::getShader();
|
||||
}
|
||||
return _drawVertexPositionVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTransformVertexPositionVS() {
|
||||
if (!_drawTransformVertexPositionVS) {
|
||||
_drawTransformVertexPositionVS = DrawTransformVertexPosition_vert::getShader();
|
||||
}
|
||||
return _drawTransformVertexPositionVS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawNadaPS() {
|
||||
if (!_drawNadaPS) {
|
||||
_drawNadaPS = gpu::Shader::createPixel(std::string(DrawNada_frag));
|
||||
}
|
||||
return _drawNadaPS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawWhitePS() {
|
||||
if (!_drawWhitePS) {
|
||||
_drawWhitePS = DrawWhite_frag::getShader();
|
||||
}
|
||||
return _drawWhitePS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawColorPS() {
|
||||
if (!_drawColorPS) {
|
||||
_drawColorPS = DrawColor_frag::getShader();
|
||||
}
|
||||
return _drawColorPS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTexturePS() {
|
||||
if (!_drawTexturePS) {
|
||||
_drawTexturePS = DrawTexture_frag::getShader();
|
||||
}
|
||||
return _drawTexturePS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTextureMirroredXPS() {
|
||||
if (!_drawTextureMirroredXPS) {
|
||||
_drawTextureMirroredXPS = DrawTextureMirroredX_frag::getShader();
|
||||
}
|
||||
return _drawTextureMirroredXPS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawTextureOpaquePS() {
|
||||
if (!_drawTextureOpaquePS) {
|
||||
_drawTextureOpaquePS = DrawTextureOpaque_frag::getShader();
|
||||
}
|
||||
return _drawTextureOpaquePS;
|
||||
}
|
||||
|
||||
ShaderPointer StandardShaderLib::getDrawColoredTexturePS() {
|
||||
if (!_drawColoredTexturePS) {
|
||||
_drawColoredTexturePS = DrawColoredTexture_frag::getShader();
|
||||
}
|
||||
return _drawColoredTexturePS;
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
//
|
||||
// StandardShaderLib.h
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Collection of standard shaders that can be used all over the place
|
||||
//
|
||||
// Created by Sam Gateau on 6/22/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
|
||||
//
|
||||
#ifndef hifi_gpu_StandardShaderLib_h
|
||||
#define hifi_gpu_StandardShaderLib_h
|
||||
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
|
||||
#include "Shader.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
class StandardShaderLib {
|
||||
public:
|
||||
|
||||
// Shader draws the unit quad in the full viewport clipPos = ([(-1,-1),(1,1)]) and the unit texcoord = [(0,0),(1,1)].
|
||||
static ShaderPointer getDrawUnitQuadTexcoordVS();
|
||||
|
||||
// Shader draw the unit quad objectPos = ([(-1,-1),(1,1)]) and transform it by the full model transform stack (Model, View, Proj).
|
||||
// A texcoord attribute is also generated texcoord = [(0,0),(1,1)]
|
||||
static ShaderPointer getDrawTransformUnitQuadVS();
|
||||
|
||||
// Shader draw the unit quad objectPos = ([(-1,-1),(1,1)]) and transform it by the full model transform stack (Model, View, Proj).
|
||||
// A texcoord attribute is also generated covering a rect defined from the uniform vec4 texcoordRect: texcoord = [texcoordRect.xy,texcoordRect.xy + texcoordRect.zw]
|
||||
static ShaderPointer getDrawTexcoordRectTransformUnitQuadVS();
|
||||
|
||||
// Shader draws the unit quad in the full viewport clipPos = ([(-1,-1),(1,1)]) and transform the texcoord = [(0,0),(1,1)] by the model transform.
|
||||
static ShaderPointer getDrawViewportQuadTransformTexcoordVS();
|
||||
|
||||
// Shader draw the fed vertex position and transform it by the full model transform stack (Model, View, Proj).
|
||||
// simply output the world pos and the clip pos to the next stage
|
||||
static ShaderPointer getDrawVertexPositionVS();
|
||||
static ShaderPointer getDrawTransformVertexPositionVS();
|
||||
|
||||
// PShader does nothing, no really nothing, but still needed for defining a program triggering rasterization
|
||||
static ShaderPointer getDrawNadaPS();
|
||||
|
||||
static ShaderPointer getDrawWhitePS();
|
||||
static ShaderPointer getDrawColorPS();
|
||||
static ShaderPointer getDrawTexturePS();
|
||||
static ShaderPointer getDrawTextureMirroredXPS();
|
||||
static ShaderPointer getDrawTextureOpaquePS();
|
||||
static ShaderPointer getDrawColoredTexturePS();
|
||||
|
||||
// The shader program combining the shaders available above, so they are unique
|
||||
typedef ShaderPointer (*GetShader) ();
|
||||
static ShaderPointer getProgram(GetShader vs, GetShader ps);
|
||||
|
||||
protected:
|
||||
|
||||
static ShaderPointer _drawUnitQuadTexcoordVS;
|
||||
static ShaderPointer _drawTransformUnitQuadVS;
|
||||
static ShaderPointer _drawTexcoordRectTransformUnitQuadVS;
|
||||
static ShaderPointer _drawViewportQuadTransformTexcoordVS;
|
||||
|
||||
static ShaderPointer _drawVertexPositionVS;
|
||||
static ShaderPointer _drawTransformVertexPositionVS;
|
||||
|
||||
static ShaderPointer _drawNadaPS;
|
||||
static ShaderPointer _drawWhitePS;
|
||||
static ShaderPointer _drawColorPS;
|
||||
static ShaderPointer _drawTexturePS;
|
||||
static ShaderPointer _drawTextureMirroredXPS;
|
||||
static ShaderPointer _drawTextureOpaquePS;
|
||||
static ShaderPointer _drawColoredTexturePS;
|
||||
|
||||
typedef std::map<std::pair<GetShader, GetShader>, ShaderPointer> ProgramMap;
|
||||
static ProgramMap _programs;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||
set(TARGET_NAME graphics)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared ktx gpu image)
|
||||
|
||||
link_hifi_libraries(shared ktx gpu shaders image)
|
|
@ -15,8 +15,7 @@
|
|||
#include <gpu/Context.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "skybox_vert.h"
|
||||
#include "skybox_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
|
@ -91,9 +90,7 @@ void Skybox::render(gpu::Batch& batch, const ViewFrustum& viewFrustum, const Sky
|
|||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
{
|
||||
auto skyVS = skybox_vert::getShader();
|
||||
auto skyFS = skybox_frag::getShader();
|
||||
auto skyShader = gpu::Shader::createProgram(skyVS, skyFS);
|
||||
auto skyShader = gpu::Shader::createProgram(shader::graphics::program::skybox);
|
||||
|
||||
batch.runLambda([skyShader] {
|
||||
gpu::Shader::BindingSet bindings;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
set(TARGET_NAME procedural)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||
setup_hifi_library()
|
||||
link_hifi_libraries(shared gpu networking graphics model-networking ktx image)
|
||||
link_hifi_libraries(shared gpu shaders networking graphics model-networking ktx image)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <NumericalConstants.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <NetworkingConstants.h>
|
||||
#include "ProceduralCommon_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "Logging.h"
|
||||
|
||||
|
@ -223,9 +223,10 @@ bool Procedural::isReady() const {
|
|||
|
||||
std::string Procedural::replaceProceduralBlock(const std::string& fragmentSource) {
|
||||
std::string fragmentShaderSource = fragmentSource;
|
||||
static const auto proceduralCommonSource = gpu::Shader::getFragmentShaderSource(shader::procedural::fragment::ProceduralCommon);
|
||||
size_t replaceIndex = fragmentShaderSource.find(PROCEDURAL_COMMON_BLOCK);
|
||||
if (replaceIndex != std::string::npos) {
|
||||
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), ProceduralCommon_frag::getSource());
|
||||
fragmentShaderSource.replace(replaceIndex, PROCEDURAL_COMMON_BLOCK.size(), proceduralCommonSource.getCode());
|
||||
}
|
||||
|
||||
replaceIndex = fragmentShaderSource.find(PROCEDURAL_VERSION);
|
||||
|
|
|
@ -13,14 +13,13 @@
|
|||
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/Shader.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include <graphics/skybox_vert.h>
|
||||
#include <graphics/skybox_frag.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
ProceduralSkybox::ProceduralSkybox() : graphics::Skybox() {
|
||||
_procedural._vertexSource = skybox_vert::getSource();
|
||||
_procedural._opaquefragmentSource = skybox_frag::getSource();
|
||||
_procedural._vertexSource = gpu::Shader::getVertexShaderSource(shader::graphics::vertex::skybox).getCode();
|
||||
_procedural._opaquefragmentSource = gpu::Shader::getFragmentShaderSource(shader::graphics::fragment::skybox).getCode();
|
||||
// Adjust the pipeline state for background using the stencil test
|
||||
_procedural.setDoesFade(false);
|
||||
// Must match PrepareStencil::STENCIL_BACKGROUND
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
set(TARGET_NAME render-utils)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics render)
|
||||
|
||||
# pull in the resources.qrc file
|
||||
qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc")
|
||||
setup_hifi_library(Gui Network Qml Quick Script)
|
||||
link_hifi_libraries(shared task ktx gpu graphics graphics-scripting model-networking render animation fbx image procedural)
|
||||
link_hifi_libraries(shared task ktx gpu shaders graphics graphics-scripting model-networking render animation fbx image procedural)
|
||||
include_hifi_library_headers(audio)
|
||||
include_hifi_library_headers(networking)
|
||||
include_hifi_library_headers(octree)
|
||||
|
@ -14,3 +14,4 @@ set_property(SOURCE qrc_fonts.cpp PROPERTY SKIP_AUTOMOC ON)
|
|||
if (NOT ANDROID)
|
||||
target_nsight()
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include <PathUtils.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "RenderUtilsLogging.h"
|
||||
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
@ -27,11 +28,6 @@
|
|||
#include "DependencyManager.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
||||
#include "ssao_makePyramid_frag.h"
|
||||
#include "ssao_makeOcclusion_frag.h"
|
||||
#include "ssao_debugOcclusion_frag.h"
|
||||
#include "ssao_makeHorizontalBlur_frag.h"
|
||||
#include "ssao_makeVerticalBlur_frag.h"
|
||||
|
||||
|
||||
AmbientOcclusionFramebuffer::AmbientOcclusionFramebuffer() {
|
||||
|
@ -261,9 +257,7 @@ void AmbientOcclusionEffect::configure(const Config& config) {
|
|||
|
||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
|
||||
if (!_occlusionPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = ssao_makeOcclusion_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_makeOcclusion);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AmbientOcclusionEffect_FrameTransformSlot));
|
||||
|
@ -286,9 +280,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getOcclusionPipeline() {
|
|||
|
||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
|
||||
if (!_hBlurPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = ssao_makeHorizontalBlur_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_makeHorizontalBlur);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("ambientOcclusionFrameTransformBuffer"), AmbientOcclusionEffect_FrameTransformSlot));
|
||||
|
@ -309,9 +301,7 @@ const gpu::PipelinePointer& AmbientOcclusionEffect::getHBlurPipeline() {
|
|||
|
||||
const gpu::PipelinePointer& AmbientOcclusionEffect::getVBlurPipeline() {
|
||||
if (!_vBlurPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = ssao_makeVerticalBlur_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_makeVerticalBlur);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("ambientOcclusionFrameTransformBuffer"), AmbientOcclusionEffect_FrameTransformSlot));
|
||||
|
@ -456,10 +446,8 @@ void DebugAmbientOcclusion::configure(const Config& config) {
|
|||
|
||||
const gpu::PipelinePointer& DebugAmbientOcclusion::getDebugPipeline() {
|
||||
if (!_debugPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = ssao_debugOcclusion_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::ssao_debugOcclusion);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), AmbientOcclusionEffect_FrameTransformSlot));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("ambientOcclusionParamsBuffer"), AmbientOcclusionEffect_ParamsSlot));
|
||||
|
|
|
@ -12,17 +12,13 @@
|
|||
#include <qmath.h>
|
||||
#include <gpu/Batch.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "AbstractViewStateInterface.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
#include "DebugDraw.h"
|
||||
#include "StencilMaskPass.h"
|
||||
|
||||
#include "animdebugdraw_vert.h"
|
||||
#include "animdebugdraw_frag.h"
|
||||
|
||||
#include "animdebugdraw_vert.h"
|
||||
#include "animdebugdraw_frag.h"
|
||||
class AnimDebugDrawData {
|
||||
public:
|
||||
|
||||
|
@ -106,9 +102,7 @@ AnimDebugDraw::AnimDebugDraw() :
|
|||
gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA,
|
||||
gpu::State::BLEND_OP_ADD, gpu::State::ONE);
|
||||
PrepareStencil::testMaskDrawShape(*state.get());
|
||||
auto vertShader = animdebugdraw_vert::getShader();
|
||||
auto fragShader = animdebugdraw_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(vertShader, fragShader);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::animdebugdraw);
|
||||
_pipeline = gpu::Pipeline::create(program, state);
|
||||
|
||||
_animDebugDrawData = std::make_shared<AnimDebugDrawData>();
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <PathUtils.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "TextureCache.h"
|
||||
|
@ -172,10 +172,6 @@ void Antialiasing::run(const render::RenderContextPointer& renderContext, const
|
|||
}
|
||||
#else
|
||||
|
||||
#include "taa_frag.h"
|
||||
#include "fxaa_blend_frag.h"
|
||||
#include "taa_blend_frag.h"
|
||||
|
||||
const int AntialiasingPass_ParamsSlot = 0;
|
||||
const int AntialiasingPass_FrameTransformSlot = 1;
|
||||
|
||||
|
@ -200,10 +196,7 @@ Antialiasing::~Antialiasing() {
|
|||
const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(const render::RenderContextPointer& renderContext) {
|
||||
|
||||
if (!_antialiasingPipeline) {
|
||||
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = taa_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::taa);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
|
||||
|
@ -235,9 +228,7 @@ const gpu::PipelinePointer& Antialiasing::getAntialiasingPipeline(const render::
|
|||
|
||||
const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
|
||||
if (!_blendPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = fxaa_blend_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::fxaa_blend);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("colorTexture"), AntialiasingPass_NextMapSlot));
|
||||
|
@ -258,9 +249,7 @@ const gpu::PipelinePointer& Antialiasing::getBlendPipeline() {
|
|||
|
||||
const gpu::PipelinePointer& Antialiasing::getDebugBlendPipeline() {
|
||||
if (!_debugBlendPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = taa_blend_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::taa_blend);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("taaParamsBuffer"), AntialiasingPass_ParamsSlot));
|
||||
|
|
|
@ -10,15 +10,13 @@
|
|||
//
|
||||
#include "BloomEffect.h"
|
||||
|
||||
#include "gpu/Context.h"
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
#include <gpu/Context.h>
|
||||
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include <render/BlurTask.h>
|
||||
#include <render/ResampleTask.h>
|
||||
|
||||
#include "BloomThreshold_frag.h"
|
||||
#include "BloomApply_frag.h"
|
||||
|
||||
#define BLOOM_BLUR_LEVEL_COUNT 3
|
||||
|
||||
BloomThreshold::BloomThreshold(unsigned int downsamplingFactor) {
|
||||
|
@ -65,9 +63,7 @@ void BloomThreshold::run(const render::RenderContextPointer& renderContext, cons
|
|||
static const int PARAMETERS_SLOT = 1;
|
||||
|
||||
if (!_pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = BloomThreshold_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::bloomThreshold);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("colorMap", COLOR_MAP_SLOT));
|
||||
|
@ -124,9 +120,7 @@ void BloomApply::run(const render::RenderContextPointer& renderContext, const In
|
|||
static const auto PARAMETERS_SLOT = 0;
|
||||
|
||||
if (!_pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = BloomApply_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::bloomApply);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("blurMap0", BLUR0_SLOT));
|
||||
|
@ -178,10 +172,7 @@ void BloomDraw::run(const render::RenderContextPointer& renderContext, const Inp
|
|||
const auto framebufferSize = frameBuffer->getSize();
|
||||
|
||||
if (!_pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawTransformUnitQuadTextureOpaque);
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
||||
|
@ -237,9 +228,7 @@ void DebugBloom::run(const render::RenderContextPointer& renderContext, const In
|
|||
static auto TEXCOORD_RECT_SLOT = 1;
|
||||
|
||||
if (!_pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTexcoordRectTransformUnitQuadVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawTextureOpaqueTexcoordRect);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("texcoordRect"), TEXCOORD_RECT_SLOT));
|
||||
|
|
|
@ -18,14 +18,12 @@
|
|||
#include <gpu/Context.h>
|
||||
#include <render/Scene.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "GeometryCache.h"
|
||||
#include "TextureCache.h"
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
||||
#include "debug_deferred_buffer_vert.h"
|
||||
#include "debug_deferred_buffer_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
void DebugDeferredBufferConfig::setMode(int newMode) {
|
||||
|
@ -378,7 +376,7 @@ bool DebugDeferredBuffer::pipelineNeedsUpdate(Mode mode, std::string customFile)
|
|||
|
||||
const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::string customFile) {
|
||||
if (pipelineNeedsUpdate(mode, customFile)) {
|
||||
static const std::string FRAGMENT_SHADER { debug_deferred_buffer_frag::getSource() };
|
||||
static const std::string FRAGMENT_SHADER { gpu::Shader::getFragmentShaderSource(shader::render_utils::fragment::debug_deferred_buffer).getCode() };
|
||||
static const std::string SOURCE_PLACEHOLDER { "//SOURCE_PLACEHOLDER" };
|
||||
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
|
||||
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
|
||||
|
@ -388,7 +386,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
|
|||
bakedFragmentShader.replace(SOURCE_PLACEHOLDER_INDEX, SOURCE_PLACEHOLDER.size(),
|
||||
getShaderSourceCode(mode, customFile));
|
||||
|
||||
const auto vs = debug_deferred_buffer_vert::getShader();
|
||||
const auto vs = gpu::Shader::createVertex(shader::render_utils::vertex::debug_deferred_buffer);
|
||||
const auto ps = gpu::Shader::createPixel(bakedFragmentShader);
|
||||
const auto program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
#include <PathUtils.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <shared/FileUtils.h>
|
||||
|
||||
#include <gpu/Batch.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "AbstractViewStateInterface.h"
|
||||
|
@ -27,20 +27,6 @@
|
|||
#include "TextureCache.h"
|
||||
#include "FramebufferCache.h"
|
||||
|
||||
#include "deferred_light_vert.h"
|
||||
#include "deferred_light_point_vert.h"
|
||||
#include "deferred_light_spot_vert.h"
|
||||
|
||||
#include "directional_ambient_light_frag.h"
|
||||
#include "directional_skybox_light_frag.h"
|
||||
|
||||
#include "directional_ambient_light_shadow_frag.h"
|
||||
#include "directional_skybox_light_shadow_frag.h"
|
||||
|
||||
#include "local_lights_shading_frag.h"
|
||||
#include "local_lights_drawOutline_frag.h"
|
||||
|
||||
|
||||
using namespace render;
|
||||
|
||||
struct LightLocations {
|
||||
|
@ -85,7 +71,7 @@ enum DeferredShader_BufferSlot {
|
|||
LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT,
|
||||
};
|
||||
|
||||
static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations);
|
||||
|
||||
void DeferredLightingEffect::init() {
|
||||
_directionalAmbientSphereLightLocations = std::make_shared<LightLocations>();
|
||||
|
@ -97,14 +83,14 @@ void DeferredLightingEffect::init() {
|
|||
_localLightLocations = std::make_shared<LightLocations>();
|
||||
_localLightOutlineLocations = std::make_shared<LightLocations>();
|
||||
|
||||
loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_frag::getShader(), false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
||||
loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_frag::getShader(), false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light, false, _directionalSkyboxLight, _directionalSkyboxLightLocations);
|
||||
|
||||
loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_shadow_frag::getShader(), false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
|
||||
loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_shadow_frag::getShader(), false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_ambient_light_shadow, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations);
|
||||
loadLightProgram(shader::render_utils::program::directional_skybox_light_shadow, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations);
|
||||
|
||||
loadLightProgram(deferred_light_vert::getShader(), local_lights_shading_frag::getShader(), true, _localLight, _localLightLocations);
|
||||
loadLightProgram(deferred_light_vert::getShader(), local_lights_drawOutline_frag::getShader(), true, _localLightOutline, _localLightOutlineLocations);
|
||||
loadLightProgram(shader::render_utils::program::local_lights_shading, true, _localLight, _localLightLocations);
|
||||
loadLightProgram(shader::render_utils::program::local_lights_drawOutline, true, _localLightOutline, _localLightOutlineLocations);
|
||||
}
|
||||
|
||||
void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) {
|
||||
|
@ -176,8 +162,8 @@ void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int lightA
|
|||
}
|
||||
}
|
||||
|
||||
static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, LightLocationsPtr& locations) {
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vertShader, fragShader);
|
||||
static gpu::ShaderPointer makeLightProgram(int programId, LightLocationsPtr& locations) {
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(programId);
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT));
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT));
|
||||
|
@ -226,9 +212,9 @@ static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader,
|
|||
return program;
|
||||
}
|
||||
|
||||
static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
|
||||
static void loadLightProgram(int programId, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) {
|
||||
|
||||
gpu::ShaderPointer program = makeLightProgram(vertShader, fragShader, locations);
|
||||
gpu::ShaderPointer program = makeLightProgram(programId, locations);
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
state->setColorWriteMask(true, true, true, false);
|
||||
|
|
|
@ -12,15 +12,13 @@
|
|||
#include "DrawHaze.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "FramebufferCache.h"
|
||||
#include "HazeStage.h"
|
||||
#include "LightStage.h"
|
||||
|
||||
#include "Haze_frag.h"
|
||||
|
||||
void HazeConfig::setHazeColor(const glm::vec3 value) {
|
||||
hazeColor = value;
|
||||
}
|
||||
|
@ -132,10 +130,7 @@ void DrawHaze::run(const render::RenderContextPointer& renderContext, const Inpu
|
|||
RenderArgs* args = renderContext->args;
|
||||
|
||||
if (!_hazePipeline) {
|
||||
gpu::ShaderPointer ps = Haze_frag::getShader();
|
||||
gpu::ShaderPointer vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::haze);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
state->setBlendFunction(true,
|
||||
|
|
|
@ -23,36 +23,17 @@
|
|||
|
||||
#include <FSTReader.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <graphics/TextureMap.h>
|
||||
#include <graphics/BufferViewHelpers.h>
|
||||
#include <render/Args.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "TextureCache.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
#include "StencilMaskPass.h"
|
||||
#include "FadeEffect.h"
|
||||
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
|
||||
#include "graphics/TextureMap.h"
|
||||
#include "graphics/BufferViewHelpers.h"
|
||||
#include "render/Args.h"
|
||||
|
||||
#include "standardTransformPNTC_vert.h"
|
||||
#include "standardDrawTexture_frag.h"
|
||||
|
||||
#include "simple_vert.h"
|
||||
#include "simple_textured_frag.h"
|
||||
#include "simple_transparent_textured_frag.h"
|
||||
#include "simple_textured_unlit_frag.h"
|
||||
#include "simple_fade_vert.h"
|
||||
#include "simple_textured_fade_frag.h"
|
||||
#include "simple_textured_unlit_fade_frag.h"
|
||||
#include "simple_opaque_web_browser_frag.h"
|
||||
#include "simple_transparent_web_browser_frag.h"
|
||||
#include "glowLine_vert.h"
|
||||
#include "glowLine_frag.h"
|
||||
|
||||
#include "forward_simple_textured_frag.h"
|
||||
#include "forward_simple_textured_transparent_frag.h"
|
||||
#include "forward_simple_textured_unlit_frag.h"
|
||||
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
||||
|
@ -63,8 +44,6 @@ static const QString RENDER_FORWARD{ "HIFI_RENDER_FORWARD" };
|
|||
static bool DISABLE_DEFERRED = QProcessEnvironment::systemEnvironment().contains(RENDER_FORWARD);
|
||||
#endif
|
||||
|
||||
#include "grid_frag.h"
|
||||
|
||||
//#define WANT_DEBUG
|
||||
|
||||
// @note: Originally size entity::NUM_SHAPES
|
||||
|
@ -2052,9 +2031,7 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
|
|||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
auto VS = glowLine_vert::getShader();
|
||||
auto PS = glowLine_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(VS, PS);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::glowLine);
|
||||
state->setCullMode(gpu::State::CULL_NONE);
|
||||
state->setDepthTest(true, false, gpu::LESS_EQUAL);
|
||||
state->setBlendFunction(true,
|
||||
|
@ -2109,9 +2086,7 @@ void GeometryCache::renderGlowLine(gpu::Batch& batch, const glm::vec3& p1, const
|
|||
void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() {
|
||||
auto vs = standardTransformPNTC_vert::getShader();
|
||||
auto ps = standardDrawTexture_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::standardDrawTexture);
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
||||
|
@ -2125,8 +2100,8 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
|
|||
auto stateNoBlend = std::make_shared<gpu::State>();
|
||||
PrepareStencil::testMaskDrawShape(*stateNoBlend);
|
||||
|
||||
auto noBlendPS = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||
auto programNoBlend = gpu::Shader::createProgram(vs, noBlendPS);
|
||||
auto noBlendPS = gpu::Shader::createVertex(shader::gpu::fragment::DrawTextureOpaque);
|
||||
auto programNoBlend = gpu::Shader::createProgram(shader::render_utils::program::standardDrawTextureNoBlend);
|
||||
|
||||
_standardDrawPipelineNoBlend = gpu::Pipeline::create(programNoBlend, stateNoBlend);
|
||||
|
||||
|
@ -2145,9 +2120,7 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch, bool noBlend) {
|
|||
|
||||
void GeometryCache::useGridPipeline(gpu::Batch& batch, GridBuffer gridBuffer, bool isLayered) {
|
||||
if (!_gridPipeline) {
|
||||
auto vs = standardTransformPNTC_vert::getShader();
|
||||
auto ps = grid_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::grid);
|
||||
gpu::Shader::makeProgram((*program));
|
||||
_gridSlot = program->getUniformBuffers().findLocation("gridBuffer");
|
||||
|
||||
|
@ -2229,9 +2202,9 @@ inline bool operator==(const SimpleProgramKey& a, const SimpleProgramKey& b) {
|
|||
return a.getRaw() == b.getRaw();
|
||||
}
|
||||
|
||||
static void buildWebShader(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool blendEnable,
|
||||
static void buildWebShader(int programId, bool blendEnable,
|
||||
gpu::ShaderPointer& shaderPointerOut, gpu::PipelinePointer& pipelinePointerOut) {
|
||||
shaderPointerOut = gpu::Shader::createProgram(vertShader, fragShader);
|
||||
shaderPointerOut = gpu::Shader::createProgram(programId);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*shaderPointerOut, slotBindings);
|
||||
|
@ -2254,8 +2227,8 @@ void GeometryCache::bindWebBrowserProgram(gpu::Batch& batch, bool transparent) {
|
|||
gpu::PipelinePointer GeometryCache::getWebBrowserProgram(bool transparent) {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() {
|
||||
buildWebShader(simple_vert::getShader(), simple_opaque_web_browser_frag::getShader(), false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline);
|
||||
buildWebShader(simple_vert::getShader(), simple_transparent_web_browser_frag::getShader(), true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline);
|
||||
buildWebShader(shader::render_utils::program::simple_opaque_web_browser, false, _simpleOpaqueWebBrowserShader, _simpleOpaqueWebBrowserPipeline);
|
||||
buildWebShader(shader::render_utils::program::simple_transparent_web_browser, true, _simpleTransparentWebBrowserShader, _simpleTransparentWebBrowserPipeline);
|
||||
});
|
||||
|
||||
return transparent ? _simpleTransparentWebBrowserPipeline : _simpleOpaqueWebBrowserPipeline;
|
||||
|
@ -2284,15 +2257,15 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
|
|||
if (!fading) {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() {
|
||||
auto VS = simple_vert::getShader();
|
||||
auto PS = DISABLE_DEFERRED ? forward_simple_textured_frag::getShader() : simple_textured_frag::getShader();
|
||||
using namespace shader::render_utils::program;
|
||||
auto PS = DISABLE_DEFERRED ? forward_simple_textured : simple_textured;
|
||||
// Use the forward pipeline for both here, otherwise transparents will be unlit
|
||||
auto PSTransparent = DISABLE_DEFERRED ? forward_simple_textured_transparent_frag::getShader() : forward_simple_textured_transparent_frag::getShader();
|
||||
auto PSUnlit = DISABLE_DEFERRED ? forward_simple_textured_unlit_frag::getShader() : simple_textured_unlit_frag::getShader();
|
||||
auto PSTransparent = DISABLE_DEFERRED ? forward_simple_textured_transparent : forward_simple_textured_transparent;
|
||||
auto PSUnlit = DISABLE_DEFERRED ? forward_simple_textured_unlit : simple_textured_unlit;
|
||||
|
||||
_simpleShader = gpu::Shader::createProgram(VS, PS);
|
||||
_transparentShader = gpu::Shader::createProgram(VS, PSTransparent);
|
||||
_unlitShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||
_simpleShader = gpu::Shader::createProgram(PS);
|
||||
_transparentShader = gpu::Shader::createProgram(PSTransparent);
|
||||
_unlitShader = gpu::Shader::createProgram(PSUnlit);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("originalTexture"), render::ShapePipeline::Slot::MAP::ALBEDO));
|
||||
|
@ -2307,12 +2280,9 @@ gpu::PipelinePointer GeometryCache::getSimplePipeline(bool textured, bool transp
|
|||
} else {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&]() {
|
||||
auto VS = simple_fade_vert::getShader();
|
||||
auto PS = DISABLE_DEFERRED ? forward_simple_textured_frag::getShader() : simple_textured_fade_frag::getShader();
|
||||
auto PSUnlit = DISABLE_DEFERRED ? forward_simple_textured_unlit_frag::getShader() : simple_textured_unlit_fade_frag::getShader();
|
||||
|
||||
_simpleFadeShader = gpu::Shader::createProgram(VS, PS);
|
||||
_unlitFadeShader = gpu::Shader::createProgram(VS, PSUnlit);
|
||||
using namespace shader::render_utils::program;
|
||||
_simpleFadeShader = gpu::Shader::createProgram(DISABLE_DEFERRED ? forward_simple_textured : simple_textured_fade);
|
||||
_unlitFadeShader = gpu::Shader::createProgram(DISABLE_DEFERRED ? forward_simple_textured_unlit : simple_textured_unlit_fade);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("originalTexture"), render::ShapePipeline::Slot::MAP::ALBEDO));
|
||||
|
|
|
@ -10,25 +10,19 @@
|
|||
//
|
||||
#include "HighlightEffect.h"
|
||||
|
||||
#include "GeometryCache.h"
|
||||
|
||||
#include "CubeProjectedPolygon.h"
|
||||
#include <sstream>
|
||||
|
||||
#include <render/FilterTask.h>
|
||||
#include <render/SortTask.h>
|
||||
|
||||
#include "gpu/Context.h"
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
#include <gpu/Context.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "GeometryCache.h"
|
||||
#include "CubeProjectedPolygon.h"
|
||||
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "surfaceGeometry_copyDepth_frag.h"
|
||||
#include "debug_deferred_buffer_vert.h"
|
||||
#include "debug_deferred_buffer_frag.h"
|
||||
#include "Highlight_frag.h"
|
||||
#include "Highlight_filled_frag.h"
|
||||
#include "Highlight_aabox_vert.h"
|
||||
#include "nop_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
@ -133,9 +127,7 @@ void DrawHighlightMask::run(const render::RenderContextPointer& renderContext, c
|
|||
fillState->setColorWriteMask(false, false, false, false);
|
||||
fillState->setCullMode(gpu::State::CULL_FRONT);
|
||||
|
||||
auto vs = Highlight_aabox_vert::getShader();
|
||||
auto ps = nop_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::highlight_aabox);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("ssbo0Buffer"), BOUNDS_SLOT));
|
||||
|
@ -327,9 +319,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
|
|||
state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA);
|
||||
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
|
||||
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = Highlight_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::highlight);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("highlightParamsBuffer", HIGHLIGHT_PARAMS_SLOT));
|
||||
|
@ -340,8 +330,7 @@ const gpu::PipelinePointer& DrawHighlight::getPipeline(const render::HighlightSt
|
|||
|
||||
_pipeline = gpu::Pipeline::create(program, state);
|
||||
|
||||
ps = Highlight_filled_frag::getShader();
|
||||
program = gpu::Shader::createProgram(vs, ps);
|
||||
program = gpu::Shader::createProgram(shader::render_utils::program::highlight_filled);
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
_pipelineFilled = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
@ -406,7 +395,7 @@ void DebugHighlight::run(const render::RenderContextPointer& renderContext, cons
|
|||
}
|
||||
|
||||
void DebugHighlight::initializePipelines() {
|
||||
static const std::string FRAGMENT_SHADER{ debug_deferred_buffer_frag::getSource() };
|
||||
static const std::string FRAGMENT_SHADER{ gpu::Shader::getFragmentShaderSource(shader::render_utils::fragment::debug_deferred_buffer).getCode() };
|
||||
static const std::string SOURCE_PLACEHOLDER{ "//SOURCE_PLACEHOLDER" };
|
||||
static const auto SOURCE_PLACEHOLDER_INDEX = FRAGMENT_SHADER.find(SOURCE_PLACEHOLDER);
|
||||
Q_ASSERT_X(SOURCE_PLACEHOLDER_INDEX != std::string::npos, Q_FUNC_INFO,
|
||||
|
@ -416,17 +405,17 @@ void DebugHighlight::initializePipelines() {
|
|||
state->setDepthTest(gpu::State::DepthTest(false, false));
|
||||
state->setStencilTest(true, 0, gpu::State::StencilTest(OUTLINE_STENCIL_MASK, 0xFF, gpu::EQUAL));
|
||||
|
||||
const auto vs = debug_deferred_buffer_vert::getShader();
|
||||
const auto vs = gpu::Shader::createVertex(shader::render_utils::vertex::debug_deferred_buffer);
|
||||
|
||||
// Depth shader
|
||||
{
|
||||
static const std::string DEPTH_SHADER{
|
||||
"vec4 getFragmentColor() {"
|
||||
" float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;"
|
||||
" Zdb = 1.0-(1.0-Zdb)*100;"
|
||||
" return vec4(Zdb, Zdb, Zdb, 1.0); "
|
||||
"}"
|
||||
};
|
||||
static const std::string DEPTH_SHADER{ R"SHADER(
|
||||
vec4 getFragmentColor() {
|
||||
float Zdb = texelFetch(depthMap, ivec2(gl_FragCoord.xy), 0).x;
|
||||
Zdb = 1.0-(1.0-Zdb)*100;
|
||||
return vec4(Zdb, Zdb, Zdb, 1.0);
|
||||
}
|
||||
)SHADER" };
|
||||
|
||||
auto fragmentShader = FRAGMENT_SHADER;
|
||||
fragmentShader.replace(SOURCE_PLACEHOLDER_INDEX, SOURCE_PLACEHOLDER.size(), DEPTH_SHADER);
|
||||
|
@ -572,21 +561,13 @@ const render::Varying DrawHighlightTask::addSelectItemJobs(JobModel& task, const
|
|||
return task.addJob<SelectItems>("TransparentSelection", selectItemInput);
|
||||
}
|
||||
|
||||
#include "model_shadow_vert.h"
|
||||
#include "skin_model_shadow_vert.h"
|
||||
|
||||
#include "model_shadow_frag.h"
|
||||
|
||||
void DrawHighlightTask::initMaskPipelines(render::ShapePlumber& shapePlumber, gpu::StatePointer state) {
|
||||
auto modelVertex = model_shadow_vert::getShader();
|
||||
auto modelPixel = model_shadow_frag::getShader();
|
||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
|
||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(shader::render_utils::program::model_shadow);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withoutSkinned(),
|
||||
modelProgram, state);
|
||||
|
||||
auto skinVertex = skin_model_shadow_vert::getShader();
|
||||
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, modelPixel);
|
||||
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(shader::render_utils::program::skin_model_shadow);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withSkinned(),
|
||||
skinProgram, state);
|
||||
|
|
|
@ -9,24 +9,13 @@
|
|||
//
|
||||
|
||||
#include "LightClusters.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
||||
#include "RenderUtilsLogging.h"
|
||||
#include "StencilMaskPass.h"
|
||||
|
||||
#include "lightClusters_drawGrid_vert.h"
|
||||
#include "lightClusters_drawGrid_frag.h"
|
||||
|
||||
//#include "lightClusters_drawClusterFromDepth_vert.h"
|
||||
#include "lightClusters_drawClusterFromDepth_frag.h"
|
||||
|
||||
|
||||
#include "lightClusters_drawClusterContent_vert.h"
|
||||
#include "lightClusters_drawClusterContent_frag.h"
|
||||
|
||||
enum LightClusterGridShader_MapSlot {
|
||||
DEFERRED_BUFFER_LINEAR_DEPTH_UNIT = 0,
|
||||
|
@ -605,9 +594,7 @@ void DebugLightClusters::configure(const Config& config) {
|
|||
|
||||
const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() {
|
||||
if (!_drawClusterGrid) {
|
||||
auto vs = lightClusters_drawGrid_vert::getShader();
|
||||
auto ps = lightClusters_drawGrid_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawGrid);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("frustumGridBuffer"), LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT));
|
||||
|
@ -633,10 +620,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterGridPipeline() {
|
|||
|
||||
const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline() {
|
||||
if (!_drawClusterFromDepth) {
|
||||
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawGrid_vert));
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = lightClusters_drawClusterFromDepth_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawClusterFromDepth);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("frustumGridBuffer"), LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT));
|
||||
|
@ -663,11 +647,7 @@ const gpu::PipelinePointer DebugLightClusters::getDrawClusterFromDepthPipeline()
|
|||
|
||||
const gpu::PipelinePointer DebugLightClusters::getDrawClusterContentPipeline() {
|
||||
if (!_drawClusterContent) {
|
||||
// auto vs = gpu::Shader::createVertex(std::string(lightClusters_drawClusterContent_vert));
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = lightClusters_drawClusterContent_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::lightClusters_drawClusterContent);
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("lightBuffer"), LIGHT_GPU_SLOT));
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <ViewFrustum.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/Texture.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
||||
#include <render/ShapePipeline.h>
|
||||
|
||||
|
@ -34,8 +33,6 @@
|
|||
#include "RenderCommonTask.h"
|
||||
#include "LightStage.h"
|
||||
|
||||
#include "nop_frag.h"
|
||||
|
||||
using namespace render;
|
||||
extern void initForwardPipelines(ShapePlumber& plumber);
|
||||
|
||||
|
|
|
@ -15,89 +15,13 @@
|
|||
#include <functional>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <model-networking/TextureCache.h>
|
||||
#include <render/DrawTask.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "DeferredLightingEffect.h"
|
||||
#include "TextureCache.h"
|
||||
#include "render/DrawTask.h"
|
||||
|
||||
#include "model_vert.h"
|
||||
#include "model_normal_map_vert.h"
|
||||
#include "model_lightmap_vert.h"
|
||||
#include "model_lightmap_normal_map_vert.h"
|
||||
#include "skin_model_vert.h"
|
||||
#include "skin_model_normal_map_vert.h"
|
||||
#include "skin_model_dq_vert.h"
|
||||
#include "skin_model_normal_map_dq_vert.h"
|
||||
|
||||
#include "model_lightmap_fade_vert.h"
|
||||
#include "model_lightmap_normal_map_fade_vert.h"
|
||||
#include "model_translucent_vert.h"
|
||||
#include "model_translucent_normal_map_vert.h"
|
||||
#include "skin_model_fade_vert.h"
|
||||
#include "skin_model_normal_map_fade_vert.h"
|
||||
#include "skin_model_fade_dq_vert.h"
|
||||
#include "skin_model_normal_map_fade_dq_vert.h"
|
||||
|
||||
#include "simple_vert.h"
|
||||
#include "simple_textured_frag.h"
|
||||
#include "simple_textured_unlit_frag.h"
|
||||
#include "simple_transparent_textured_frag.h"
|
||||
#include "simple_transparent_textured_unlit_frag.h"
|
||||
|
||||
#include "simple_fade_vert.h"
|
||||
#include "simple_textured_fade_frag.h"
|
||||
#include "simple_textured_unlit_fade_frag.h"
|
||||
#include "simple_transparent_textured_fade_frag.h"
|
||||
#include "simple_transparent_textured_unlit_fade_frag.h"
|
||||
|
||||
#include "model_frag.h"
|
||||
#include "model_unlit_frag.h"
|
||||
#include "model_normal_map_frag.h"
|
||||
#include "model_fade_vert.h"
|
||||
#include "model_normal_map_fade_vert.h"
|
||||
|
||||
#include "model_fade_frag.h"
|
||||
#include "model_unlit_fade_frag.h"
|
||||
#include "model_normal_map_fade_frag.h"
|
||||
|
||||
#include "forward_model_frag.h"
|
||||
#include "forward_model_unlit_frag.h"
|
||||
#include "forward_model_normal_map_frag.h"
|
||||
#include "forward_model_translucent_frag.h"
|
||||
|
||||
#include "model_lightmap_frag.h"
|
||||
#include "model_lightmap_normal_map_frag.h"
|
||||
#include "model_translucent_frag.h"
|
||||
#include "model_translucent_unlit_frag.h"
|
||||
#include "model_translucent_normal_map_frag.h"
|
||||
|
||||
#include "model_lightmap_fade_frag.h"
|
||||
#include "model_lightmap_normal_map_fade_frag.h"
|
||||
#include "model_translucent_fade_frag.h"
|
||||
#include "model_translucent_unlit_fade_frag.h"
|
||||
#include "model_translucent_normal_map_fade_frag.h"
|
||||
|
||||
#include "model_shadow_vert.h"
|
||||
#include "skin_model_shadow_vert.h"
|
||||
#include "skin_model_shadow_dq_vert.h"
|
||||
#include "skin_model_shadow_fade_dq_vert.h"
|
||||
|
||||
#include "model_shadow_frag.h"
|
||||
#include "skin_model_shadow_frag.h"
|
||||
|
||||
#include "model_shadow_fade_vert.h"
|
||||
#include "skin_model_shadow_fade_vert.h"
|
||||
|
||||
#include "model_shadow_fade_frag.h"
|
||||
#include "skin_model_shadow_fade_frag.h"
|
||||
|
||||
#include "simple_vert.h"
|
||||
#include "forward_simple_textured_frag.h"
|
||||
#include "forward_simple_textured_transparent_frag.h"
|
||||
#include "forward_simple_textured_unlit_frag.h"
|
||||
|
||||
using namespace render;
|
||||
using namespace std::placeholders;
|
||||
|
@ -107,7 +31,7 @@ void initForwardPipelines(ShapePlumber& plumber);
|
|||
void initZPassPipelines(ShapePlumber& plumber, gpu::StatePointer state);
|
||||
|
||||
void addPlumberPipeline(ShapePlumber& plumber,
|
||||
const ShapeKey& key, const gpu::ShaderPointer& vertex, const gpu::ShaderPointer& pixel,
|
||||
const ShapeKey& key, int programId,
|
||||
const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter);
|
||||
|
||||
void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* args);
|
||||
|
@ -115,326 +39,239 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderAr
|
|||
static bool forceLightBatchSetter{ false };
|
||||
|
||||
void initDeferredPipelines(render::ShapePlumber& plumber, const render::ShapePipeline::BatchSetter& batchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
|
||||
// Vertex shaders
|
||||
auto simpleVertex = simple_vert::getShader();
|
||||
auto modelVertex = model_vert::getShader();
|
||||
auto modelNormalMapVertex = model_normal_map_vert::getShader();
|
||||
auto modelLightmapVertex = model_lightmap_vert::getShader();
|
||||
auto modelLightmapNormalMapVertex = model_lightmap_normal_map_vert::getShader();
|
||||
auto modelTranslucentVertex = model_translucent_vert::getShader();
|
||||
auto modelTranslucentNormalMapVertex = model_translucent_normal_map_vert::getShader();
|
||||
auto modelShadowVertex = model_shadow_vert::getShader();
|
||||
|
||||
auto modelLightmapFadeVertex = model_lightmap_fade_vert::getShader();
|
||||
auto modelLightmapNormalMapFadeVertex = model_lightmap_normal_map_fade_vert::getShader();
|
||||
|
||||
// matrix palette skinned
|
||||
auto skinModelVertex = skin_model_vert::getShader();
|
||||
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
|
||||
auto skinModelShadowVertex = skin_model_shadow_vert::getShader();
|
||||
auto skinModelFadeVertex = skin_model_fade_vert::getShader();
|
||||
auto skinModelNormalMapFadeVertex = skin_model_normal_map_fade_vert::getShader();
|
||||
auto skinModelTranslucentVertex = skinModelFadeVertex; // We use the same because it ouputs world position per vertex
|
||||
auto skinModelNormalMapTranslucentVertex = skinModelNormalMapFadeVertex; // We use the same because it ouputs world position per vertex
|
||||
|
||||
// dual quaternion skinned
|
||||
auto skinModelDualQuatVertex = skin_model_dq_vert::getShader();
|
||||
auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader();
|
||||
auto skinModelShadowDualQuatVertex = skin_model_shadow_dq_vert::getShader();
|
||||
auto skinModelShadowFadeDualQuatVertex = skin_model_shadow_fade_dq_vert::getShader();
|
||||
auto skinModelFadeDualQuatVertex = skin_model_fade_dq_vert::getShader();
|
||||
auto skinModelNormalMapFadeDualQuatVertex = skin_model_normal_map_fade_dq_vert::getShader();
|
||||
auto skinModelTranslucentDualQuatVertex = skinModelFadeDualQuatVertex; // We use the same because it ouputs world position per vertex
|
||||
auto skinModelNormalMapTranslucentDualQuatVertex = skinModelNormalMapFadeDualQuatVertex; // We use the same because it ouputs world position per vertex
|
||||
|
||||
auto modelFadeVertex = model_fade_vert::getShader();
|
||||
auto modelNormalMapFadeVertex = model_normal_map_fade_vert::getShader();
|
||||
auto simpleFadeVertex = simple_fade_vert::getShader();
|
||||
auto modelShadowFadeVertex = model_shadow_fade_vert::getShader();
|
||||
auto skinModelShadowFadeVertex = skin_model_shadow_fade_vert::getShader();
|
||||
|
||||
// Pixel shaders
|
||||
auto simplePixel = simple_textured_frag::getShader();
|
||||
auto simpleUnlitPixel = simple_textured_unlit_frag::getShader();
|
||||
auto simpleTranslucentPixel = simple_transparent_textured_frag::getShader();
|
||||
auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader();
|
||||
auto modelPixel = model_frag::getShader();
|
||||
auto modelUnlitPixel = model_unlit_frag::getShader();
|
||||
auto modelNormalMapPixel = model_normal_map_frag::getShader();
|
||||
auto modelTranslucentPixel = model_translucent_frag::getShader();
|
||||
auto modelTranslucentUnlitPixel = model_translucent_unlit_frag::getShader();
|
||||
auto modelTranslucentNormalMapPixel = model_translucent_normal_map_frag::getShader();
|
||||
auto modelShadowPixel = model_shadow_frag::getShader();
|
||||
auto modelLightmapPixel = model_lightmap_frag::getShader();
|
||||
auto modelLightmapNormalMapPixel = model_lightmap_normal_map_frag::getShader();
|
||||
auto modelLightmapFadePixel = model_lightmap_fade_frag::getShader();
|
||||
auto modelLightmapNormalMapFadePixel = model_lightmap_normal_map_fade_frag::getShader();
|
||||
|
||||
auto modelFadePixel = model_fade_frag::getShader();
|
||||
auto modelUnlitFadePixel = model_unlit_fade_frag::getShader();
|
||||
auto modelNormalMapFadePixel = model_normal_map_fade_frag::getShader();
|
||||
auto modelShadowFadePixel = model_shadow_fade_frag::getShader();
|
||||
auto modelTranslucentFadePixel = model_translucent_fade_frag::getShader();
|
||||
auto modelTranslucentUnlitFadePixel = model_translucent_unlit_fade_frag::getShader();
|
||||
auto modelTranslucentNormalMapFadePixel = model_translucent_normal_map_fade_frag::getShader();
|
||||
auto simpleFadePixel = simple_textured_fade_frag::getShader();
|
||||
auto simpleUnlitFadePixel = simple_textured_unlit_fade_frag::getShader();
|
||||
auto simpleTranslucentFadePixel = simple_transparent_textured_fade_frag::getShader();
|
||||
auto simpleTranslucentUnlitFadePixel = simple_transparent_textured_unlit_fade_frag::getShader();
|
||||
|
||||
using namespace shader::render_utils::program;
|
||||
using Key = render::ShapeKey;
|
||||
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
|
||||
auto addPipeline = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4);
|
||||
// TODO: Refactor this to use a filter
|
||||
// Opaques
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial(),
|
||||
modelVertex, modelPixel, nullptr, nullptr);
|
||||
model, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder(),
|
||||
simpleVertex, simplePixel, nullptr, nullptr);
|
||||
simple_textured, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withUnlit(),
|
||||
modelVertex, modelUnlitPixel, nullptr, nullptr);
|
||||
model_unlit, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withUnlit(),
|
||||
simpleVertex, simpleUnlitPixel, nullptr, nullptr);
|
||||
simple_textured_unlit, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTangents(),
|
||||
modelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr);
|
||||
model_normal_map, nullptr, nullptr);
|
||||
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withFade(),
|
||||
modelFadeVertex, modelFadePixel, batchSetter, itemSetter);
|
||||
model_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withFade(),
|
||||
simpleFadeVertex, simpleFadePixel, batchSetter, itemSetter);
|
||||
simple_textured_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withUnlit().withFade(),
|
||||
modelFadeVertex, modelUnlitFadePixel, batchSetter, itemSetter);
|
||||
model_unlit_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withUnlit().withFade(),
|
||||
simpleFadeVertex, simpleUnlitFadePixel, batchSetter, itemSetter);
|
||||
simple_textured_unlit_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTangents().withFade(),
|
||||
modelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter);
|
||||
model_normal_map_fade, batchSetter, itemSetter);
|
||||
|
||||
// Translucents
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent(),
|
||||
modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
|
||||
model_translucent, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withTranslucent(),
|
||||
simpleVertex, simpleTranslucentPixel, nullptr, nullptr);
|
||||
simple_transparent_textured, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent().withUnlit(),
|
||||
modelVertex, modelTranslucentUnlitPixel, nullptr, nullptr);
|
||||
model_translucent_unlit, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withTranslucent().withUnlit(),
|
||||
simpleVertex, simpleTranslucentUnlitPixel, nullptr, nullptr);
|
||||
simple_transparent_textured_unlit, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent().withTangents(),
|
||||
modelTranslucentNormalMapVertex, modelTranslucentNormalMapPixel, nullptr, nullptr);
|
||||
model_translucent_normal_map, nullptr, nullptr);
|
||||
addPipeline(
|
||||
// FIXME: Ignore lightmap for translucents meshpart
|
||||
Key::Builder().withMaterial().withTranslucent().withLightmap(),
|
||||
modelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
|
||||
model_translucent, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent().withFade(),
|
||||
modelTranslucentVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
|
||||
model_translucent_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withTranslucent().withFade(),
|
||||
simpleFadeVertex, simpleTranslucentFadePixel, batchSetter, itemSetter);
|
||||
simple_transparent_textured_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent().withUnlit().withFade(),
|
||||
modelFadeVertex, modelTranslucentUnlitFadePixel, batchSetter, itemSetter);
|
||||
model_translucent_unlit_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withTranslucent().withUnlit().withFade(),
|
||||
simpleFadeVertex, simpleTranslucentUnlitFadePixel, batchSetter, itemSetter);
|
||||
simple_transparent_textured_unlit_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withTranslucent().withTangents().withFade(),
|
||||
modelTranslucentNormalMapVertex, modelTranslucentNormalMapFadePixel, batchSetter, itemSetter);
|
||||
model_translucent_normal_map_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
// FIXME: Ignore lightmap for translucents meshpart
|
||||
Key::Builder().withMaterial().withTranslucent().withLightmap().withFade(),
|
||||
modelFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
|
||||
|
||||
model_translucent_fade, batchSetter, itemSetter);
|
||||
// Lightmapped
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap(),
|
||||
modelLightmapVertex, modelLightmapPixel, nullptr, nullptr);
|
||||
model_lightmap, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withTangents(),
|
||||
modelLightmapNormalMapVertex, modelLightmapNormalMapPixel, nullptr, nullptr);
|
||||
model_lightmap_normal_map, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withFade(),
|
||||
modelLightmapFadeVertex, modelLightmapFadePixel, batchSetter, itemSetter);
|
||||
model_lightmap_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withLightmap().withTangents().withFade(),
|
||||
modelLightmapNormalMapFadeVertex, modelLightmapNormalMapFadePixel, batchSetter, itemSetter);
|
||||
model_lightmap_normal_map_fade, batchSetter, itemSetter);
|
||||
|
||||
// matrix palette skinned
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned(),
|
||||
skinModelVertex, modelPixel, nullptr, nullptr);
|
||||
skin_model, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTangents(),
|
||||
skinModelNormalMapVertex, modelNormalMapPixel, nullptr, nullptr);
|
||||
skin_model_normal_map, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withFade(),
|
||||
skinModelFadeVertex, modelFadePixel, batchSetter, itemSetter);
|
||||
skin_model_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTangents().withFade(),
|
||||
skinModelNormalMapFadeVertex, modelNormalMapFadePixel, batchSetter, itemSetter);
|
||||
|
||||
skin_model_normal_map_fade, batchSetter, itemSetter);
|
||||
// matrix palette skinned and translucent
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent(),
|
||||
skinModelTranslucentVertex, modelTranslucentPixel, nullptr, nullptr);
|
||||
skin_model_translucent, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(),
|
||||
skinModelNormalMapTranslucentVertex, modelTranslucentNormalMapPixel, nullptr, nullptr);
|
||||
skin_model_normal_map_translucent, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent().withFade(),
|
||||
skinModelFadeVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
|
||||
skin_model_translucent_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withFade(),
|
||||
skinModelNormalMapFadeVertex, modelTranslucentNormalMapFadePixel, batchSetter, itemSetter);
|
||||
skin_model_normal_map_translucent_fade, batchSetter, itemSetter);
|
||||
|
||||
// dual quaternion skinned
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned(),
|
||||
skinModelDualQuatVertex, modelPixel, nullptr, nullptr);
|
||||
skin_model_dq, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTangents(),
|
||||
skinModelNormalMapDualQuatVertex, modelNormalMapPixel, nullptr, nullptr);
|
||||
skin_model_normal_map_dq, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withFade(),
|
||||
skinModelFadeDualQuatVertex, modelFadePixel, batchSetter, itemSetter);
|
||||
skin_model_fade_dq, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTangents().withFade(),
|
||||
skinModelNormalMapFadeDualQuatVertex, modelNormalMapFadePixel, batchSetter, itemSetter);
|
||||
|
||||
skin_model_normal_map_fade_dq, batchSetter, itemSetter);
|
||||
// dual quaternion skinned and translucent
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent(),
|
||||
skinModelTranslucentDualQuatVertex, modelTranslucentPixel, nullptr, nullptr);
|
||||
skin_model_translucent_dq, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withTangents(),
|
||||
skinModelNormalMapTranslucentDualQuatVertex, modelTranslucentNormalMapPixel, nullptr, nullptr);
|
||||
skin_model_normal_map_translucent_dq, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withFade(),
|
||||
skinModelFadeDualQuatVertex, modelTranslucentFadePixel, batchSetter, itemSetter);
|
||||
skin_model_translucent_fade_dq, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withMaterial().withSkinned().withDualQuatSkinned().withTranslucent().withTangents().withFade(),
|
||||
skinModelNormalMapFadeDualQuatVertex, modelTranslucentNormalMapFadePixel, batchSetter, itemSetter);
|
||||
skin_model_normal_map_translucent_fade_dq, batchSetter, itemSetter);
|
||||
|
||||
// Depth-only
|
||||
addPipeline(
|
||||
Key::Builder().withDepthOnly(),
|
||||
modelShadowVertex, modelShadowPixel, nullptr, nullptr);
|
||||
model_shadow, nullptr, nullptr);
|
||||
addPipeline(
|
||||
Key::Builder().withSkinned().withDepthOnly(),
|
||||
skinModelShadowVertex, modelShadowPixel, nullptr, nullptr);
|
||||
skin_model_shadow, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withDepthOnly().withFade(),
|
||||
modelShadowFadeVertex, modelShadowFadePixel, batchSetter, itemSetter);
|
||||
model_shadow_fade, batchSetter, itemSetter);
|
||||
addPipeline(
|
||||
Key::Builder().withSkinned().withDepthOnly().withFade(),
|
||||
skinModelShadowFadeVertex, modelShadowFadePixel, batchSetter, itemSetter);
|
||||
skin_model_shadow_fade, batchSetter, itemSetter);
|
||||
|
||||
// Now repeat for dual quaternion
|
||||
// Depth-only
|
||||
addPipeline(
|
||||
Key::Builder().withSkinned().withDualQuatSkinned().withDepthOnly(),
|
||||
skinModelShadowDualQuatVertex, modelShadowPixel, nullptr, nullptr);
|
||||
skin_model_shadow_dq, nullptr, nullptr);
|
||||
// Same thing but with Fade on
|
||||
addPipeline(
|
||||
Key::Builder().withSkinned().withDualQuatSkinned().withDepthOnly().withFade(),
|
||||
skinModelShadowFadeDualQuatVertex, modelShadowFadePixel, batchSetter, itemSetter);
|
||||
skin_model_shadow_fade_dq, batchSetter, itemSetter);
|
||||
}
|
||||
|
||||
void initForwardPipelines(ShapePlumber& plumber) {
|
||||
// Vertex shaders
|
||||
auto simpleVertex = simple_vert::getShader();
|
||||
auto modelVertex = model_vert::getShader();
|
||||
auto modelNormalMapVertex = model_normal_map_vert::getShader();
|
||||
auto skinModelVertex = skin_model_vert::getShader();
|
||||
auto skinModelNormalMapVertex = skin_model_normal_map_vert::getShader();
|
||||
|
||||
auto skinModelDualQuatVertex = skin_model_dq_vert::getShader();
|
||||
auto skinModelNormalMapDualQuatVertex = skin_model_normal_map_dq_vert::getShader();
|
||||
|
||||
// Pixel shaders
|
||||
auto simplePixel = forward_simple_textured_frag::getShader();
|
||||
auto simpleTranslucentPixel = forward_simple_textured_transparent_frag::getShader();
|
||||
auto simpleUnlitPixel = forward_simple_textured_unlit_frag::getShader();
|
||||
auto simpleTranslucentUnlitPixel = simple_transparent_textured_unlit_frag::getShader();
|
||||
auto modelPixel = forward_model_frag::getShader();
|
||||
auto modelUnlitPixel = forward_model_unlit_frag::getShader();
|
||||
auto modelNormalMapPixel = forward_model_normal_map_frag::getShader();
|
||||
auto modelTranslucentPixel = forward_model_translucent_frag::getShader();
|
||||
using namespace shader::render_utils::program;
|
||||
|
||||
using Key = render::ShapeKey;
|
||||
auto addPipelineBind = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4, _5);
|
||||
auto addPipelineBind = std::bind(&addPlumberPipeline, std::ref(plumber), _1, _2, _3, _4);
|
||||
|
||||
// Disable fade on the forward pipeline, all shaders get added twice, once with the fade key and once without
|
||||
auto addPipeline = [&](const ShapeKey& key, const gpu::ShaderPointer& vertex, const gpu::ShaderPointer& pixel) {
|
||||
addPipelineBind(key, vertex, pixel, nullptr, nullptr);
|
||||
addPipelineBind(Key::Builder(key).withFade(), vertex, pixel, nullptr, nullptr);
|
||||
auto addPipeline = [&](const ShapeKey& key, int programId) {
|
||||
addPipelineBind(key, programId, nullptr, nullptr);
|
||||
addPipelineBind(Key::Builder(key).withFade(), programId, nullptr, nullptr);
|
||||
};
|
||||
|
||||
// Forward pipelines need the lightBatchSetter for opaques and transparents
|
||||
forceLightBatchSetter = true;
|
||||
|
||||
// Simple Opaques
|
||||
addPipeline(Key::Builder(), simpleVertex, simplePixel);
|
||||
addPipeline(Key::Builder().withUnlit(), simpleVertex, simpleUnlitPixel);
|
||||
addPipeline(Key::Builder(), simple);
|
||||
addPipeline(Key::Builder().withUnlit(), simpleUnlit);
|
||||
|
||||
// Simple Translucents
|
||||
addPipeline(Key::Builder().withTranslucent(), simpleVertex, simpleTranslucentPixel);
|
||||
addPipeline(Key::Builder().withTranslucent().withUnlit(), simpleVertex, simpleTranslucentUnlitPixel);
|
||||
addPipeline(Key::Builder().withTranslucent(), simpleTranslucent);
|
||||
addPipeline(Key::Builder().withTranslucent().withUnlit(), simpleTranslucentUnlit);
|
||||
|
||||
// Opaques
|
||||
addPipeline(Key::Builder().withMaterial(), modelVertex, modelPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withUnlit(), modelVertex, modelUnlitPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withTangents(), modelNormalMapVertex, modelNormalMapPixel);
|
||||
addPipeline(Key::Builder().withMaterial(), forward_model);
|
||||
addPipeline(Key::Builder().withMaterial().withUnlit(), forward_model_unlit);
|
||||
addPipeline(Key::Builder().withMaterial().withTangents(), forward_model_translucent);
|
||||
|
||||
// Skinned Opaques
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned(), skinModelVertex, modelPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), skinModelNormalMapVertex, modelNormalMapPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withDualQuatSkinned(), skinModelDualQuatVertex, modelPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents().withDualQuatSkinned(), skinModelNormalMapDualQuatVertex, modelNormalMapPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned(), forward_skin_model);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents(), forward_skin_model_normal_map);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withDualQuatSkinned(), forward_skin_model_dq);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTangents().withDualQuatSkinned(), forward_skin_model_normal_map_dq);
|
||||
|
||||
// Translucents
|
||||
addPipeline(Key::Builder().withMaterial().withTranslucent(), modelVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), modelNormalMapVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withTranslucent(), forward_model_translucent);
|
||||
addPipeline(Key::Builder().withMaterial().withTranslucent().withTangents(), forward_model_normal_map_translucent);
|
||||
|
||||
// Skinned Translucents
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), skinModelVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), skinModelNormalMapVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withDualQuatSkinned(), skinModelDualQuatVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withDualQuatSkinned(), skinModelNormalMapDualQuatVertex, modelTranslucentPixel);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent(), forward_skin_translucent);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents(), forward_skin_translucent_normal_map);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withDualQuatSkinned(), forward_skin_translucent_dq);
|
||||
addPipeline(Key::Builder().withMaterial().withSkinned().withTranslucent().withTangents().withDualQuatSkinned(), forward_skin_translucent_normal_map_dq);
|
||||
|
||||
forceLightBatchSetter = false;
|
||||
}
|
||||
|
||||
void addPlumberPipeline(ShapePlumber& plumber,
|
||||
const ShapeKey& key, const gpu::ShaderPointer& vertex, const gpu::ShaderPointer& pixel,
|
||||
const ShapeKey& key, int programId,
|
||||
const render::ShapePipeline::BatchSetter& extraBatchSetter, const render::ShapePipeline::ItemSetter& itemSetter) {
|
||||
// These key-values' pipelines are added by this functor in addition to the key passed
|
||||
assert(!key.isWireframe());
|
||||
assert(!key.isDepthBiased());
|
||||
assert(key.isCullFace());
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vertex, pixel);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(programId);
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
bool isCulled = (i & 1);
|
||||
|
@ -517,43 +354,33 @@ void lightBatchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderAr
|
|||
}
|
||||
|
||||
void initZPassPipelines(ShapePlumber& shapePlumber, gpu::StatePointer state) {
|
||||
auto modelVertex = model_shadow_vert::getShader();
|
||||
auto modelPixel = model_shadow_frag::getShader();
|
||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(modelVertex, modelPixel);
|
||||
using namespace shader::render_utils::program;
|
||||
gpu::ShaderPointer modelProgram = gpu::Shader::createProgram(model_shadow);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withoutSkinned().withoutFade(),
|
||||
modelProgram, state);
|
||||
|
||||
auto skinVertex = skin_model_shadow_vert::getShader();
|
||||
auto skinPixel = skin_model_shadow_frag::getShader();
|
||||
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skinVertex, skinPixel);
|
||||
gpu::ShaderPointer skinProgram = gpu::Shader::createProgram(skin_model_shadow);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withSkinned().withoutDualQuatSkinned().withoutFade(),
|
||||
skinProgram, state);
|
||||
|
||||
auto modelFadeVertex = model_shadow_fade_vert::getShader();
|
||||
auto modelFadePixel = model_shadow_fade_frag::getShader();
|
||||
gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(modelFadeVertex, modelFadePixel);
|
||||
gpu::ShaderPointer modelFadeProgram = gpu::Shader::createProgram(model_shadow_fade);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withoutSkinned().withFade(),
|
||||
modelFadeProgram, state);
|
||||
|
||||
auto skinFadeVertex = skin_model_shadow_fade_vert::getShader();
|
||||
auto skinFadePixel = skin_model_shadow_fade_frag::getShader();
|
||||
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skinFadeVertex, skinFadePixel);
|
||||
gpu::ShaderPointer skinFadeProgram = gpu::Shader::createProgram(skin_model_shadow_fade);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withSkinned().withoutDualQuatSkinned().withFade(),
|
||||
skinFadeProgram, state);
|
||||
|
||||
//Added for dual quaternions
|
||||
auto skinModelShadowDualQuatVertex = skin_model_shadow_dq_vert::getShader();
|
||||
gpu::ShaderPointer skinModelShadowDualQuatProgram = gpu::Shader::createProgram(skinModelShadowDualQuatVertex, skinPixel);
|
||||
gpu::ShaderPointer skinModelShadowDualQuatProgram = gpu::Shader::createProgram(skin_model_shadow_dq);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withSkinned().withDualQuatSkinned().withoutFade(),
|
||||
skinModelShadowDualQuatProgram, state);
|
||||
|
||||
auto skinModelShadowFadeDualQuatVertex = skin_model_shadow_fade_dq_vert::getShader();
|
||||
gpu::ShaderPointer skinModelShadowFadeDualQuatProgram = gpu::Shader::createProgram(skinModelShadowFadeDualQuatVertex, skinFadePixel);
|
||||
gpu::ShaderPointer skinModelShadowFadeDualQuatProgram = gpu::Shader::createProgram(skin_model_shadow_fade_dq);
|
||||
shapePlumber.addPipeline(
|
||||
ShapeKey::Filter::Builder().withSkinned().withDualQuatSkinned().withFade(),
|
||||
skinModelShadowFadeDualQuatProgram, state);
|
||||
|
|
|
@ -13,11 +13,7 @@
|
|||
|
||||
#include <ViewFrustum.h>
|
||||
#include <gpu/Context.h>
|
||||
|
||||
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
||||
#include "stencil_drawMask_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
@ -43,9 +39,7 @@ graphics::MeshPointer PrepareStencil::getMesh() {
|
|||
|
||||
gpu::PipelinePointer PrepareStencil::getMeshStencilPipeline() {
|
||||
if (!_meshStencilPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawVertexPositionVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawNadaPS();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
auto program = gpu::Shader::createProgram(shader::gpu::program::drawNothing);
|
||||
gpu::Shader::makeProgram((*program));
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
@ -59,9 +53,7 @@ gpu::PipelinePointer PrepareStencil::getMeshStencilPipeline() {
|
|||
|
||||
gpu::PipelinePointer PrepareStencil::getPaintStencilPipeline() {
|
||||
if (!_paintStencilPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = stencil_drawMask_frag::getShader();
|
||||
auto program = gpu::Shader::createProgram(vs, ps);
|
||||
auto program = gpu::Shader::createProgram(shader::render_utils::program::stencil_drawMask);
|
||||
gpu::Shader::makeProgram((*program));
|
||||
|
||||
auto state = std::make_shared<gpu::State>();
|
||||
|
|
|
@ -11,17 +11,12 @@
|
|||
#include "SubsurfaceScattering.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "FramebufferCache.h"
|
||||
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
||||
#include "subsurfaceScattering_makeProfile_frag.h"
|
||||
#include "subsurfaceScattering_makeLUT_frag.h"
|
||||
#include "subsurfaceScattering_makeSpecularBeckmann_frag.h"
|
||||
|
||||
#include "subsurfaceScattering_drawScattering_frag.h"
|
||||
|
||||
enum ScatteringShaderBufferSlots {
|
||||
ScatteringTask_FrameTransformSlot = 0,
|
||||
|
@ -307,9 +302,7 @@ void diffuseProfileGPU(gpu::TexturePointer& profileMap, RenderArgs* args) {
|
|||
|
||||
gpu::PipelinePointer makePipeline;
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = subsurfaceScattering_makeProfile_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::subsurfaceScattering_makeProfile);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
|
@ -338,15 +331,11 @@ void diffuseScatterGPU(const gpu::TexturePointer& profileMap, gpu::TexturePointe
|
|||
int width = lut->getWidth();
|
||||
int height = lut->getHeight();
|
||||
|
||||
gpu::PipelinePointer makePipeline;
|
||||
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = subsurfaceScattering_makeLUT_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::subsurfaceScattering_makeLUT);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
makePipeline = gpu::Pipeline::create(program, state);
|
||||
gpu::PipelinePointer makePipeline = gpu::Pipeline::create(program, state);
|
||||
|
||||
auto makeFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("diffuseScatter"));
|
||||
makeFramebuffer->setRenderBuffer(0, lut);
|
||||
|
@ -379,9 +368,7 @@ void computeSpecularBeckmannGPU(gpu::TexturePointer& beckmannMap, RenderArgs* ar
|
|||
|
||||
gpu::PipelinePointer makePipeline;
|
||||
{
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = subsurfaceScattering_makeSpecularBeckmann_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::subsurfaceScattering_makeSpecularBeckmann);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
|
@ -451,9 +438,7 @@ void DebugSubsurfaceScattering::configure(const Config& config) {
|
|||
|
||||
gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() {
|
||||
if (!_scatteringPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = subsurfaceScattering_drawScattering_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::subsurfaceScattering_drawScattering);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), ScatteringTask_FrameTransformSlot));
|
||||
|
@ -480,19 +465,12 @@ gpu::PipelinePointer DebugSubsurfaceScattering::getScatteringPipeline() {
|
|||
return _scatteringPipeline;
|
||||
}
|
||||
|
||||
|
||||
gpu::PipelinePointer _showLUTPipeline;
|
||||
gpu::PipelinePointer getShowLUTPipeline();
|
||||
|
||||
gpu::PipelinePointer DebugSubsurfaceScattering::getShowLUTPipeline() {
|
||||
if (!_showLUTPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawUnitQuatTextureOpaque);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
_showLUTPipeline = gpu::Pipeline::create(program, state);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
#include <limits>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
|
||||
const int DepthLinearPass_FrameTransformSlot = 0;
|
||||
|
@ -25,13 +26,6 @@ const int SurfaceGeometryPass_ParamsSlot = 1;
|
|||
const int SurfaceGeometryPass_DepthMapSlot = 0;
|
||||
const int SurfaceGeometryPass_NormalMapSlot = 1;
|
||||
|
||||
#include "surfaceGeometry_makeLinearDepth_frag.h"
|
||||
#include "surfaceGeometry_downsampleDepthNormal_frag.h"
|
||||
|
||||
#include "surfaceGeometry_makeCurvature_frag.h"
|
||||
|
||||
|
||||
|
||||
LinearDepthFramebuffer::LinearDepthFramebuffer() {
|
||||
}
|
||||
|
||||
|
@ -212,9 +206,7 @@ void LinearDepthPass::run(const render::RenderContextPointer& renderContext, con
|
|||
const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline(const render::RenderContextPointer& renderContext) {
|
||||
gpu::ShaderPointer program;
|
||||
if (!_linearDepthPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = surfaceGeometry_makeLinearDepth_frag::getShader();
|
||||
program = gpu::Shader::createProgram(vs, ps);
|
||||
program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_makeLinearDepth);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
|
@ -243,9 +235,7 @@ const gpu::PipelinePointer& LinearDepthPass::getLinearDepthPipeline(const render
|
|||
|
||||
const gpu::PipelinePointer& LinearDepthPass::getDownsamplePipeline(const render::RenderContextPointer& renderContext) {
|
||||
if (!_downsamplePipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = surfaceGeometry_downsampleDepthNormal_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_downsampleDepthNormal);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
PrepareStencil::testShape(*state);
|
||||
|
@ -546,9 +536,7 @@ void SurfaceGeometryPass::run(const render::RenderContextPointer& renderContext,
|
|||
|
||||
const gpu::PipelinePointer& SurfaceGeometryPass::getCurvaturePipeline(const render::RenderContextPointer& renderContext) {
|
||||
if (!_curvaturePipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = surfaceGeometry_makeCurvature_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::surfaceGeometry_makeCurvature);
|
||||
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
#include <QStringList>
|
||||
#include <QFile>
|
||||
|
||||
#include <shaders/Shaders.h>
|
||||
#include "text/Font.h"
|
||||
|
||||
#include "GLMHelpers.h"
|
||||
#include "MatrixStack.h"
|
||||
#include "RenderUtilsLogging.h"
|
||||
|
||||
#include "sdf_text3D_vert.h"
|
||||
#include "sdf_text3D_frag.h"
|
||||
|
||||
#include "GeometryCache.h"
|
||||
|
||||
const float TextRenderer3D::DEFAULT_POINT_SIZE = 12;
|
||||
|
|
|
@ -12,12 +12,11 @@
|
|||
#include "ToneMappingEffect.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "FramebufferCache.h"
|
||||
|
||||
#include "toneMapping_frag.h"
|
||||
|
||||
const int ToneMappingEffect_ParamsSlot = 0;
|
||||
const int ToneMappingEffect_LightingMapSlot = 0;
|
||||
|
@ -28,10 +27,7 @@ ToneMappingEffect::ToneMappingEffect() {
|
|||
}
|
||||
|
||||
void ToneMappingEffect::init(RenderArgs* args) {
|
||||
auto blitPS = toneMapping_frag::getShader();
|
||||
|
||||
auto blitVS = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto blitProgram = gpu::ShaderPointer(gpu::Shader::createProgram(blitVS, blitPS));
|
||||
auto blitProgram = gpu::Shader::createProgram(shader::render_utils::program::toneMapping);
|
||||
|
||||
auto blitState = std::make_shared<gpu::State>();
|
||||
blitState->setColorWriteMask(true, true, true, true);
|
||||
|
|
|
@ -13,15 +13,13 @@
|
|||
#include <limits>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
|
||||
const int VelocityBufferPass_FrameTransformSlot = 0;
|
||||
const int VelocityBufferPass_DepthMapSlot = 0;
|
||||
|
||||
|
||||
#include "velocityBuffer_cameraMotion_frag.h"
|
||||
|
||||
VelocityFramebuffer::VelocityFramebuffer() {
|
||||
}
|
||||
|
||||
|
@ -145,10 +143,7 @@ void VelocityBufferPass::run(const render::RenderContextPointer& renderContext,
|
|||
|
||||
const gpu::PipelinePointer& VelocityBufferPass::getCameraMotionPipeline(const render::RenderContextPointer& renderContext) {
|
||||
if (!_cameraMotionPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawViewportQuadTransformTexcoordVS();
|
||||
auto ps = velocityBuffer_cameraMotion_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::velocityBuffer_cameraMotion);
|
||||
gpu::StatePointer state = gpu::StatePointer(new gpu::State());
|
||||
|
||||
// Stencil test the curvature pass for objects pixels only, not the background
|
||||
|
|
|
@ -10,21 +10,15 @@
|
|||
//
|
||||
#include "ZoneRenderer.h"
|
||||
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
||||
#include <render/FilterTask.h>
|
||||
#include <render/DrawTask.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "StencilMaskPass.h"
|
||||
#include "DeferredLightingEffect.h"
|
||||
|
||||
#include "zone_drawKeyLight_frag.h"
|
||||
#include "zone_drawAmbient_frag.h"
|
||||
#include "zone_drawSkybox_frag.h"
|
||||
|
||||
|
||||
using namespace render;
|
||||
|
||||
class SetupZones {
|
||||
|
@ -77,9 +71,7 @@ void SetupZones::run(const RenderContextPointer& context, const Inputs& inputs)
|
|||
|
||||
const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
|
||||
if (!_keyLightPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = zone_drawKeyLight_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::zone_drawKeyLight);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), ZONE_DEFERRED_TRANSFORM_BUFFER));
|
||||
|
@ -98,9 +90,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getKeyLightPipeline() {
|
|||
|
||||
const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
|
||||
if (!_ambientPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = zone_drawAmbient_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::zone_drawAmbient);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), ZONE_DEFERRED_TRANSFORM_BUFFER));
|
||||
|
@ -119,9 +109,7 @@ const gpu::PipelinePointer& DebugZoneLighting::getAmbientPipeline() {
|
|||
}
|
||||
const gpu::PipelinePointer& DebugZoneLighting::getBackgroundPipeline() {
|
||||
if (!_backgroundPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = zone_drawSkybox_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::zone_drawSkybox);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("deferredFrameTransformBuffer"), ZONE_DEFERRED_TRANSFORM_BUFFER));
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_shadow.frag
|
||||
// fragment shader
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
layout(location = 0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
// pass-through to set z-buffer
|
||||
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<@include gpu/Config.slh@>
|
||||
<$VERSION_HEADER$>
|
||||
// Generated on <$_SCRIBE_DATE$>
|
||||
//
|
||||
// skin_model_shadow_fade.frag
|
||||
// fragment shader
|
||||
//
|
||||
// Created by Olivier Prat on 06/08/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 Fade.slh@>
|
||||
<$declareFadeFragment()$>
|
||||
|
||||
in vec4 _positionWS;
|
||||
|
||||
layout(location = 0) out vec4 _fragColor;
|
||||
|
||||
void main(void) {
|
||||
FadeObjectParams fadeParams;
|
||||
|
||||
<$fetchFadeObjectParams(fadeParams)$>
|
||||
applyFadeClip(fadeParams, _positionWS.xyz);
|
||||
|
||||
// pass-through to set z-buffer
|
||||
_fragColor = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
|
@ -6,10 +6,7 @@
|
|||
#include <ColorUtils.h>
|
||||
|
||||
#include <StreamHelpers.h>
|
||||
|
||||
#include "sdf_text3D_vert.h"
|
||||
#include "sdf_text3D_frag.h"
|
||||
#include "sdf_text3D_transparent_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "../RenderUtilsLogging.h"
|
||||
#include "FontFamilies.h"
|
||||
|
@ -223,11 +220,8 @@ void Font::setupGPU() {
|
|||
|
||||
// Setup render pipeline
|
||||
{
|
||||
auto vertexShader = sdf_text3D_vert::getShader();
|
||||
auto pixelShader = sdf_text3D_frag::getShader();
|
||||
auto pixelShaderTransparent = sdf_text3D_transparent_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vertexShader, pixelShader);
|
||||
gpu::ShaderPointer programTransparent = gpu::Shader::createProgram(vertexShader, pixelShaderTransparent);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D);
|
||||
gpu::ShaderPointer programTransparent = gpu::Shader::createProgram(shader::render_utils::program::sdf_text3D_transparent);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
set(TARGET_NAME render)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||
setup_hifi_library()
|
||||
|
||||
# render needs octree only for getAccuracyAngle(float, int)
|
||||
link_hifi_libraries(shared task ktx gpu graphics octree)
|
||||
link_hifi_libraries(shared task ktx gpu shaders graphics octree)
|
||||
|
||||
target_nsight()
|
||||
|
|
|
@ -11,13 +11,7 @@
|
|||
#include "BlurTask.h"
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
|
||||
#include "blurGaussianV_frag.h"
|
||||
#include "blurGaussianH_frag.h"
|
||||
|
||||
#include "blurGaussianDepthAwareV_frag.h"
|
||||
#include "blurGaussianDepthAwareH_frag.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
@ -209,9 +203,7 @@ BlurGaussian::BlurGaussian(bool generateOutputFramebuffer, unsigned int downsamp
|
|||
|
||||
gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
|
||||
if (!_blurVPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = blurGaussianV_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::blurGaussianV);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("blurParamsBuffer"), BlurTask_ParamsSlot));
|
||||
|
@ -231,9 +223,7 @@ gpu::PipelinePointer BlurGaussian::getBlurVPipeline() {
|
|||
|
||||
gpu::PipelinePointer BlurGaussian::getBlurHPipeline() {
|
||||
if (!_blurHPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = blurGaussianH_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::blurGaussianH);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("blurParamsBuffer"), BlurTask_ParamsSlot));
|
||||
|
@ -323,9 +313,7 @@ BlurGaussianDepthAware::BlurGaussianDepthAware(bool generateOutputFramebuffer, c
|
|||
|
||||
gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
|
||||
if (!_blurVPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = blurGaussianDepthAwareV_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::blurGaussianDepthAwareV);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("blurParamsBuffer"), BlurTask_ParamsSlot));
|
||||
|
@ -346,9 +334,7 @@ gpu::PipelinePointer BlurGaussianDepthAware::getBlurVPipeline() {
|
|||
|
||||
gpu::PipelinePointer BlurGaussianDepthAware::getBlurHPipeline() {
|
||||
if (!_blurHPipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawUnitQuadTexcoordVS();
|
||||
auto ps = blurGaussianDepthAwareH_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::blurGaussianDepthAwareH);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("blurParamsBuffer"), BlurTask_ParamsSlot));
|
||||
|
|
|
@ -18,25 +18,17 @@
|
|||
#include <PerfStat.h>
|
||||
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "Args.h"
|
||||
|
||||
#include "drawCellBounds_vert.h"
|
||||
#include "drawCellBounds_frag.h"
|
||||
#include "drawLODReticle_frag.h"
|
||||
|
||||
#include "drawItemBounds_vert.h"
|
||||
#include "drawItemBounds_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
||||
const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
|
||||
if (!_drawCellBoundsPipeline) {
|
||||
auto vs = drawCellBounds_vert::getShader();
|
||||
auto ps = drawCellBounds_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawCellBounds);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
@ -58,12 +50,8 @@ const gpu::PipelinePointer DrawSceneOctree::getDrawCellBoundsPipeline() {
|
|||
|
||||
const gpu::PipelinePointer DrawSceneOctree::getDrawLODReticlePipeline() {
|
||||
if (!_drawLODReticlePipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = drawLODReticle_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawLODReticle);
|
||||
gpu::Shader::makeProgram(*program);
|
||||
|
||||
// _drawCellLocationLoc = program->getUniforms().findLocation("inCellLocation");
|
||||
|
||||
|
@ -162,9 +150,7 @@ void DrawSceneOctree::run(const RenderContextPointer& renderContext, const ItemS
|
|||
|
||||
const gpu::PipelinePointer DrawItemSelection::getDrawItemBoundPipeline() {
|
||||
if (!_drawItemBoundPipeline) {
|
||||
auto vs = drawItemBounds_vert::getShader();
|
||||
auto ps = drawItemBounds_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
|
||||
#include <gpu/Context.h>
|
||||
|
||||
#include "Args.h"
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "drawItemBounds_vert.h"
|
||||
#include "drawItemBounds_frag.h"
|
||||
#include "drawItemStatus_vert.h"
|
||||
#include "drawItemStatus_frag.h"
|
||||
#include "Args.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
@ -35,9 +32,7 @@ void DrawStatusConfig::dirtyHelper() {
|
|||
|
||||
const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
|
||||
if (!_drawItemBoundsPipeline) {
|
||||
auto vs = drawItemBounds_vert::getShader();
|
||||
auto ps = drawItemBounds_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
@ -63,9 +58,7 @@ const gpu::PipelinePointer DrawStatus::getDrawItemBoundsPipeline() {
|
|||
|
||||
const gpu::PipelinePointer DrawStatus::getDrawItemStatusPipeline() {
|
||||
if (!_drawItemStatusPipeline) {
|
||||
auto vs = drawItemStatus_vert::getShader();
|
||||
auto ps = drawItemStatus_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemStatus);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding(std::string("iconStatusMap"), 0));
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
#include <PerfStat.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <gpu/Context.h>
|
||||
#include <gpu/StandardShaderLib.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
#include "Logging.h"
|
||||
|
||||
#include "drawItemBounds_vert.h"
|
||||
#include "drawItemBounds_frag.h"
|
||||
|
||||
using namespace render;
|
||||
|
||||
void render::renderItems(const RenderContextPointer& renderContext, const ItemBounds& inItems, int maxDrawnItems) {
|
||||
|
@ -160,9 +157,7 @@ void DrawLight::run(const RenderContextPointer& renderContext, const ItemBounds&
|
|||
|
||||
const gpu::PipelinePointer DrawBounds::getPipeline() {
|
||||
if (!_boundsPipeline) {
|
||||
auto vs = drawItemBounds_vert::getShader();
|
||||
auto ps = drawItemBounds_frag::getShader();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::render::program::drawItemBounds);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
@ -267,9 +262,7 @@ gpu::PipelinePointer DrawQuadVolume::getPipeline() {
|
|||
static gpu::PipelinePointer pipeline;
|
||||
|
||||
if (!pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformVertexPositionVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawColorPS();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawColor);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
slotBindings.insert(gpu::Shader::Binding("color", 0));
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
//
|
||||
#include "ResampleTask.h"
|
||||
|
||||
#include "gpu/Context.h"
|
||||
#include "gpu/StandardShaderLib.h"
|
||||
#include <gpu/Context.h>
|
||||
#include <shaders/Shaders.h>
|
||||
|
||||
using namespace render;
|
||||
|
||||
|
@ -51,9 +51,7 @@ void HalfDownsample::run(const RenderContextPointer& renderContext, const gpu::F
|
|||
resampledFrameBuffer = getResampledFrameBuffer(sourceFramebuffer);
|
||||
|
||||
if (!_pipeline) {
|
||||
auto vs = gpu::StandardShaderLib::getDrawTransformUnitQuadVS();
|
||||
auto ps = gpu::StandardShaderLib::getDrawTextureOpaquePS();
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(vs, ps);
|
||||
gpu::ShaderPointer program = gpu::Shader::createProgram(shader::gpu::program::drawTransformUnitQuadTextureOpaque);
|
||||
|
||||
gpu::Shader::BindingSet slotBindings;
|
||||
gpu::Shader::makeProgram(*program, slotBindings);
|
||||
|
|
175
libraries/shaders/CMakeLists.txt
Normal file
175
libraries/shaders/CMakeLists.txt
Normal file
|
@ -0,0 +1,175 @@
|
|||
|
||||
set(TARGET_NAME gpu)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawColor VERTEX DrawTransformVertexPosition FRAGMENT DrawColor)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawTransformUnitQuadTextureOpaque VERTEX DrawTransformUnitQuad FRAGMENT DrawTextureOpaque)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawUnitQuatTextureOpaque VERTEX DrawUnitQuadTexcoord FRAGMENT DrawTextureOpaque)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawTextureOpaqueTexcoordRect VERTEX DrawTexcoordRectTransformUnitQuad FRAGMENT DrawTextureOpaque)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawNothing VERTEX DrawVertexPosition FRAGMENT DrawNada)
|
||||
|
||||
set(TARGET_NAME graphics)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu)
|
||||
AUTOSCRIBE_PROGRAM(NAME skybox)
|
||||
|
||||
set(TARGET_NAME procedural)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||
|
||||
set(TARGET_NAME render)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawCellBounds)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawItemBounds)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawItemStatus)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawLODReticle VERTEX gpu::vertex::DrawTransformUnitQuad)
|
||||
AUTOSCRIBE_PROGRAM(NAME blurGaussianV VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME blurGaussianH VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME blurGaussianDepthAwareV VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME blurGaussianDepthAwareH VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
|
||||
set(TARGET_NAME render-utils)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics render)
|
||||
AUTOSCRIBE_PROGRAM(NAME animdebugdraw)
|
||||
AUTOSCRIBE_PROGRAM(NAME bloomThreshold VERTEX gpu::vertex::DrawTransformUnitQuad FRAGMENT BloomThreshold)
|
||||
AUTOSCRIBE_PROGRAM(NAME bloomApply VERTEX gpu::vertex::DrawTransformUnitQuad FRAGMENT BloomApply)
|
||||
AUTOSCRIBE_PROGRAM(NAME directional_ambient_light VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME directional_ambient_light_shadow VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME directional_skybox_light VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME directional_skybox_light_shadow VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME local_lights_shading VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME local_lights_drawOutline VERTEX deferred_light)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_simple_textured VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_simple_textured_unlit VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_simple_textured_transparent VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME fxaa_blend VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME glowLine)
|
||||
AUTOSCRIBE_PROGRAM(NAME grid VERTEX standardTransformPNTC)
|
||||
AUTOSCRIBE_PROGRAM(NAME hmd_ui)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawWorkloadProxy)
|
||||
AUTOSCRIBE_PROGRAM(NAME drawWorkloadView)
|
||||
AUTOSCRIBE_PROGRAM(NAME haze VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord FRAGMENT Haze)
|
||||
AUTOSCRIBE_PROGRAM(NAME highlight_aabox VERTEX Highlight_aabox FRAGMENT nop)
|
||||
AUTOSCRIBE_PROGRAM(NAME highlight VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord FRAGMENT Highlight)
|
||||
AUTOSCRIBE_PROGRAM(NAME highlight_filled VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord FRAGMENT Highlight_filled)
|
||||
AUTOSCRIBE_PROGRAM(NAME lightClusters_drawGrid)
|
||||
AUTOSCRIBE_PROGRAM(NAME lightClusters_drawClusterFromDepth VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME lightClusters_drawClusterContent VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_opaque_web_browser VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_transparent_web_browser VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_textured VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_textured_unlit VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_transparent_textured VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_transparent_textured_unlit VERTEX simple)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_textured_fade VERTEX simple_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_textured_unlit_fade VERTEX simple_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_transparent_textured_fade VERTEX simple_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME simple_transparent_textured_unlit_fade VERTEX simple_fade)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME sdf_text3D)
|
||||
AUTOSCRIBE_PROGRAM(NAME sdf_text3D_transparent VERTEX sdf_text3D)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME ssao_makeOcclusion VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME ssao_makeHorizontalBlur VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME ssao_makeVerticalBlur VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME ssao_debugOcclusion VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME stencil_drawMask VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME standardDrawTexture VERTEX standardTransformPNTC)
|
||||
AUTOSCRIBE_PROGRAM(NAME standardDrawTextureNoBlend VERTEX standardTransformPNTC FRAGMENT gpu::fragment::DrawTextureOpaque)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME subsurfaceScattering_makeProfile VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME subsurfaceScattering_makeLUT VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME subsurfaceScattering_makeSpecularBeckmann VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME subsurfaceScattering_drawScattering VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME surfaceGeometry_makeLinearDepth VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME surfaceGeometry_downsampleDepthNormal VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME surfaceGeometry_makeCurvature VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME taa VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME taa_blend VERTEX gpu::vertex::DrawUnitQuadTexcoord)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME simple FRAGMENT forward_simple_textured)
|
||||
AUTOSCRIBE_PROGRAM(NAME simpleUnlit VERTEX simple FRAGMENT forward_simple_textured_unlit)
|
||||
AUTOSCRIBE_PROGRAM(NAME simpleTranslucent VERTEX simple FRAGMENT forward_simple_textured_transparent)
|
||||
AUTOSCRIBE_PROGRAM(NAME simpleTranslucentUnlit VERTEX simple FRAGMENT simple_transparent_textured_unlit)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_model VERTEX model)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_model_translucent VERTEX model)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_model_unlit VERTEX model)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_model_normal_map VERTEX model_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_model_normal_map_translucent VERTEX model_normal_map FRAGMENT forward_model_translucent)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_model VERTEX skin_model FRAGMENT forward_model)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_model_normal_map VERTEX skin_model_normal_map FRAGMENT forward_model_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_model_dq VERTEX skin_model_dq FRAGMENT forward_model)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_model_normal_map_dq VERTEX skin_model_normal_map_dq FRAGMENT forward_model_normal_map)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_translucent VERTEX skin_model FRAGMENT forward_model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_translucent_normal_map VERTEX skin_model_normal_map FRAGMENT forward_model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_translucent_dq VERTEX skin_model_dq FRAGMENT forward_model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME forward_skin_translucent_normal_map_dq VERTEX skin_model_normal_map_dq FRAGMENT forward_model_translucent)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME model)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_unlit VERTEX model)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent_unlit VERTEX model)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_lightmap)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_lightmap_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_shadow)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_shadow_fade)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model FRAGMENT model)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map FRAGMENT model_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_fade FRAGMENT model_normal_map_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_translucent VERTEX skin_model_fade FRAGMENT model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_translucent_fade VERTEX skin_model_fade FRAGMENT model_translucent_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_translucent VERTEX skin_model_normal_map_fade FRAGMENT model_translucent_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_translucent_fade VERTEX skin_model_normal_map_fade FRAGMENT model_translucent_normal_map_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_fade FRAGMENT model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_shadow FRAGMENT model_shadow)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_shadow_fade FRAGMENT model_shadow)
|
||||
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_dq FRAGMENT model)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_fade_dq FRAGMENT model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_dq FRAGMENT model_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_fade_dq FRAGMENT model_normal_map_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_translucent_dq VERTEX skin_model_fade_dq FRAGMENT model_translucent)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_translucent_fade_dq VERTEX skin_model_fade_dq FRAGMENT model_translucent_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_translucent_dq VERTEX skin_model_normal_map_fade_dq FRAGMENT model_translucent_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_normal_map_translucent_fade_dq VERTEX skin_model_normal_map_fade_dq FRAGMENT model_translucent_normal_map_fade)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_shadow_dq FRAGMENT model_shadow)
|
||||
AUTOSCRIBE_PROGRAM(NAME skin_model_shadow_fade_dq FRAGMENT model_shadow_fade)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_unlit_fade VERTEX model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent_unlit_fade VERTEX model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_normal_map_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent_normal_map_fade VERTEX model_translucent_normal_map)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_translucent_fade VERTEX model_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_lightmap_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME model_lightmap_normal_map_fade)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME zone_drawKeyLight VERTEX gpu::vertex::DrawTransformUnitQuad)
|
||||
AUTOSCRIBE_PROGRAM(NAME zone_drawSkybox VERTEX gpu::vertex::DrawTransformUnitQuad)
|
||||
AUTOSCRIBE_PROGRAM(NAME zone_drawAmbient VERTEX gpu::vertex::DrawTransformUnitQuad)
|
||||
|
||||
AUTOSCRIBE_PROGRAM(NAME toneMapping VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
AUTOSCRIBE_PROGRAM(NAME velocityBuffer_cameraMotion VERTEX gpu::vertex::DrawViewportQuadTransformTexcoord)
|
||||
|
||||
set(TARGET_NAME entities-renderer)
|
||||
AUTOSCRIBE_SHADER_LIB(gpu graphics procedural render render-utils)
|
||||
AUTOSCRIBE_PROGRAM(NAME polyvox)
|
||||
AUTOSCRIBE_PROGRAM(NAME polyvox_fade)
|
||||
AUTOSCRIBE_PROGRAM(NAME paintStroke)
|
||||
AUTOSCRIBE_PROGRAM(NAME textured_particle)
|
||||
|
||||
set(TARGET_NAME shaders)
|
||||
autoscribe_shader_finish()
|
||||
setup_hifi_library(Gui)
|
||||
link_hifi_libraries(shared)
|
||||
|
11
libraries/shaders/Shaders.cpp.in
Normal file
11
libraries/shaders/Shaders.cpp.in
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "Shaders.h"
|
||||
|
||||
namespace shader {
|
||||
|
||||
uint32_t all_programs[] = {
|
||||
@SHADER_PROGRAMS_ARRAY@
|
||||
INVALID_SHADER
|
||||
};
|
||||
|
||||
}
|
||||
|
14
libraries/shaders/Shaders.h.in
Normal file
14
libraries/shaders/Shaders.h.in
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace shader {
|
||||
|
||||
@SHADER_ENUMS@
|
||||
|
||||
extern uint32_t all_programs[];
|
||||
|
||||
static const uint32_t INVALID_SHADER = (uint32_t)-1;
|
||||
|
||||
std::string loadShaderSource(uint32_t shaderId);
|
||||
}
|
||||
|
6
libraries/shaders/shaders.qrc.in
Normal file
6
libraries/shaders/shaders.qrc.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource prefix="/shaders">
|
||||
@SHADER_QRC@
|
||||
</qresource>
|
||||
</RCC>
|
16
libraries/shaders/src/shaders/ShadersCommon.cpp
Normal file
16
libraries/shaders/src/shaders/ShadersCommon.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include <shared/FileUtils.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace shader {
|
||||
|
||||
std::string loadShaderSource(uint32_t shaderId) {
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
Q_INIT_RESOURCE(shaders);
|
||||
});
|
||||
auto shaderPath = std::string(":/shaders/") + std::to_string(shaderId);
|
||||
auto shaderData = FileUtils::readFile(shaderPath.c_str());
|
||||
return shaderData.toStdString();
|
||||
}
|
||||
|
||||
}
|
9
tests/shaders/CMakeLists.txt
Normal file
9
tests/shaders/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
# Declare dependencies
|
||||
macro (setup_testcase_dependencies)
|
||||
# link in the shared libraries
|
||||
link_hifi_libraries(shared test-utils gpu shaders gl ${PLATFORM_GL_BACKEND})
|
||||
package_libraries_for_deployment()
|
||||
endmacro ()
|
||||
|
||||
setup_hifi_testcase(Gui)
|
100
tests/shaders/src/ShaderTests.cpp
Normal file
100
tests/shaders/src/ShaderTests.cpp
Normal file
|
@ -0,0 +1,100 @@
|
|||
//
|
||||
// ShaderTests.cpp
|
||||
// tests/octree/src
|
||||
//
|
||||
// Created by Andrew Meadows on 2016.02.19
|
||||
// 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 "ShaderTests.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <QtCore/QJsonDocument>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include <test-utils/GLMTestUtils.h>
|
||||
#include <test-utils/QTestExtensions.h>
|
||||
#include <shared/FileUtils.h>
|
||||
|
||||
#include <shaders/Shaders.h>
|
||||
#include <gl/Config.h>
|
||||
#include <gl/GLHelpers.h>
|
||||
#include <gpu/gl/GLBackend.h>
|
||||
|
||||
QTEST_MAIN(ShaderTests)
|
||||
|
||||
void ShaderTests::initTestCase() {
|
||||
getDefaultOpenGLSurfaceFormat();
|
||||
_canvas.create();
|
||||
if (!_canvas.makeCurrent()) {
|
||||
qFatal("Unable to make test GL context current");
|
||||
}
|
||||
gl::initModuleGl();
|
||||
gpu::Context::init<gpu::gl::GLBackend>();
|
||||
_gpuContext = std::make_shared<gpu::Context>();
|
||||
}
|
||||
|
||||
void ShaderTests::cleanupTestCase() {
|
||||
}
|
||||
|
||||
|
||||
QVariantList slotSetToVariantList(const gpu::Shader::SlotSet& slotSet) {
|
||||
QVariantList result;
|
||||
for (const auto slot : slotSet) {
|
||||
QVariantMap inputMap;
|
||||
inputMap["name"] = slot._name.c_str();
|
||||
inputMap["location"] = slot._location;
|
||||
result.append(inputMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string reflect(const gpu::ShaderPointer& program) {
|
||||
QVariantMap result;
|
||||
if (!program->getInputs().empty()) {
|
||||
result["inputs"] = slotSetToVariantList(program->getInputs());
|
||||
}
|
||||
if (!program->getOutputs().empty()) {
|
||||
result["outputs"] = slotSetToVariantList(program->getOutputs());
|
||||
}
|
||||
if (!program->getResourceBuffers().empty()) {
|
||||
result["storage_buffers"] = slotSetToVariantList(program->getResourceBuffers());
|
||||
}
|
||||
if (!program->getSamplers().empty()) {
|
||||
result["samplers"] = slotSetToVariantList(program->getSamplers());
|
||||
}
|
||||
if (!program->getTextures().empty()) {
|
||||
result["textures"] = slotSetToVariantList(program->getTextures());
|
||||
}
|
||||
if (!program->getUniforms().empty()) {
|
||||
result["uniforms"] = slotSetToVariantList(program->getUniforms());
|
||||
}
|
||||
if (!program->getUniformBuffers().empty()) {
|
||||
result["uniform_buffers"] = slotSetToVariantList(program->getUniformBuffers());
|
||||
}
|
||||
|
||||
return QJsonDocument::fromVariant(result).toJson(QJsonDocument::Indented).toStdString();
|
||||
}
|
||||
|
||||
void ShaderTests::testShaderLoad() {
|
||||
size_t index = 0;
|
||||
uint32_t INVALID_SHADER_ID = (uint32_t)-1;
|
||||
while (INVALID_SHADER_ID != shader::all_programs[index]) {
|
||||
auto programId = shader::all_programs[index];
|
||||
uint32_t vertexId = programId >> 16;
|
||||
uint32_t fragmentId = programId & 0xFF;
|
||||
auto vertexSource = shader::loadShaderSource(vertexId);
|
||||
QVERIFY(!vertexSource.empty());
|
||||
auto fragmentSource = shader::loadShaderSource(fragmentId);
|
||||
QVERIFY(!fragmentSource.empty());
|
||||
auto program = gpu::Shader::createProgram(programId);
|
||||
QVERIFY(gpu::Shader::makeProgram(*program, {}));
|
||||
auto reflectionData = reflect(program);
|
||||
std::ofstream(std::string("d:/reflection/") + std::to_string(index) + std::string(".json")) << reflectionData;
|
||||
++index;
|
||||
}
|
||||
}
|
29
tests/shaders/src/ShaderTests.h
Normal file
29
tests/shaders/src/ShaderTests.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2018/06/21
|
||||
// Copyright 2013-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
|
||||
//
|
||||
|
||||
#ifndef hifi_ShaderTests_h
|
||||
#define hifi_ShaderTests_h
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
#include <gpu/Forward.h>
|
||||
#include <gl/OffscreenGLCanvas.h>
|
||||
|
||||
class ShaderTests : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void testShaderLoad();
|
||||
|
||||
private:
|
||||
OffscreenGLCanvas _canvas;
|
||||
gpu::ContextPointer _gpuContext;
|
||||
};
|
||||
|
||||
#endif // hifi_ViewFruxtumTests_h
|
Loading…
Reference in a new issue