mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-06-14 05:13:28 +00:00
Huge shader refactor
This commit is contained in:
parent
0a0a581f2d
commit
c307e354ca
4
.idea/vcs.xml
generated
4
.idea/vcs.xml
generated
@ -14,6 +14,10 @@
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/athena" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/glslang" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/NX/libdrm_nouveau" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/NX/mesa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/libdrm_nouveau" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/lib/graphicsdev/nx/mesa" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/boo/logvisor" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libSquish" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/hecl/extern/libjpeg-turbo" vcs="Git" />
|
||||
|
@ -9,14 +9,17 @@ if(APPLE AND NOT CMAKE_OSX_SYSROOT)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
project(urde)
|
||||
|
||||
option(URDE_CROSSCOMPILING "Don't build tools; attempt package import" Off)
|
||||
option(URDE_CROSSCOMPILING "Don't build tools; attempt package import" OFF)
|
||||
if (URDE_CROSSCOMPILING)
|
||||
set(CMAKE_CROSSCOMPILING On)
|
||||
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(HAVE_WORDS_BIGENDIAN_EXITCODE 0 CACHE INTEGER "Makes soxr happy" FORCE)
|
||||
endif()
|
||||
|
||||
project(urde)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
|
||||
@ -30,7 +33,11 @@ if(NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||
include(cotire)
|
||||
endif()
|
||||
|
||||
set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
|
||||
if (NX)
|
||||
set(URDE_VECTOR_ISA "neon")
|
||||
else()
|
||||
set(URDE_VECTOR_ISA "sse2" CACHE STRING "Vector ISA to build for (sse2, sse3, sse41, avx, avx2)")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(${URDE_VECTOR_ISA} STREQUAL "avx2")
|
||||
@ -99,12 +106,14 @@ else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
|
||||
message(STATUS "Building with SSE2 Vector ISA")
|
||||
elseif(${URDE_VECTOR_ISA} STREQUAL "neon")
|
||||
message(STATUS "Building with NEON Vector ISA")
|
||||
else()
|
||||
message(STATUS "Building with x87 Vector ISA")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\
|
||||
-Wno-multichar -fno-exceptions -Wno-narrowing -Wno-nullability-completeness -Werror=return-type")
|
||||
-Wno-multichar -fno-exceptions -fno-rtti -Wno-narrowing -Wno-nullability-completeness -Werror=return-type")
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto=thin")
|
||||
@ -141,13 +150,15 @@ if(USE_LD_GOLD AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_
|
||||
endif()
|
||||
|
||||
# Add discord-rpc here
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
|
||||
if (NOT CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix)
|
||||
if(NOT GEKKO AND NOT NX)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/include)
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc)
|
||||
if (NOT CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR ${CMAKE_BINARY_DIR}/fake-prefix)
|
||||
endif()
|
||||
add_subdirectory(discord-rpc/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
|
||||
endif()
|
||||
add_subdirectory(discord-rpc/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/discord-rpc/include)
|
||||
|
||||
add_subdirectory(nod)
|
||||
set(NOD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nod/include)
|
||||
@ -185,6 +196,10 @@ set(HECL_DATASPEC_PUSHES
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3);
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3PC);
|
||||
hecl::Database::DATA_SPEC_REGISTRY.push_back(&DataSpec::SpecEntMP3ORIG);")
|
||||
add_subdirectory(hecl/shaderc)
|
||||
include(hecl/ApplicationTools.cmake)
|
||||
add_subdirectory(specter/shaders)
|
||||
add_subdirectory(Shaders)
|
||||
add_subdirectory(hecl)
|
||||
|
||||
if(NOT TARGET bintoc)
|
||||
@ -233,12 +248,14 @@ add_subdirectory(visigen)
|
||||
|
||||
add_dependencies(hecl visigen)
|
||||
|
||||
find_package(Qt5Widgets)
|
||||
if (Qt5Widgets_FOUND)
|
||||
if (NOT WINDOWS_STORE AND NOT NX)
|
||||
find_package(Qt5Widgets)
|
||||
if (Qt5Widgets_FOUND)
|
||||
message(STATUS "Qt5 found, hecl-gui will be built")
|
||||
add_subdirectory(hecl-gui)
|
||||
else()
|
||||
else()
|
||||
message(STATUS "Qt5 not found, hecl-gui will not be built")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(GIT_EXECUTABLE CACHE)
|
||||
|
@ -156,7 +156,7 @@ void MaterialSet::ConstructMaterial(Stream& out,
|
||||
for (const Material::SectionFactory& factory : material.sections)
|
||||
{
|
||||
factory.section->constructNode(out, pakRouter, entry, prevSection, i++, texMapIdx, texMtxIdx, kColorIdx);
|
||||
Material::SectionPASS* pass = dynamic_cast<Material::SectionPASS*>(factory.section.get());
|
||||
Material::SectionPASS* pass = Material::SectionPASS::castTo(factory.section.get());
|
||||
if (!pass || (pass && Material::SectionPASS::Subtype(pass->subtype.toUint32()) != Material::SectionPASS::Subtype::RFLV))
|
||||
prevSection = factory.section.get();
|
||||
}
|
||||
|
@ -74,6 +74,8 @@ struct MaterialSet : BigDNA
|
||||
struct SectionPASS : ISection
|
||||
{
|
||||
SectionPASS() : ISection(ISection::Type::PASS) {}
|
||||
static SectionPASS* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::PASS ? static_cast<SectionPASS*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
Value<atUint32> size;
|
||||
@ -126,6 +128,8 @@ struct MaterialSet : BigDNA
|
||||
struct SectionCLR : ISection
|
||||
{
|
||||
SectionCLR() : ISection(ISection::Type::CLR) {}
|
||||
static SectionCLR* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::CLR ? static_cast<SectionCLR*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
enum class Subtype : atUint32
|
||||
@ -148,6 +152,8 @@ struct MaterialSet : BigDNA
|
||||
struct SectionINT : ISection
|
||||
{
|
||||
SectionINT() : ISection(ISection::Type::INT) {}
|
||||
static SectionINT* castTo(ISection* sec)
|
||||
{ return sec->m_type == Type::INT ? static_cast<SectionINT*>(sec) : nullptr; }
|
||||
AT_DECL_DNA
|
||||
AT_DECL_DNAV
|
||||
enum class Subtype : atUint32
|
||||
|
@ -101,7 +101,9 @@ target_link_libraries(urde
|
||||
UrdeIcons
|
||||
UrdeBadging
|
||||
RuntimeCommon NESEmulator
|
||||
specter specter-fonts freetype ${DATA_SPEC_LIBS}
|
||||
specter specter-fonts
|
||||
${HECL_APPLICATION_REPS_TARGETS_LIST}
|
||||
freetype ${DATA_SPEC_LIBS}
|
||||
hecl-full hecl-blender-addon
|
||||
athena-core nod logvisor athena-libyaml amuse boo
|
||||
${PNG_LIB} libjpeg-turbo squish xxhash zeus
|
||||
|
@ -98,7 +98,7 @@ void SplitSpace::joinViews(specter::SplitView* thisSplit, int thisSlot, specter:
|
||||
{
|
||||
if (thisSplit == otherSplit)
|
||||
{
|
||||
SplitSpace* thisSS = dynamic_cast<SplitSpace*>(m_slots[thisSlot].get());
|
||||
SplitSpace* thisSS = m_slots[thisSlot]->castToSplitSpace();
|
||||
if (thisSS)
|
||||
{
|
||||
int ax = thisSS->m_state.axis == specter::SplitView::Axis::Horizontal ? 1 : 0;
|
||||
@ -115,7 +115,7 @@ void SplitSpace::joinViews(specter::SplitView* thisSplit, int thisSlot, specter:
|
||||
{
|
||||
for (int i=0 ; i<2 ; ++i)
|
||||
{
|
||||
SplitSpace* otherSS = dynamic_cast<SplitSpace*>(m_slots[i].get());
|
||||
SplitSpace* otherSS = m_slots[i]->castToSplitSpace();
|
||||
if (otherSS && otherSS->m_splitView.get() == otherSplit)
|
||||
{
|
||||
int ax = m_state.axis == specter::SplitView::Axis::Horizontal ? 1 : 0;
|
||||
@ -248,23 +248,23 @@ void Space::SpaceMenuNode::SubNode::activated(const boo::SWindowCoord &coord)
|
||||
switch(m_data.m_cls)
|
||||
{
|
||||
case Class::InformationCenter:
|
||||
if (typeid(InformationCenter) != typeid(m_space))
|
||||
if (m_space.cls() == Class::InformationCenter)
|
||||
newSpace.reset(new InformationCenter(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::EffectEditor:
|
||||
if (typeid(EffectEditor) != typeid(m_space))
|
||||
if (m_space.cls() == Class::EffectEditor)
|
||||
newSpace.reset(new EffectEditor(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::ResourceBrowser:
|
||||
if (typeid(ResourceBrowser) != typeid(m_space))
|
||||
if (m_space.cls() == Class::ResourceBrowser)
|
||||
newSpace.reset(new ResourceBrowser(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::ModelViewer:
|
||||
if (typeid(ModelViewer) != typeid(m_space))
|
||||
if (m_space.cls() == Class::ModelViewer)
|
||||
newSpace.reset(new ModelViewer(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
case Class::GameMode:
|
||||
if (typeid(GameMode) != typeid(m_space))
|
||||
if (m_space.cls() == Class::GameMode)
|
||||
newSpace.reset(new GameMode(m_space.m_parent->m_vm, m_space.m_parent));
|
||||
break;
|
||||
default: break;
|
||||
|
@ -22,6 +22,7 @@ namespace urde
|
||||
{
|
||||
class ViewManager;
|
||||
class RootSpace;
|
||||
class SplitSpace;
|
||||
|
||||
class Space : public specter::ISpaceController
|
||||
{
|
||||
@ -160,6 +161,8 @@ public:
|
||||
{return std::unique_ptr<Space>();}
|
||||
|
||||
virtual specter::View* basisView() {return m_spaceView.get();}
|
||||
Class cls() const { return m_class; }
|
||||
SplitSpace* castToSplitSpace();
|
||||
};
|
||||
|
||||
class RootSpace : public Space
|
||||
@ -359,6 +362,8 @@ public:
|
||||
|
||||
specter::View* basisView() {return m_splitView.get();}
|
||||
};
|
||||
inline SplitSpace* Space::castToSplitSpace()
|
||||
{ return cls() == Class::SplitSpace ? static_cast<SplitSpace*>(this) : nullptr; }
|
||||
|
||||
class ViewerSpace : public Space
|
||||
{
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Audio/CStreamAudioManager.hpp"
|
||||
#include "Runtime/CStateManager.hpp"
|
||||
#include "Runtime/World/CPlayer.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
using YAMLNode = athena::io::YAMLNode;
|
||||
@ -292,6 +293,8 @@ void ViewManager::init(boo::IApplication* app)
|
||||
float pixelFactor = m_mainWindow->getVirtualPixelFactor();
|
||||
|
||||
m_mainBooFactory = m_mainWindow->getMainContextDataFactory();
|
||||
m_pipelineConv = hecl::NewPipelineConverter(m_mainBooFactory);
|
||||
hecl::conv = m_pipelineConv.get();
|
||||
m_mainPlatformName = m_mainBooFactory->platformName();
|
||||
m_mainWindow->setTitle(_S("URDE [") + hecl::SystemString(m_mainPlatformName) + _S("]"));
|
||||
m_mainCommandQueue = m_mainWindow->getCommandQueue();
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include "Runtime/Graphics/Shaders/CCameraBlurFilter.hpp"
|
||||
#include "Runtime/Audio/CStaticAudioPlayer.hpp"
|
||||
|
||||
namespace hecl { class PipelineConverterBase; }
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class SplashScreen;
|
||||
@ -43,6 +45,7 @@ class ViewManager final : public specter::IViewManager
|
||||
specter::Translator m_translator;
|
||||
boo::IGraphicsDataFactory* m_mainBooFactory = nullptr;
|
||||
boo::IGraphicsCommandQueue* m_mainCommandQueue = nullptr;
|
||||
std::unique_ptr<hecl::PipelineConverterBase> m_pipelineConv;
|
||||
boo::ObjToken<boo::ITextureR> m_renderTex;
|
||||
const boo::SystemChar* m_mainPlatformName;
|
||||
|
||||
|
@ -1,334 +1,32 @@
|
||||
#include "CNESShader.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
|
||||
boo::ObjToken<boo::IShaderPipeline> CNESShader::g_Pipeline;
|
||||
boo::ObjToken<boo::IVertexFormat> CNESShader::g_VtxFmt;
|
||||
|
||||
static const char* VS_GLSL =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 uvIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform TexuredQuadUniform\n"
|
||||
"{\n"
|
||||
" mat4 mtx;\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = uvIn.xy;\n"
|
||||
" gl_Position = mtx * vec4(posIn.xyz, 1.0);\n"
|
||||
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
#if _WIN32
|
||||
static const char* VS_HLSL =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer TexuredQuadUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mat;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D tex : register(t0);\n"
|
||||
"SamplerState samp : register(s4);\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_METAL
|
||||
static const char* VS_METAL =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
" float4 uvIn [[ attribute(1) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct TexuredQuadUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mat;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant TexuredQuadUniform& tqu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = tqu.color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
static const char* FS_METAL =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler clampSamp [[ sampler(4) ]],\n"
|
||||
" texture2d<float> tex [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.sample(clampSamp, vtf.uv);\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_GL
|
||||
void CNESShader::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
void CNESShader::Initialize()
|
||||
{
|
||||
const char* texNames[] = {"tex"};
|
||||
const char* uniNames[] = {"TexuredQuadUniform"};
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_GLSL, FS_GLSL, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
g_Pipeline = hecl::conv->convert(Shader_CNESShader{});
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::GLDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline,
|
||||
ctx.newVertexFormat(2, VtxVmt), vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _WIN32
|
||||
void CNESShader::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_HLSL, FS_HLSL, nullptr, nullptr, nullptr,
|
||||
g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::D3DDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_METAL
|
||||
void CNESShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_METAL, FS_METAL, nullptr, nullptr,
|
||||
g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::MetalDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
void CNESShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
g_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
g_Pipeline = ctx.newShaderPipeline(VS_GLSL, FS_GLSL, g_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::VulkanDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, g_VtxFmt,
|
||||
vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
boo::ObjToken<boo::IShaderDataBinding> CNESShader::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
return BuildShaderDataBinding(static_cast<boo::GLDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
return BuildShaderDataBinding(static_cast<boo::D3DDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
return BuildShaderDataBinding(static_cast<boo::MetalDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
return BuildShaderDataBinding(static_cast<boo::VulkanDataFactory::Context&>(ctx), vbo, uniBuf, tex);
|
||||
#endif
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void CNESShader::Initialize()
|
||||
{
|
||||
if (!CGraphics::g_BooFactory)
|
||||
return;
|
||||
|
||||
CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
Initialize(static_cast<boo::GLDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
Initialize(static_cast<boo::D3DDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
Initialize(static_cast<boo::MetalDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
Initialize(static_cast<boo::VulkanDataFactory::Context&>(ctx));
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {tex.get()};
|
||||
return ctx.newShaderDataBinding(g_Pipeline, vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
|
||||
void CNESShader::Shutdown()
|
||||
{
|
||||
g_Pipeline.reset();
|
||||
g_VtxFmt.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
#ifndef URDE_CNESSHADER_HPP
|
||||
#define URDE_CNESSHADER_HPP
|
||||
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
|
||||
namespace urde::MP1
|
||||
{
|
||||
@ -12,34 +9,6 @@ namespace urde::MP1
|
||||
class CNESShader
|
||||
{
|
||||
public:
|
||||
#if BOO_HAS_GL
|
||||
static void Initialize(boo::GLDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::GLDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if _WIN32
|
||||
static void Initialize(boo::D3DDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::D3DDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
static void Initialize(boo::MetalDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::MetalDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
static void Initialize(boo::VulkanDataFactory::Context& ctx);
|
||||
static boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::VulkanDataFactory::Context& ctx,
|
||||
boo::ObjToken<boo::IGraphicsBufferS> vbo,
|
||||
boo::ObjToken<boo::IGraphicsBufferD> uniBuf,
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
#endif
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
|
||||
@ -49,7 +18,6 @@ public:
|
||||
boo::ObjToken<boo::ITextureD> tex);
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> g_Pipeline;
|
||||
static boo::ObjToken<boo::IVertexFormat> g_VtxFmt;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
template <class T>
|
||||
const T* GetParm() const
|
||||
{
|
||||
return dynamic_cast<T*>(x8_parm.get());
|
||||
return static_cast<T*>(x8_parm.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,85 +1,3 @@
|
||||
if(WIN32)
|
||||
set(PLAT_SRCS
|
||||
Shaders/CLineRendererShadersHLSL.cpp
|
||||
Shaders/CTexturedQuadFilterHLSL.cpp
|
||||
Shaders/CColoredQuadFilterHLSL.cpp
|
||||
Shaders/CModelShadersHLSL.cpp
|
||||
Shaders/CThermalColdFilterHLSL.cpp
|
||||
Shaders/CThermalHotFilterHLSL.cpp
|
||||
Shaders/CSpaceWarpFilterHLSL.cpp
|
||||
Shaders/CCameraBlurFilterHLSL.cpp
|
||||
Shaders/CXRayBlurFilterHLSL.cpp
|
||||
Shaders/CTextSupportShaderHLSL.cpp
|
||||
Shaders/CFogVolumePlaneShaderHLSL.cpp
|
||||
Shaders/CFogVolumeFilterHLSL.cpp
|
||||
Shaders/CEnergyBarShaderHLSL.cpp
|
||||
Shaders/CRadarPaintShaderHLSL.cpp
|
||||
Shaders/CMapSurfaceShaderHLSL.cpp
|
||||
Shaders/CPhazonSuitFilterHLSL.cpp
|
||||
Shaders/CScanLinesFilterHLSL.cpp
|
||||
Shaders/CRandomStaticFilterHLSL.cpp
|
||||
Shaders/CElementGenShadersHLSL.cpp
|
||||
Shaders/CDecalShadersHLSL.cpp
|
||||
Shaders/CParticleSwooshShadersHLSL.cpp
|
||||
Shaders/CFluidPlaneShaderHLSL.cpp
|
||||
Shaders/CAABoxShaderHLSL.cpp
|
||||
Shaders/CWorldShadowShaderHLSL.cpp)
|
||||
elseif(BOO_HAS_METAL)
|
||||
set(PLAT_SRCS
|
||||
Shaders/CLineRendererShadersMetal.cpp
|
||||
Shaders/CTexturedQuadFilterMetal.cpp
|
||||
Shaders/CColoredQuadFilterMetal.cpp
|
||||
Shaders/CModelShadersMetal.cpp
|
||||
Shaders/CThermalColdFilterMetal.cpp
|
||||
Shaders/CThermalHotFilterMetal.cpp
|
||||
Shaders/CSpaceWarpFilterMetal.cpp
|
||||
Shaders/CCameraBlurFilterMetal.cpp
|
||||
Shaders/CXRayBlurFilterMetal.cpp
|
||||
Shaders/CTextSupportShaderMetal.cpp
|
||||
Shaders/CFogVolumePlaneShaderMetal.cpp
|
||||
Shaders/CFogVolumeFilterMetal.cpp
|
||||
Shaders/CEnergyBarShaderMetal.cpp
|
||||
Shaders/CRadarPaintShaderMetal.cpp
|
||||
Shaders/CMapSurfaceShaderMetal.cpp
|
||||
Shaders/CPhazonSuitFilterMetal.cpp
|
||||
Shaders/CScanLinesFilterMetal.cpp
|
||||
Shaders/CRandomStaticFilterMetal.cpp
|
||||
Shaders/CElementGenShadersMetal.cpp
|
||||
Shaders/CDecalShadersMetal.cpp
|
||||
Shaders/CParticleSwooshShadersMetal.cpp
|
||||
Shaders/CFluidPlaneShaderMetal.cpp
|
||||
Shaders/CAABoxShaderMetal.cpp
|
||||
Shaders/CWorldShadowShaderMetal.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT WINDOWS_STORE)
|
||||
list(APPEND PLAT_SRCS
|
||||
Shaders/CLineRendererShadersGLSL.cpp
|
||||
Shaders/CTexturedQuadFilterGLSL.cpp
|
||||
Shaders/CColoredQuadFilterGLSL.cpp
|
||||
Shaders/CModelShadersGLSL.cpp
|
||||
Shaders/CThermalColdFilterGLSL.cpp
|
||||
Shaders/CThermalHotFilterGLSL.cpp
|
||||
Shaders/CSpaceWarpFilterGLSL.cpp
|
||||
Shaders/CCameraBlurFilterGLSL.cpp
|
||||
Shaders/CXRayBlurFilterGLSL.cpp
|
||||
Shaders/CTextSupportShaderGLSL.cpp
|
||||
Shaders/CFogVolumePlaneShaderGLSL.cpp
|
||||
Shaders/CFogVolumeFilterGLSL.cpp
|
||||
Shaders/CEnergyBarShaderGLSL.cpp
|
||||
Shaders/CRadarPaintShaderGLSL.cpp
|
||||
Shaders/CMapSurfaceShaderGLSL.cpp
|
||||
Shaders/CPhazonSuitFilterGLSL.cpp
|
||||
Shaders/CScanLinesFilterGLSL.cpp
|
||||
Shaders/CRandomStaticFilterGLSL.cpp
|
||||
Shaders/CElementGenShadersGLSL.cpp
|
||||
Shaders/CDecalShadersGLSL.cpp
|
||||
Shaders/CParticleSwooshShadersGLSL.cpp
|
||||
Shaders/CFluidPlaneShaderGLSL.cpp
|
||||
Shaders/CAABoxShaderGLSL.cpp
|
||||
Shaders/CWorldShadowShaderGLSL.cpp)
|
||||
endif()
|
||||
|
||||
set(GRAPHICS_SOURCES
|
||||
IRenderer.hpp
|
||||
IWeaponRenderer.hpp IWeaponRenderer.cpp
|
||||
@ -101,12 +19,11 @@ set(GRAPHICS_SOURCES
|
||||
CGraphics.hpp CGraphics.cpp
|
||||
CSimpleShadow.hpp CSimpleShadow.cpp
|
||||
CRainSplashGenerator.hpp CRainSplashGenerator.cpp
|
||||
Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp
|
||||
Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp
|
||||
Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp
|
||||
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp
|
||||
Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp
|
||||
Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp
|
||||
Shaders/CModelShadersGLSL.cpp Shaders/CModelShadersHLSL.cpp Shaders/CModelShadersMetal.cpp
|
||||
Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp
|
||||
Shaders/CThermalHotFilter.hpp Shaders/CThermalHotFilter.cpp
|
||||
Shaders/CSpaceWarpFilter.hpp Shaders/CSpaceWarpFilter.cpp
|
||||
@ -126,7 +43,6 @@ set(GRAPHICS_SOURCES
|
||||
Shaders/CParticleSwooshShaders.hpp Shaders/CParticleSwooshShaders.cpp
|
||||
Shaders/CFluidPlaneShader.hpp Shaders/CFluidPlaneShader.cpp
|
||||
Shaders/CAABoxShader.hpp Shaders/CAABoxShader.cpp
|
||||
Shaders/CWorldShadowShader.hpp Shaders/CWorldShadowShader.cpp
|
||||
${PLAT_SRCS})
|
||||
Shaders/CWorldShadowShader.hpp Shaders/CWorldShadowShader.cpp)
|
||||
|
||||
runtime_add_list(Graphics GRAPHICS_SOURCES)
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "RetroTypes.hpp"
|
||||
#include "zeus/CTransform.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "hecl/Runtime.hpp"
|
||||
#include "hecl/HMDLMeta.hpp"
|
||||
#include "Shaders/CModelShaders.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -24,7 +24,7 @@ class CMetroidModelInstance
|
||||
std::vector<CBooSurface> m_surfaces;
|
||||
std::unique_ptr<CBooModel> m_instance;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>> m_shaders;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
public:
|
||||
CMetroidModelInstance() = default;
|
||||
CMetroidModelInstance(CMetroidModelInstance&&) = default;
|
||||
|
@ -103,18 +103,20 @@ struct GeometryUniformLayout
|
||||
|
||||
struct SShader
|
||||
{
|
||||
|
||||
|
||||
std::vector<TCachedToken<CTexture>> x0_textures;
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>> m_shaders;
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines> m_shaders;
|
||||
MaterialSet m_matSet;
|
||||
std::experimental::optional<GeometryUniformLayout> m_geomLayout;
|
||||
int m_matSetIdx;
|
||||
SShader(int idx) : m_matSetIdx(idx) {}
|
||||
void InitializeLayout(const CModel* model) { m_geomLayout.emplace(model, &m_matSet); }
|
||||
void UnlockTextures();
|
||||
std::shared_ptr<hecl::Runtime::ShaderPipelines>
|
||||
CModelShaders::ShaderPipelines
|
||||
BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta,
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& shaders);
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders);
|
||||
void BuildShaders(const hecl::HMDLMeta& meta) { BuildShaders(meta, m_shaders); }
|
||||
};
|
||||
|
||||
@ -144,7 +146,7 @@ private:
|
||||
const MaterialSet* x4_matSet;
|
||||
const GeometryUniformLayout* m_geomLayout;
|
||||
int m_matSetIdx = -1;
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>* m_pipelines;
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>* m_pipelines;
|
||||
std::vector<TCachedToken<CTexture>> x1c_textures;
|
||||
zeus::CAABox x20_aabb;
|
||||
CBooSurface* x38_firstUnsortedSurface = nullptr;
|
||||
@ -170,15 +172,12 @@ private:
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_geomUniformBuffer;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniformBuffer;
|
||||
std::vector<std::vector<boo::ObjToken<boo::IShaderDataBinding>>> m_shaderDataBindings;
|
||||
boo::ObjToken<boo::IVertexFormat> m_dynamicVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_dynamicVbo;
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> GetBooVBO(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
boo::ObjToken<boo::IVertexFormat> GetBooVtxFmt(const CBooModel& model, boo::IGraphicsDataFactory::Context& ctx);
|
||||
};
|
||||
std::vector<ModelInstance> m_instances;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticIbo;
|
||||
|
||||
@ -206,9 +205,8 @@ private:
|
||||
public:
|
||||
~CBooModel();
|
||||
CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8]);
|
||||
|
||||
static void MakeTexturesFromMats(const MaterialSet& matSet,
|
||||
std::vector<TCachedToken<CTexture>>& toksOut,
|
||||
@ -221,7 +219,7 @@ public:
|
||||
void DisableAllLights();
|
||||
void RemapMaterialData(SShader& shader);
|
||||
void RemapMaterialData(SShader& shader,
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines);
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines);
|
||||
bool TryLockTextures() const;
|
||||
void UnlockTextures() const;
|
||||
void SyncLoadTextures() const;
|
||||
@ -292,7 +290,6 @@ class CModel
|
||||
int x38_lastFrame;
|
||||
|
||||
/* urde addition: boo! */
|
||||
boo::ObjToken<boo::IVertexFormat> m_staticVtxFmt;
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_staticVbo;
|
||||
hecl::HMDLMeta m_hmdlMeta;
|
||||
std::unique_ptr<uint8_t[]> m_dynamicVertexData;
|
||||
|
@ -155,13 +155,12 @@ CBooModel::~CBooModel()
|
||||
}
|
||||
|
||||
CBooModel::CBooModel(TToken<CModel>& token, CModel* parent, std::vector<CBooSurface>* surfaces, SShader& shader,
|
||||
const boo::ObjToken<boo::IVertexFormat>& vtxFmt, const boo::ObjToken<boo::IGraphicsBufferS>& vbo,
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& ibo, const zeus::CAABox& aabb, u8 renderMask,
|
||||
int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
const boo::ObjToken<boo::IGraphicsBufferS>& vbo, const boo::ObjToken<boo::IGraphicsBufferS>& ibo,
|
||||
const zeus::CAABox& aabb, u8 renderMask, int numInsts, const boo::ObjToken<boo::ITexture> txtrOverrides[8])
|
||||
: m_modelTok(token), m_model(parent), x0_surfaces(surfaces), x4_matSet(&shader.m_matSet),
|
||||
m_geomLayout(&*shader.m_geomLayout), m_matSetIdx(shader.m_matSetIdx), m_pipelines(&shader.m_shaders),
|
||||
x1c_textures(shader.x0_textures), x20_aabb(aabb), x40_24_texturesLoaded(false), x40_25_modelVisible(0),
|
||||
x41_mask(renderMask), m_staticVtxFmt(vtxFmt), m_staticVbo(vbo), m_staticIbo(ibo)
|
||||
x41_mask(renderMask), m_staticVbo(vbo), m_staticIbo(ibo)
|
||||
{
|
||||
if (txtrOverrides)
|
||||
for (int i=0 ; i<8 ; ++i)
|
||||
@ -217,21 +216,6 @@ CBooModel::ModelInstance::GetBooVBO(const CBooModel& model,
|
||||
return m_dynamicVbo.get();
|
||||
}
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat>
|
||||
CBooModel::ModelInstance::GetBooVtxFmt(const CBooModel& model,
|
||||
boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
if (model.m_staticVtxFmt)
|
||||
return model.m_staticVtxFmt;
|
||||
if (!m_dynamicVtxFmt && model.m_model)
|
||||
{
|
||||
const CModel& parent = *model.m_model;
|
||||
m_dynamicVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, parent.m_hmdlMeta,
|
||||
GetBooVBO(model, ctx), parent.m_ibo.get());
|
||||
}
|
||||
return m_dynamicVtxFmt;
|
||||
}
|
||||
|
||||
GeometryUniformLayout::GeometryUniformLayout(const CModel* model, const MaterialSet* matSet)
|
||||
{
|
||||
if (model)
|
||||
@ -418,14 +402,14 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
|
||||
}
|
||||
thisSizes[3] = 256;
|
||||
|
||||
const std::shared_ptr<hecl::Runtime::ShaderPipelines>& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
const CModelShaders::ShaderPipelines& pipelines = m_pipelines->at(surf.m_data.matIdx);
|
||||
|
||||
newInst.m_shaderDataBindings.emplace_back();
|
||||
std::vector<boo::ObjToken<boo::IShaderDataBinding>>& extendeds = newInst.m_shaderDataBindings.back();
|
||||
extendeds.reserve(pipelines->m_pipelines.size());
|
||||
extendeds.reserve(pipelines->size());
|
||||
|
||||
int idx = 0;
|
||||
for (const boo::ObjToken<boo::IShaderPipeline>& pipeline : pipelines->m_pipelines)
|
||||
for (const auto& pipeline : *pipelines)
|
||||
{
|
||||
boo::ObjToken<boo::ITexture>* ltexs;
|
||||
if (idx == EExtendedShader::Thermal)
|
||||
@ -454,7 +438,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
|
||||
ltexs = texs;
|
||||
}
|
||||
extendeds.push_back(
|
||||
ctx.newShaderDataBinding(pipeline, newInst.GetBooVtxFmt(*this, ctx),
|
||||
ctx.newShaderDataBinding(pipeline,
|
||||
newInst.GetBooVBO(*this, ctx), nullptr, m_staticIbo.get(), 4, bufs,
|
||||
stages, thisOffs, thisSizes, 8, ltexs, nullptr, nullptr));
|
||||
++idx;
|
||||
@ -513,7 +497,7 @@ void CBooModel::RemapMaterialData(SShader& shader)
|
||||
}
|
||||
|
||||
void CBooModel::RemapMaterialData(SShader& shader,
|
||||
const std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& pipelines)
|
||||
const std::unordered_map<int, CModelShaders::ShaderPipelines>& pipelines)
|
||||
{
|
||||
if (!shader.m_geomLayout)
|
||||
return;
|
||||
@ -1204,14 +1188,13 @@ std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
|
||||
if (shaderIdx >= x18_matSets.size())
|
||||
shaderIdx = 0;
|
||||
auto ret = std::make_unique<CBooModel>(m_selfToken, this, &x8_surfaces, x18_matSets[shaderIdx],
|
||||
m_staticVtxFmt, m_staticVbo, m_ibo,
|
||||
m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
|
||||
m_staticVbo, m_ibo, m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
|
||||
if (lockParent)
|
||||
ret->LockParent();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::shared_ptr<hecl::Runtime::ShaderPipelines>
|
||||
CModelShaders::ShaderPipelines
|
||||
SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& mat)
|
||||
{
|
||||
hecl::Backend::ReflectionType reflectionType;
|
||||
@ -1221,16 +1204,15 @@ SShader::BuildShader(const hecl::HMDLMeta& meta, const MaterialSet::Material& ma
|
||||
reflectionType = hecl::Backend::ReflectionType::Simple;
|
||||
else
|
||||
reflectionType = hecl::Backend::ReflectionType::None;
|
||||
hecl::Runtime::ShaderTag tag(mat.heclIr,
|
||||
hecl::Backend::ShaderTag tag(mat.heclIr,
|
||||
meta.colorCount, meta.uvCount, meta.weightCount,
|
||||
meta.weightCount * 4, boo::Primitive(meta.topology),
|
||||
reflectionType, true, true, true);
|
||||
return CModelShaders::g_ModelShaders->buildExtendedShader
|
||||
(tag, mat.heclIr, "CMDL", *CGraphics::g_BooFactory);
|
||||
return CModelShaders::BuildExtendedShader(tag, mat.heclIr);
|
||||
}
|
||||
|
||||
void SShader::BuildShaders(const hecl::HMDLMeta& meta,
|
||||
std::unordered_map<int, std::shared_ptr<hecl::Runtime::ShaderPipelines>>& shaders)
|
||||
std::unordered_map<int, CModelShaders::ShaderPipelines>& shaders)
|
||||
{
|
||||
shaders.reserve(m_matSet.materials.size());
|
||||
int idx = 0;
|
||||
@ -1294,7 +1276,6 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
|
||||
if (m_hmdlMeta.vertCount)
|
||||
m_staticVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, vboData,
|
||||
m_hmdlMeta.vertStride, m_hmdlMeta.vertCount);
|
||||
m_staticVtxFmt = hecl::Runtime::HMDLData::NewVertexFormat(ctx, m_hmdlMeta, m_staticVbo.get(), m_ibo.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,158 +5,12 @@
|
||||
#include "Audio/g721.h"
|
||||
#include "amuse/DSPCodec.hpp"
|
||||
#include "CDvdRequest.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include <turbojpeg.h>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_GLSL_YUV =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec3 posIn;\n"
|
||||
"layout(location=1) in vec2 uvIn;\n"
|
||||
SPECTER_GLSL_VIEW_VERT_BLOCK
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.uv = uvIn;\n"
|
||||
" vtf.color = mulColor;\n"
|
||||
" gl_Position = mv * vec4(posIn, 1.0);\n"
|
||||
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_YUV =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"TBINDING0 uniform sampler2D texY;\n"
|
||||
"TBINDING1 uniform sampler2D texU;\n"
|
||||
"TBINDING2 uniform sampler2D texV;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec3 yuv;\n"
|
||||
" yuv.r = texture(texY, vtf.uv).r;\n"
|
||||
" yuv.g = texture(texU, vtf.uv).r;\n"
|
||||
" yuv.b = texture(texV, vtf.uv).r;\n"
|
||||
" yuv.r = 1.1643*(yuv.r-0.0625);\n"
|
||||
" yuv.g = yuv.g-0.5;\n"
|
||||
" yuv.b = yuv.b-0.5;\n"
|
||||
" colorOut = vec4(yuv.r+1.5958*yuv.b,\n"
|
||||
" yuv.r-0.39173*yuv.g-0.81290*yuv.b,\n"
|
||||
" yuv.r+2.017*yuv.g, 1.0) * vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
#if _WIN32
|
||||
static const char* VS_HLSL_YUV =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float3 posIn : POSITION;\n"
|
||||
" float2 uvIn : UV;\n"
|
||||
"};\n"
|
||||
SPECTER_HLSL_VIEW_VERT_BLOCK
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uv = v.uvIn;\n"
|
||||
" vtf.color = mulColor;\n"
|
||||
" vtf.position = mul(mv, float4(v.posIn, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_YUV =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"Texture2D texs[3] : register(t0);\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float3 yuv;\n"
|
||||
" yuv.r = texs[0].Sample(samp, vtf.uv).r;\n"
|
||||
" yuv.g = texs[1].Sample(samp, vtf.uv).r;\n"
|
||||
" yuv.b = texs[2].Sample(samp, vtf.uv).r;\n"
|
||||
" yuv.r = 1.1643*(yuv.r-0.0625);\n"
|
||||
" yuv.g = yuv.g-0.5;\n"
|
||||
" yuv.b = yuv.b-0.5;\n"
|
||||
" return float4(yuv.r+1.5958*yuv.b,\n"
|
||||
" yuv.r-0.39173*yuv.g-0.81290*yuv.b,\n"
|
||||
" yuv.r+2.017*yuv.g, 1.0) * vtf.color;\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
#if BOO_HAS_METAL
|
||||
static const char* VS_METAL_YUV =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float3 posIn [[ attribute(0) ]];\n"
|
||||
" float2 uvIn [[ attribute(1) ]];\n"
|
||||
"};\n"
|
||||
SPECTER_METAL_VIEW_VERT_BLOCK
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant SpecterViewBlock& view [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uv = v.uvIn;\n"
|
||||
" vtf.color = view.mulColor;\n"
|
||||
" vtf.position = view.mv * float4(v.posIn, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_YUV =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]],\n"
|
||||
" texture2d<float> tex1 [[ texture(1) ]],\n"
|
||||
" texture2d<float> tex2 [[ texture(2) ]])\n"
|
||||
"{\n"
|
||||
" float3 yuv;\n"
|
||||
" yuv.r = tex0.sample(samp, vtf.uv).r;\n"
|
||||
" yuv.g = tex1.sample(samp, vtf.uv).r;\n"
|
||||
" yuv.b = tex2.sample(samp, vtf.uv).r;\n"
|
||||
" yuv.r = 1.1643*(yuv.r-0.0625);\n"
|
||||
" yuv.g = yuv.g-0.5;\n"
|
||||
" yuv.b = yuv.b-0.5;\n"
|
||||
" return float4(yuv.r+1.5958*yuv.b,\n"
|
||||
" yuv.r-0.39173*yuv.g-0.81290*yuv.b,\n"
|
||||
" yuv.r+2.017*yuv.g, 1.0) * vtf.color;\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
/* used in the original to look up fixed-point dividends on a
|
||||
* MIDI-style volume scale (0-127) -> (n/0x8000) */
|
||||
static const u16 StaticVolumeLookup[] =
|
||||
@ -180,7 +34,6 @@ static const u16 StaticVolumeLookup[] =
|
||||
};
|
||||
|
||||
/* shared boo resources */
|
||||
static boo::ObjToken<boo::IVertexFormat> YUVVTXFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> YUVShaderPipeline;
|
||||
static tjhandle TjHandle = nullptr;
|
||||
|
||||
@ -202,63 +55,12 @@ static const char* TexNames[] = {"texY", "texU", "texV"};
|
||||
|
||||
void CMoviePlayer::Initialize()
|
||||
{
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
if (!ctx.bindingNeedsVertexFormat())
|
||||
{
|
||||
boo::VertexElementDescriptor texvdescs[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
YUVVTXFmt = ctx.newVertexFormat(2, texvdescs);
|
||||
}
|
||||
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
YUVShaderPipeline = static_cast<boo::GLDataFactory::Context&>(ctx).newShaderPipeline
|
||||
(VS_GLSL_YUV, FS_GLSL_YUV, 3, TexNames, 1, BlockNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
YUVShaderPipeline = static_cast<boo::D3DDataFactory::Context&>(ctx).newShaderPipeline
|
||||
(VS_HLSL_YUV, FS_HLSL_YUV, nullptr, nullptr, nullptr, YUVVTXFmt,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
YUVShaderPipeline = static_cast<boo::MetalDataFactory::Context&>(ctx).newShaderPipeline
|
||||
(VS_METAL_YUV, FS_METAL_YUV, nullptr, nullptr, YUVVTXFmt,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
YUVShaderPipeline = static_cast<boo::VulkanDataFactory::Context&>(ctx).newShaderPipeline
|
||||
(VS_GLSL_YUV, FS_GLSL_YUV, YUVVTXFmt,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
|
||||
YUVShaderPipeline = hecl::conv->convert(Shader_CMoviePlayerShader{});
|
||||
TjHandle = tjInitDecompress();
|
||||
}
|
||||
|
||||
void CMoviePlayer::Shutdown()
|
||||
{
|
||||
YUVVTXFmt.reset();
|
||||
YUVShaderPipeline.reset();
|
||||
tjDestroy(TjHandle);
|
||||
}
|
||||
@ -434,17 +236,6 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
||||
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
|
||||
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = YUVVTXFmt;
|
||||
if (ctx.bindingNeedsVertexFormat())
|
||||
{
|
||||
boo::VertexElementDescriptor texvdescs[] =
|
||||
{
|
||||
{m_vertBuf.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{m_vertBuf.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(2, texvdescs);
|
||||
}
|
||||
|
||||
/* Allocate textures here (rather than at decode time) */
|
||||
x80_textures.reserve(3);
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
@ -467,7 +258,7 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
||||
for (int j=0 ; j<2 ; ++j)
|
||||
{
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[j].get(), set.U.get(), set.V.get()};
|
||||
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
|
||||
set.binding[j] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(),
|
||||
nullptr, nullptr, 1, bufs, nullptr,
|
||||
3, texs, nullptr, nullptr);
|
||||
}
|
||||
@ -484,7 +275,7 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_blockBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {set.Y[0].get(), set.U.get(), set.V.get()};
|
||||
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, vtxFmt, m_vertBuf.get(),
|
||||
set.binding[0] = ctx.newShaderDataBinding(YUVShaderPipeline, m_vertBuf.get(),
|
||||
nullptr, nullptr, 1, bufs, nullptr,
|
||||
3, texs, nullptr, nullptr);
|
||||
}
|
||||
|
@ -1,16 +1,36 @@
|
||||
#include "CAABoxShader.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
CAABoxShader::CAABoxShader(bool zOnly)
|
||||
: m_zOnly(zOnly)
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
void CAABoxShader::Initialize()
|
||||
{
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
s_Pipeline = hecl::conv->convert(Shader_CAABoxShader{});
|
||||
s_zOnlyPipeline = hecl::conv->convert(Shader_CAABoxShaderZOnly{});
|
||||
}
|
||||
|
||||
void CAABoxShader::Shutdown()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
CAABoxShader::CAABoxShader(bool zOnly)
|
||||
{
|
||||
CGraphics::CommitResources([this, zOnly](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
m_dataBind = TShader<CAABoxShader>::BuildShaderDataBinding(ctx, *this);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(zOnly ? s_zOnlyPipeline : s_Pipeline,
|
||||
m_vbo.get(), nullptr, nullptr, 1, bufs, stages,
|
||||
nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -73,6 +93,4 @@ void CAABoxShader::draw(const zeus::CColor& color)
|
||||
CGraphics::DrawArray(0, 34);
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __URDE_CAABOXSHADER_HPP__
|
||||
#define __URDE_CAABOXSHADER_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
@ -11,11 +11,6 @@ namespace urde
|
||||
|
||||
class CAABoxShader
|
||||
{
|
||||
friend struct CAABoxShaderGLDataBindingFactory;
|
||||
friend struct CAABoxShaderVulkanDataBindingFactory;
|
||||
friend struct CAABoxShaderMetalDataBindingFactory;
|
||||
friend struct CAABoxShaderD3DDataBindingFactory;
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
zeus::CMatrix4f m_xf;
|
||||
@ -25,15 +20,13 @@ class CAABoxShader
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind;
|
||||
Uniform m_uniform;
|
||||
bool m_zOnly;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CAABoxShader(bool zOnly);
|
||||
void setAABB(const zeus::CAABox& aabb);
|
||||
void draw(const zeus::CColor& color);
|
||||
|
||||
using _CLS = CAABoxShader;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,132 +0,0 @@
|
||||
#include "CAABoxShader.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform CAABoxUniform\n"
|
||||
"{\n"
|
||||
" mat4 xf;\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = color;\n"
|
||||
" gl_Position = xf * vec4(posIn.xyz, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
struct CAABoxShaderGLDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline,
|
||||
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CAABoxShaderVulkanDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* uniNames[] = {"CAABoxUniform"};
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CAABoxShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CAABoxShaderVulkanDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
#include "CAABoxShader.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer CAABoxUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.pos = mul(xf, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
struct CAABoxShaderD3DDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
boo::D3DDataFactory::Context& cctx = static_cast<boo::D3DDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CAABoxShaderD3DDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
#include "CAABoxShader.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct CAABoxUniform\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant CAABoxUniform& bu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = bu.color;\n"
|
||||
" vtf.pos = bu.xf * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CAABoxShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_zOnlyPipeline;
|
||||
|
||||
struct CAABoxShaderMetalDataBindingFactory : TShader<CAABoxShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CAABoxShader& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(filter.m_zOnly ? s_zOnlyPipeline : s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CAABoxShader>::IDataBindingFactory* CAABoxShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
s_zOnlyPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, true, false, false, boo::CullMode::None);
|
||||
return new CAABoxShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CAABoxShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
s_zOnlyPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +1,33 @@
|
||||
#include "CCameraBlurFilter.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CCameraBlurFilter::Initialize()
|
||||
{
|
||||
s_Pipeline = hecl::conv->convert(Shader_CCameraBlurFilter{});
|
||||
}
|
||||
|
||||
void CCameraBlurFilter::Shutdown()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
CCameraBlurFilter::CCameraBlurFilter()
|
||||
{
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
m_dataBind = TShader<CCameraBlurFilter>::BuildShaderDataBinding(ctx, *this);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
m_dataBind = ctx.newShaderDataBinding(s_Pipeline, m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -59,6 +77,4 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth)
|
||||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __URDE_CCAMERABLURFILTER_HPP__
|
||||
#define __URDE_CCAMERABLURFILTER_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
|
||||
@ -10,11 +10,6 @@ namespace urde
|
||||
|
||||
class CCameraBlurFilter
|
||||
{
|
||||
friend struct CCameraBlurFilterGLDataBindingFactory;
|
||||
friend struct CCameraBlurFilterVulkanDataBindingFactory;
|
||||
friend struct CCameraBlurFilterMetalDataBindingFactory;
|
||||
friend struct CCameraBlurFilterD3DDataBindingFactory;
|
||||
|
||||
struct Vert
|
||||
{
|
||||
zeus::CVector2f m_pos;
|
||||
@ -32,11 +27,10 @@ class CCameraBlurFilter
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CCameraBlurFilter();
|
||||
void draw(float amount, bool clearDepth=false);
|
||||
|
||||
using _CLS = CCameraBlurFilter;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,163 +0,0 @@
|
||||
#include "CCameraBlurFilter.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 uvIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform CameraBlurUniform\n"
|
||||
"{\n"
|
||||
" vec4 uv0;\n"
|
||||
" vec4 uv1;\n"
|
||||
" vec4 uv2;\n"
|
||||
" vec4 uv3;\n"
|
||||
" vec4 uv4;\n"
|
||||
" vec4 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec2 uvReg;\n"
|
||||
" vec2 uv0;\n"
|
||||
" vec2 uv1;\n"
|
||||
" vec2 uv2;\n"
|
||||
" vec2 uv3;\n"
|
||||
" vec2 uv4;\n"
|
||||
" vec2 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.uvReg = uvIn.xy;\n"
|
||||
" vtf.uv0 = uv0.xy + uvIn.xy;\n"
|
||||
" vtf.uv1 = uv1.xy + uvIn.xy;\n"
|
||||
" vtf.uv2 = uv2.xy + uvIn.xy;\n"
|
||||
" vtf.uv3 = uv3.xy + uvIn.xy;\n"
|
||||
" vtf.uv4 = uv4.xy + uvIn.xy;\n"
|
||||
" vtf.uv5 = uv5.xy + uvIn.xy;\n"
|
||||
" vtf.opacity = opacity;\n"
|
||||
" gl_Position = vec4(posIn.xyz, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec2 uvReg;\n"
|
||||
" vec2 uv0;\n"
|
||||
" vec2 uv1;\n"
|
||||
" vec2 uv2;\n"
|
||||
" vec2 uv3;\n"
|
||||
" vec2 uv4;\n"
|
||||
" vec2 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D sceneTex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 colorSample = texture(sceneTex, vtf.uvReg) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv0) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv1) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv2) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv3) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv4) * 0.14285715;\n"
|
||||
" colorSample += texture(sceneTex, vtf.uv5) * 0.14285715;\n"
|
||||
" colorOut = vec4(colorSample.rgb, vtf.opacity);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CCameraBlurFilterGLDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
return cctx.newShaderDataBinding(s_Pipeline,
|
||||
ctx.newVertexFormat(2, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CCameraBlurFilterVulkanDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* texNames[] = {"sceneTex"};
|
||||
const char* uniNames[] = {"CameraBlurUniform"};
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CCameraBlurFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CCameraBlurFilterVulkanDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
#include "CCameraBlurFilter.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer CameraBlurUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4 uv0;\n"
|
||||
" float4 uv1;\n"
|
||||
" float4 uv2;\n"
|
||||
" float4 uv3;\n"
|
||||
" float4 uv4;\n"
|
||||
" float4 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float2 uvReg : UV6;\n"
|
||||
" float2 uv0 : UV0;\n"
|
||||
" float2 uv1 : UV1;\n"
|
||||
" float2 uv2 : UV2;\n"
|
||||
" float2 uv3 : UV3;\n"
|
||||
" float2 uv4 : UV4;\n"
|
||||
" float2 uv5 : UV5;\n"
|
||||
" float opacity : OPACITY;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uvReg = v.uvIn.xy;\n"
|
||||
" vtf.uvReg.y = 1.0 - vtf.uvReg.y;\n"
|
||||
" vtf.uv0 = uv0.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
|
||||
" vtf.uv1 = uv1.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
|
||||
" vtf.uv2 = uv2.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
|
||||
" vtf.uv3 = uv3.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
|
||||
" vtf.uv4 = uv4.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
|
||||
" vtf.uv5 = uv5.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
|
||||
" vtf.opacity = opacity;\n"
|
||||
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"Texture2D sceneTex : register(t0);\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float2 uvReg : UV6;\n"
|
||||
" float2 uv0 : UV0;\n"
|
||||
" float2 uv1 : UV1;\n"
|
||||
" float2 uv2 : UV2;\n"
|
||||
" float2 uv3 : UV3;\n"
|
||||
" float2 uv4 : UV4;\n"
|
||||
" float2 uv5 : UV5;\n"
|
||||
" float opacity : OPACITY;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float4 colorSample = sceneTex.Sample(samp, vtf.uvReg) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv0) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv1) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv2) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv3) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv4) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.Sample(samp, vtf.uv5) * 0.14285715;\n"
|
||||
" return float4(colorSample.rgb, vtf.opacity);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CCameraBlurFilterD3DDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::D3DDataFactory::Context& cctx = static_cast<boo::D3DDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CCameraBlurFilterD3DDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,133 +0,0 @@
|
||||
#include "CCameraBlurFilter.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
" float4 uvIn [[ attribute(1) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct CameraBlurUniform\n"
|
||||
"{\n"
|
||||
" float4 uv0;\n"
|
||||
" float4 uv1;\n"
|
||||
" float4 uv2;\n"
|
||||
" float4 uv3;\n"
|
||||
" float4 uv4;\n"
|
||||
" float4 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float2 uvReg;\n"
|
||||
" float2 uv0;\n"
|
||||
" float2 uv1;\n"
|
||||
" float2 uv2;\n"
|
||||
" float2 uv3;\n"
|
||||
" float2 uv4;\n"
|
||||
" float2 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant CameraBlurUniform& cbu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.uvReg = v.uvIn.xy;\n"
|
||||
" vtf.uvReg.y = 1.0 - vtf.uvReg.y;\n"
|
||||
" vtf.uv0 = cbu.uv0.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv0.y = 1.0 - vtf.uv0.y;\n"
|
||||
" vtf.uv1 = cbu.uv1.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv1.y = 1.0 - vtf.uv1.y;\n"
|
||||
" vtf.uv2 = cbu.uv2.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv2.y = 1.0 - vtf.uv2.y;\n"
|
||||
" vtf.uv3 = cbu.uv3.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv3.y = 1.0 - vtf.uv3.y;\n"
|
||||
" vtf.uv4 = cbu.uv4.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv4.y = 1.0 - vtf.uv4.y;\n"
|
||||
" vtf.uv5 = cbu.uv5.xy + v.uvIn.xy;\n"
|
||||
" vtf.uv5.y = 1.0 - vtf.uv5.y;\n"
|
||||
" vtf.opacity = cbu.opacity;\n"
|
||||
" vtf.position = float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float2 uvReg;\n"
|
||||
" float2 uv0;\n"
|
||||
" float2 uv1;\n"
|
||||
" float2 uv2;\n"
|
||||
" float2 uv3;\n"
|
||||
" float2 uv4;\n"
|
||||
" float2 uv5;\n"
|
||||
" float opacity;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]], sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> sceneTex [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" float4 colorSample = sceneTex.sample(samp, vtf.uvReg) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv0) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv1) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv2) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv3) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv4) * 0.14285715;\n"
|
||||
" colorSample += sceneTex.sample(samp, vtf.uv5) * 0.14285715;\n"
|
||||
" return float4(colorSample.rgb, vtf.opacity);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CCameraBlurFilterMetalDataBindingFactory : TShader<CCameraBlurFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CCameraBlurFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {CGraphics::g_SpareTexture.get()};
|
||||
return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CCameraBlurFilter>::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CCameraBlurFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CCameraBlurFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,46 @@
|
||||
#include "CColoredQuadFilter.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
void CColoredQuadFilter::Initialize()
|
||||
{
|
||||
s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{});
|
||||
s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{});
|
||||
s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{});
|
||||
}
|
||||
|
||||
void CColoredQuadFilter::Shutdown()
|
||||
{
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
|
||||
{
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
struct Vert
|
||||
{
|
||||
@ -19,7 +54,10 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
|
||||
};
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, 16, 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
m_dataBind = TMultiBlendShader<CColoredQuadFilter>::BuildShaderDataBinding(ctx, type, *this);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -90,6 +128,4 @@ void CWideScreenFilter::SetViewportToFull()
|
||||
|
||||
const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f};
|
||||
|
||||
URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __URDE_CCOLOREDQUADFILTER_HPP__
|
||||
#define __URDE_CCOLOREDQUADFILTER_HPP__
|
||||
|
||||
#include "TMultiBlendShader.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
@ -12,11 +11,6 @@ namespace urde
|
||||
|
||||
class CColoredQuadFilter
|
||||
{
|
||||
friend struct CColoredQuadFilterGLDataBindingFactory;
|
||||
friend struct CColoredQuadFilterVulkanDataBindingFactory;
|
||||
friend struct CColoredQuadFilterMetalDataBindingFactory;
|
||||
friend struct CColoredQuadFilterD3DDataBindingFactory;
|
||||
|
||||
struct Uniform
|
||||
{
|
||||
zeus::CMatrix4f m_matrix;
|
||||
@ -28,15 +22,14 @@ class CColoredQuadFilter
|
||||
Uniform m_uniform;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static const zeus::CRectangle DefaultRect;
|
||||
CColoredQuadFilter(EFilterType type);
|
||||
CColoredQuadFilter(EFilterType type, const TLockedToken<CTexture>&)
|
||||
: CColoredQuadFilter(type) {}
|
||||
void draw(const zeus::CColor& color, const zeus::CRectangle& rect=DefaultRect);
|
||||
void DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) { draw(color); }
|
||||
|
||||
using _CLS = CColoredQuadFilter;
|
||||
#include "TMultiBlendShaderDecl.hpp"
|
||||
};
|
||||
|
||||
class CWideScreenFilter
|
||||
|
@ -1,157 +0,0 @@
|
||||
#include "CColoredQuadFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform ColoredQuadUniform\n"
|
||||
"{\n"
|
||||
" mat4 xf;\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = color;\n"
|
||||
" gl_Position = xf * vec4(posIn.xyz, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type),
|
||||
ctx.newVertexFormat(1, VtxVmt), filter.m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
|
||||
CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* uniNames[] = {"ColoredQuadUniform"};
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::Zero,
|
||||
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CColoredQuadFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
|
||||
CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::Zero,
|
||||
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CColoredQuadFilterVulkanDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,113 +0,0 @@
|
||||
#include "CColoredQuadFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer ColoredQuadUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CColoredQuadFilterD3DDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::D3DDataFactory::Context& cctx = static_cast<boo::D3DDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
|
||||
CColoredQuadFilter::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::Zero,
|
||||
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CColoredQuadFilterD3DDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
#include "CColoredQuadFilter.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ColoredQuadUniform\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant ColoredQuadUniform& cqu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = cqu.color;\n"
|
||||
" vtf.position = cqu.xf * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EFilterType::Blend:
|
||||
return s_AlphaPipeline;
|
||||
case EFilterType::Add:
|
||||
return s_AddPipeline;
|
||||
case EFilterType::Multiply:
|
||||
return s_MultPipeline;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
EFilterType type, CColoredQuadFilter& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[] = {filter.m_uniBuf.get()};
|
||||
return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr);
|
||||
}
|
||||
};
|
||||
|
||||
TMultiBlendShader<CColoredQuadFilter>::IDataBindingFactory*
|
||||
CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
|
||||
s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_AddPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_MultPipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::Zero,
|
||||
boo::BlendFactor::SrcColor, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CColoredQuadFilterMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CColoredQuadFilter::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_AlphaPipeline.reset();
|
||||
s_AddPipeline.reset();
|
||||
s_MultPipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#include "CDecalShaders.hpp"
|
||||
#include "Particle/CDecal.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -11,8 +12,23 @@ boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_texRedToAlphaZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_noTexZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CDecalShaders::m_noTexAdditiveZTest;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> CDecalShaders::m_vtxFormatTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CDecalShaders::m_vtxFormatNoTex;
|
||||
void CDecalShaders::Initialize()
|
||||
{
|
||||
m_texZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderTexZTest{});
|
||||
m_texAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderTexAdditiveZTest{});
|
||||
m_texRedToAlphaZTest = hecl::conv->convert(Shader_CDecalShaderTexRedToAlphaZTest{});
|
||||
m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CDecalShaderNoTexZTest{});
|
||||
m_noTexAdditiveZTest = hecl::conv->convert(Shader_CDecalShaderNoTexAdditiveZTest{});
|
||||
}
|
||||
|
||||
void CDecalShaders::Shutdown()
|
||||
{
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
}
|
||||
|
||||
void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CQuadDecal& decal)
|
||||
{
|
||||
@ -35,10 +51,31 @@ void CDecalShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& c
|
||||
regPipeline = m_noTexZTestNoZWrite;
|
||||
}
|
||||
|
||||
CDecalShaders shad(decal, regPipeline, redToAlphaPipeline);
|
||||
TShader<CDecalShaders>::BuildShaderDataBinding(ctx, shad);
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
if (regPipeline)
|
||||
decal.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (redToAlphaPipeline)
|
||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CDecalShaders)
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,7 @@
|
||||
#ifndef __URDE_CDECALSHADERS_HPP__
|
||||
#define __URDE_CDECALSHADERS_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -14,11 +9,6 @@ struct CQuadDecal;
|
||||
|
||||
class CDecalShaders
|
||||
{
|
||||
friend struct OGLDecalDataBindingFactory;
|
||||
friend struct VulkanDecalDataBindingFactory;
|
||||
friend struct D3DDecalDataBindingFactory;
|
||||
friend struct MetalDecalDataBindingFactory;
|
||||
|
||||
private:
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_texAdditiveZTest;
|
||||
@ -27,22 +17,10 @@ private:
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexZTestNoZWrite;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatNoTex; /* No OpenGL */
|
||||
|
||||
CQuadDecal& m_decal;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipeline;
|
||||
CDecalShaders(CQuadDecal& decal,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipeline,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipeline)
|
||||
: m_decal(decal), m_regPipeline(regPipeline), m_redToAlphaPipeline(redToAlphaPipeline) {}
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CQuadDecal& decal);
|
||||
|
||||
using _CLS = CDecalShaders;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,320 +0,0 @@
|
||||
#include "CDecalShaders.hpp"
|
||||
#include "Particle/CDecal.hpp"
|
||||
#include "Graphics/CModel.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_GLSL_TEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn[4];\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"layout(location=5) in vec4 uvsIn[4];\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform DecalUniform\n"
|
||||
"{\n"
|
||||
" mat4 mvp;\n"
|
||||
" vec4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = colorIn * moduColor;\n"
|
||||
" vtf.uv = uvsIn[gl_VertexID].xy;\n"
|
||||
" gl_Position = mvp * posIn[gl_VertexID];\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_TEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_TEX_REDTOALPHA =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
" colorOut.a = texture(tex, vtf.uv).r;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_GLSL_NOTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn[4];\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform DecalUniform\n"
|
||||
"{\n"
|
||||
" mat4 mvp;\n"
|
||||
" vec4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = colorIn * moduColor;\n"
|
||||
" gl_Position = mvp * posIn[gl_VertexID];\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_NOTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct OGLDecalDataBindingFactory : TShader<CDecalShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CDecalShaders& shaders)
|
||||
{
|
||||
CQuadDecal& decal = shaders.m_decal;
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt;
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(9, TexFmtTex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{decal.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
}
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
decal.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, vtxFmt, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, vtxFmt, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
static const char* UniNames[] = {"DecalUniform"};
|
||||
static const char* TexNames[] = {"tex"};
|
||||
|
||||
TShader<CDecalShaders>::IDataBindingFactory* CDecalShaders::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::One, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, true, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct OGLDecalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CDecalShaders::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct VulkanDecalDataBindingFactory : TShader<CDecalShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CDecalShaders& shaders)
|
||||
{
|
||||
CQuadDecal& decal = shaders.m_decal;
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
decal.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CDecalShaders>::IDataBindingFactory* CDecalShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
boo::BlendFactor::One, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, true, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct VulkanDecalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CDecalShaders::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,215 +0,0 @@
|
||||
#include "CDecalShaders.hpp"
|
||||
#include "Particle/CDecal.hpp"
|
||||
#include "Graphics/CModel.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_HLSL_TEX =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4] : POSITION;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
" float4 uvsIn[4] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer DecalUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn * moduColor;\n"
|
||||
" vtf.uv = v.uvsIn[vertId].xy;\n"
|
||||
" vtf.position = mul(mvp, v.posIn[vertId]);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_TEX =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex0.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_TEX_REDTOALPHA =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_HLSL_NOTEX =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4] : POSITION;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer DecalUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn * moduColor;\n"
|
||||
" vtf.position = mul(mvp, v.posIn[vertId]);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_NOTEX =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct D3DDecalDataBindingFactory : TShader<CDecalShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CDecalShaders& shaders)
|
||||
{
|
||||
CQuadDecal& decal = shaders.m_decal;
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
decal.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CDecalShaders>::IDataBindingFactory* CDecalShaders::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::One, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, true, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct D3DDecalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CDecalShaders::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,221 +0,0 @@
|
||||
#include "CDecalShaders.hpp"
|
||||
#include "Particle/CDecal.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_METAL_TEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4];\n"
|
||||
" float4 colorIn;\n"
|
||||
" float4 uvsIn[4];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct DecalUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],\n"
|
||||
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
|
||||
" constant DecalUniform& decal [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" constant VertData& v = va[instId];\n"
|
||||
" vtf.color = v.colorIn * decal.moduColor;\n"
|
||||
" vtf.uv = v.uvsIn[vertId].xy;\n"
|
||||
" vtf.position = decal.mvp * v.posIn[vertId];\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_TEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex0.sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_TEX_REDTOALPHA =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_METAL_NOTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4];\n"
|
||||
" float4 colorIn;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct DecalUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],\n"
|
||||
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
|
||||
" constant DecalUniform& decal [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" constant VertData& v = va[instId];\n"
|
||||
" vtf.color = v.colorIn * decal.moduColor;\n"
|
||||
" vtf.position = decal.mvp * v.posIn[vertId];\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_NOTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct MetalDecalDataBindingFactory : TShader<CDecalShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CDecalShaders& shader)
|
||||
{
|
||||
CQuadDecal& decal = shader.m_decal;
|
||||
const SQuadDescr* desc = decal.m_desc;
|
||||
|
||||
CUVElement* texr = desc->x14_TEX.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[1];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
}
|
||||
|
||||
if (decal.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {decal.m_uniformBuf.get()};
|
||||
|
||||
if (shader.m_regPipeline)
|
||||
decal.m_normalDataBind = ctx.newShaderDataBinding(shader.m_regPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shader.m_redToAlphaPipeline)
|
||||
decal.m_redToAlphaDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
decal.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CDecalShaders>::IDataBindingFactory* CDecalShaders::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::One, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
|
||||
return new struct MetalDecalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CDecalShaders::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#include "CElementGenShaders.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -32,9 +33,67 @@ boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexNoZTestNoZWrite;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveZTest;
|
||||
boo::ObjToken<boo::IShaderPipeline> CElementGenShaders::m_noTexAdditiveNoZTest;
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatIndTex;
|
||||
boo::ObjToken<boo::IVertexFormat> CElementGenShaders::m_vtxFormatNoTex;
|
||||
void CElementGenShaders::Initialize()
|
||||
{
|
||||
m_texZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderTexZTestZWrite{});
|
||||
m_texNoZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestZWrite{});
|
||||
m_texZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWrite{});
|
||||
m_texNoZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWrite{});
|
||||
m_texAdditiveZTest = hecl::conv->convert(Shader_CElementGenShaderTexAdditiveZTest{});
|
||||
m_texAdditiveNoZTest = hecl::conv->convert(Shader_CElementGenShaderTexAdditiveNoZTest{});
|
||||
m_texRedToAlphaZTest = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTest{});
|
||||
m_texRedToAlphaNoZTest = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTest{});
|
||||
m_texZTestNoZWriteSub = hecl::conv->convert(Shader_CElementGenShaderTexZTestNoZWriteSub{});
|
||||
m_texNoZTestNoZWriteSub = hecl::conv->convert(Shader_CElementGenShaderTexNoZTestNoZWriteSub{});
|
||||
m_texRedToAlphaZTestSub = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaZTestSub{});
|
||||
m_texRedToAlphaNoZTestSub = hecl::conv->convert(Shader_CElementGenShaderTexRedToAlphaNoZTestSub{});
|
||||
|
||||
m_indTexZWrite = hecl::conv->convert(Shader_CElementGenShaderIndTexZWrite{});
|
||||
m_indTexNoZWrite = hecl::conv->convert(Shader_CElementGenShaderIndTexNoZWrite{});
|
||||
m_indTexAdditive = hecl::conv->convert(Shader_CElementGenShaderIndTexAdditive{});
|
||||
|
||||
m_cindTexZWrite = hecl::conv->convert(Shader_CElementGenShaderCindTexZWrite{});
|
||||
m_cindTexNoZWrite = hecl::conv->convert(Shader_CElementGenShaderCindTexNoZWrite{});
|
||||
m_cindTexAdditive = hecl::conv->convert(Shader_CElementGenShaderCindTexAdditive{});
|
||||
|
||||
m_noTexZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexZTestZWrite{});
|
||||
m_noTexNoZTestZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestZWrite{});
|
||||
m_noTexZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexZTestNoZWrite{});
|
||||
m_noTexNoZTestNoZWrite = hecl::conv->convert(Shader_CElementGenShaderNoTexNoZTestNoZWrite{});
|
||||
m_noTexAdditiveZTest = hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveZTest{});
|
||||
m_noTexAdditiveNoZTest = hecl::conv->convert(Shader_CElementGenShaderNoTexAdditiveNoZTest{});
|
||||
}
|
||||
|
||||
void CElementGenShaders::Shutdown()
|
||||
{
|
||||
m_texZTestZWrite.reset();
|
||||
m_texNoZTestZWrite.reset();
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texNoZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texAdditiveNoZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_texRedToAlphaNoZTest.reset();
|
||||
m_texZTestNoZWriteSub.reset();
|
||||
m_texNoZTestNoZWriteSub.reset();
|
||||
m_texRedToAlphaZTestSub.reset();
|
||||
m_texRedToAlphaNoZTestSub.reset();
|
||||
|
||||
m_indTexZWrite.reset();
|
||||
m_indTexNoZWrite.reset();
|
||||
m_indTexAdditive.reset();
|
||||
|
||||
m_cindTexZWrite.reset();
|
||||
m_cindTexNoZWrite.reset();
|
||||
m_cindTexAdditive.reset();
|
||||
|
||||
m_noTexZTestZWrite.reset();
|
||||
m_noTexNoZTestZWrite.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexNoZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
m_noTexAdditiveNoZTest.reset();
|
||||
}
|
||||
|
||||
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen)
|
||||
{
|
||||
@ -178,11 +237,62 @@ void CElementGenShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Conte
|
||||
}
|
||||
}
|
||||
|
||||
CElementGenShaders shad(gen, regPipeline, regPipelineSub, redToAlphaPipeline, redToAlphaPipelineSub,
|
||||
regPipelinePmus, redToAlphaPipelinePmus);
|
||||
TShader<CElementGenShaders>::BuildShaderDataBinding(ctx, shad);
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (regPipelineSub)
|
||||
gen.m_normalSubDataBind = ctx.newShaderDataBinding(regPipelineSub, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (redToAlphaPipelineSub)
|
||||
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(redToAlphaPipelineSub, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (regPipelinePmus)
|
||||
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(regPipelinePmus, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (redToAlphaPipelinePmus)
|
||||
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(redToAlphaPipelinePmus, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CElementGenShaders)
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
#ifndef __URDE_CELEMENTGENSHADERS_HPP__
|
||||
#define __URDE_CELEMENTGENSHADERS_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -14,10 +10,6 @@ class CElementGen;
|
||||
|
||||
class CElementGenShaders
|
||||
{
|
||||
friend struct OGLElementDataBindingFactory;
|
||||
friend struct VulkanElementDataBindingFactory;
|
||||
friend struct D3DElementDataBindingFactory;
|
||||
friend struct MetalElementDataBindingFactory;
|
||||
public:
|
||||
enum class EShaderClass
|
||||
{
|
||||
@ -55,34 +47,11 @@ private:
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZTest;
|
||||
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveNoZTest;
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatIndTex; /* No OpenGL */
|
||||
static boo::ObjToken<boo::IVertexFormat> m_vtxFormatNoTex; /* No OpenGL */
|
||||
|
||||
CElementGen& m_gen;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipeline;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelineSub;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_regPipelinePmus;
|
||||
boo::ObjToken<boo::IShaderPipeline> m_redToAlphaPipelinePmus;
|
||||
CElementGenShaders(CElementGen& gen,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipeline,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipelineSub,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipeline,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelineSub,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& regPipelinePmus,
|
||||
const boo::ObjToken<boo::IShaderPipeline>& redToAlphaPipelinePmus)
|
||||
: m_gen(gen), m_regPipeline(regPipeline), m_regPipelineSub(regPipelineSub),
|
||||
m_redToAlphaPipeline(redToAlphaPipeline), m_redToAlphaPipelineSub(redToAlphaPipelineSub),
|
||||
m_regPipelinePmus(regPipelinePmus), m_redToAlphaPipelinePmus(redToAlphaPipelinePmus) {}
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static EShaderClass GetShaderClass(CElementGen& gen);
|
||||
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CElementGen& gen);
|
||||
|
||||
using _CLS = CElementGenShaders;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,744 +0,0 @@
|
||||
#include "CElementGenShaders.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
#include "Particle/CElectricDescription.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
#include "Graphics/CModel.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_GLSL_TEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn[4];\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"layout(location=5) in vec4 uvsIn[4];\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform ParticleUniform\n"
|
||||
"{\n"
|
||||
" mat4 mvp;\n"
|
||||
" vec4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 pos = posIn[gl_VertexID];\n"
|
||||
" vtf.color = colorIn * moduColor;\n"
|
||||
" vtf.uv = uvsIn[gl_VertexID].xy;\n"
|
||||
" gl_Position = mvp * pos;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_TEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_TEX_REDTOALPHA =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
" colorOut.a = texture(tex, vtf.uv).r;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_GLSL_INDTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn[4];\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"layout(location=5) in vec4 uvsInTexrTind[4];\n"
|
||||
"layout(location=9) in vec4 uvsInScene;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform ParticleUniform\n"
|
||||
"{\n"
|
||||
" mat4 mvp;\n"
|
||||
" vec4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 uvScene;\n"
|
||||
" vec2 uvTexr;\n"
|
||||
" vec2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 pos = posIn[gl_VertexID];\n"
|
||||
" vtf.color = colorIn * moduColor;\n"
|
||||
" vtf.uvScene = uvsInScene;\n"
|
||||
" vtf.uvTexr = uvsInTexrTind[gl_VertexID].xy;\n"
|
||||
" vtf.uvTind = uvsInTexrTind[gl_VertexID].zw;\n"
|
||||
" gl_Position = mvp * pos;\n"
|
||||
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_INDTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 uvScene;\n"
|
||||
" vec2 uvTexr;\n"
|
||||
" vec2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D texrMap;\n"
|
||||
"TBINDING1 uniform sampler2D sceneMap;\n"
|
||||
"TBINDING2 uniform sampler2D tindMap;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;\n"
|
||||
" vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" vec4 texrTexel = texture(texrMap, vtf.uvTexr);\n"
|
||||
" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) + texrTexel;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_CINDTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 uvScene;\n"
|
||||
" vec2 uvTexr;\n"
|
||||
" vec2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D texrMap;\n"
|
||||
"TBINDING1 uniform sampler2D sceneMap;\n"
|
||||
"TBINDING2 uniform sampler2D tindMap;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;\n"
|
||||
" vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) * texture(texrMap, vtf.uvTexr);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_GLSL_NOTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn[4];\n"
|
||||
"layout(location=4) in vec4 colorIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform ParticleUniform\n"
|
||||
"{\n"
|
||||
" mat4 mvp;\n"
|
||||
" vec4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 pos = posIn[gl_VertexID];\n"
|
||||
" vtf.color = colorIn * moduColor;\n"
|
||||
" gl_Position = mvp * pos;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_GLSL_NOTEX =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shaders)
|
||||
{
|
||||
CElementGen& gen = shaders.m_gen;
|
||||
CGenDescription* desc = gen.GetDesc();
|
||||
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt;
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmtPmus;
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
|
||||
const boo::VertexElementDescriptor TexFmtIndTex[] =
|
||||
{
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4},
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(10, TexFmtIndTex);
|
||||
}
|
||||
else
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(9, TexFmtTex);
|
||||
}
|
||||
}
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
vtxFmtPmus = ctx.newVertexFormat(9, TexFmtTex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBuf.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
}
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{gen.m_instBufPmus.get(), nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
vtxFmtPmus = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
}
|
||||
}
|
||||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, vtxFmt, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_regPipelineSub)
|
||||
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, vtxFmt, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, vtxFmt, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelineSub)
|
||||
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, vtxFmt, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shaders.m_regPipelinePmus)
|
||||
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, vtxFmtPmus, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelinePmus)
|
||||
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, vtxFmtPmus, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
static const char* UniNames[] = {"ParticleUniform"};
|
||||
static const char* TexNames[] = {"tex"};
|
||||
static const char* TindTexNames[] = {"texrMap", "sceneMap", "tindMap"};
|
||||
|
||||
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct OGLElementDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CElementGenShaders::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
m_texZTestZWrite.reset();
|
||||
m_texNoZTestZWrite.reset();
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texNoZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texAdditiveNoZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_texRedToAlphaNoZTest.reset();
|
||||
m_texZTestNoZWriteSub.reset();
|
||||
m_texNoZTestNoZWriteSub.reset();
|
||||
m_texRedToAlphaZTestSub.reset();
|
||||
m_texRedToAlphaNoZTestSub.reset();
|
||||
|
||||
m_indTexZWrite.reset();
|
||||
m_indTexNoZWrite.reset();
|
||||
m_indTexAdditive.reset();
|
||||
|
||||
m_cindTexZWrite.reset();
|
||||
m_cindTexNoZWrite.reset();
|
||||
m_cindTexAdditive.reset();
|
||||
|
||||
m_noTexZTestZWrite.reset();
|
||||
m_noTexNoZTestZWrite.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexNoZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
m_noTexAdditiveNoZTest.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shaders)
|
||||
{
|
||||
CElementGen& gen = shaders.m_gen;
|
||||
CGenDescription* desc = gen.GetDesc();
|
||||
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_regPipelineSub)
|
||||
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelineSub)
|
||||
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shaders.m_regPipelinePmus)
|
||||
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelinePmus)
|
||||
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtIndTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 5},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 6},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 7}
|
||||
};
|
||||
m_vtxFormatIndTex = ctx.newVertexFormat(13, TexFmtIndTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct VulkanElementDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CElementGenShaders::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatIndTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
|
||||
m_texZTestZWrite.reset();
|
||||
m_texNoZTestZWrite.reset();
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texNoZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texAdditiveNoZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_texRedToAlphaNoZTest.reset();
|
||||
m_texZTestNoZWriteSub.reset();
|
||||
m_texNoZTestNoZWriteSub.reset();
|
||||
m_texRedToAlphaZTestSub.reset();
|
||||
m_texRedToAlphaNoZTestSub.reset();
|
||||
|
||||
m_indTexZWrite.reset();
|
||||
m_indTexNoZWrite.reset();
|
||||
m_indTexAdditive.reset();
|
||||
|
||||
m_cindTexZWrite.reset();
|
||||
m_cindTexNoZWrite.reset();
|
||||
m_cindTexAdditive.reset();
|
||||
|
||||
m_noTexZTestZWrite.reset();
|
||||
m_noTexNoZTestZWrite.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexNoZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
m_noTexAdditiveNoZTest.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,474 +0,0 @@
|
||||
#include "CElementGenShaders.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
#include "Particle/CElectricDescription.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
#include "Graphics/CModel.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_HLSL_TEX =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4] : POSITION;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
" float4 uvsIn[4] : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer ParticleUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn * moduColor;\n"
|
||||
" vtf.uv = v.uvsIn[vertId].xy;\n"
|
||||
" vtf.position = mul(mvp, v.posIn[vertId]);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_TEX =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex0.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_TEX_REDTOALPHA =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return float4(vtf.color.rgb, tex0.Sample(samp, vtf.uv).r);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_HLSL_INDTEX =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4] : POSITION;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
" float4 uvsInTexrTind[4] : UV0;\n"
|
||||
" float4 uvsInScene : UV4;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer ParticleUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float4 uvScene : UV0;\n"
|
||||
" float2 uvTexr : UV1;\n"
|
||||
" float2 uvTind : UV2;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn * moduColor;\n"
|
||||
" vtf.uvScene = v.uvsInScene;\n"
|
||||
" vtf.uvScene.y = 1.0 - vtf.uvScene.y;\n"
|
||||
" vtf.uvScene.w = 1.0 - vtf.uvScene.w;\n"
|
||||
" vtf.uvTexr = v.uvsInTexrTind[vertId].xy;\n"
|
||||
" vtf.uvTind = v.uvsInTexrTind[vertId].zw;\n"
|
||||
" vtf.position = mul(mvp, v.posIn[vertId]);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_INDTEX =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"Texture2D tex1 : register(t1);\n"
|
||||
"Texture2D tex2 : register(t2);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float4 uvScene : UV0;\n"
|
||||
" float2 uvTexr : UV1;\n"
|
||||
" float2 uvTind : UV2;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float2 tindTexel = tex2.Sample(samp, vtf.uvTind).zw;\n"
|
||||
" float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" float4 texrTexel = tex0.Sample(samp, vtf.uvTexr);\n"
|
||||
" float4 colorOut = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;\n"
|
||||
" colorOut.a = vtf.color.a * texrTexel.a;\n"
|
||||
" return colorOut;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_CINDTEX =
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex0 : register(t0);\n"
|
||||
"Texture2D tex1 : register(t1);\n"
|
||||
"Texture2D tex2 : register(t2);\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float4 uvScene : UV0;\n"
|
||||
" float2 uvTexr : UV1;\n"
|
||||
" float2 uvTind : UV2;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float2 tindTexel = tex2.Sample(samp, vtf.uvTind).ba;\n"
|
||||
" float4 sceneTexel = tex1.Sample(samp, lerp(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.Sample(samp, vtf.uvTexr);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_HLSL_NOTEX =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4] : POSITION;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer ParticleUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v, in uint vertId : SV_VertexID)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = v.colorIn * moduColor;\n"
|
||||
" vtf.position = mul(mvp, v.posIn[vertId]);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_HLSL_NOTEX =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct D3DElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shaders)
|
||||
{
|
||||
CElementGen& gen = shaders.m_gen;
|
||||
CGenDescription* desc = gen.GetDesc();
|
||||
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shaders.m_regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
if (shaders.m_regPipelineSub)
|
||||
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelineSub)
|
||||
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shaders.m_regPipelinePmus)
|
||||
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
if (shaders.m_redToAlphaPipelinePmus)
|
||||
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtIndTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4}
|
||||
};
|
||||
m_vtxFormatIndTex = ctx.newVertexFormat(10, TexFmtIndTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_HLSL_TEX, FS_HLSL_TEX_REDTOALPHA, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_INDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_INDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_INDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_CINDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_CINDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_HLSL_INDTEX, FS_HLSL_CINDTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
|
||||
nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct D3DElementDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CElementGenShaders::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatIndTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
|
||||
m_texZTestZWrite.reset();
|
||||
m_texNoZTestZWrite.reset();
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texNoZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texAdditiveNoZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_texRedToAlphaNoZTest.reset();
|
||||
m_texZTestNoZWriteSub.reset();
|
||||
m_texNoZTestNoZWriteSub.reset();
|
||||
m_texRedToAlphaZTestSub.reset();
|
||||
m_texRedToAlphaNoZTestSub.reset();
|
||||
|
||||
m_indTexZWrite.reset();
|
||||
m_indTexNoZWrite.reset();
|
||||
m_indTexAdditive.reset();
|
||||
|
||||
m_cindTexZWrite.reset();
|
||||
m_cindTexNoZWrite.reset();
|
||||
m_cindTexAdditive.reset();
|
||||
|
||||
m_noTexZTestZWrite.reset();
|
||||
m_noTexNoZTestZWrite.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexNoZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
m_noTexAdditiveNoZTest.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,444 +0,0 @@
|
||||
#include "CElementGenShaders.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS_METAL_TEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4];\n"
|
||||
" float4 colorIn;\n"
|
||||
" float4 uvsIn[4];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ParticleUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],\n"
|
||||
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
|
||||
" constant ParticleUniform& particle [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" constant VertData& v = va[instId];\n"
|
||||
" vtf.color = v.colorIn * particle.moduColor;\n"
|
||||
" vtf.uv = v.uvsIn[vertId].xy;\n"
|
||||
" vtf.position = particle.mvp * v.posIn[vertId];\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_TEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex0.sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_TEX_REDTOALPHA =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return float4(vtf.color.rgb, tex0.sample(samp, vtf.uv).r);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_METAL_INDTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4];\n"
|
||||
" float4 colorIn;\n"
|
||||
" float4 uvsInTexrTind[4];\n"
|
||||
" float4 uvsInScene;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ParticleUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float4 uvScene;\n"
|
||||
" float2 uvTexr;\n"
|
||||
" float2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],\n"
|
||||
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
|
||||
" constant ParticleUniform& particle [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" constant VertData& v = va[instId];\n"
|
||||
" vtf.color = v.colorIn * particle.moduColor;\n"
|
||||
" vtf.uvScene = v.uvsInScene;\n"
|
||||
" vtf.uvScene.y = 1.0 - vtf.uvScene.y;\n"
|
||||
" vtf.uvScene.w = 1.0 - vtf.uvScene.w;\n"
|
||||
" vtf.uvTexr = v.uvsInTexrTind[vertId].xy;\n"
|
||||
" vtf.uvTind = v.uvsInTexrTind[vertId].zw;\n"
|
||||
" vtf.position = particle.mvp * v.posIn[vertId];\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_INDTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float4 uvScene;\n"
|
||||
" float2 uvTexr;\n"
|
||||
" float2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],"
|
||||
" texture2d<float> tex0 [[ texture(0) ]],\n"
|
||||
" texture2d<float> tex1 [[ texture(1) ]],\n"
|
||||
" texture2d<float> tex2 [[ texture(2) ]])\n"
|
||||
"{\n"
|
||||
" float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;\n"
|
||||
" float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" float4 texrTexel = tex0.sample(samp, vtf.uvTexr);\n"
|
||||
" float4 colr = vtf.color * float4(sceneTexel.rgb, 1.0) + texrTexel;\n"
|
||||
" return float4(colr.rgb, vtf.color.a * texrTexel.a);"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_CINDTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float4 uvScene;\n"
|
||||
" float2 uvTexr;\n"
|
||||
" float2 uvTind;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex0 [[ texture(0) ]],\n"
|
||||
" texture2d<float> tex1 [[ texture(1) ]],\n"
|
||||
" texture2d<float> tex2 [[ texture(2) ]])\n"
|
||||
"{\n"
|
||||
" float2 tindTexel = tex2.sample(samp, vtf.uvTind).ba;\n"
|
||||
" float4 sceneTexel = tex1.sample(samp, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
||||
" return vtf.color * float4(sceneTexel.rgb, 1.0) * tex0.sample(samp, vtf.uvTexr);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* VS_METAL_NOTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn[4];\n"
|
||||
" float4 colorIn;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct ParticleUniform\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
" float4 moduColor;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(constant VertData* va [[ buffer(1) ]],\n"
|
||||
" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n"
|
||||
" constant ParticleUniform& particle [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" constant VertData& v = va[instId];\n"
|
||||
" vtf.color = v.colorIn * particle.moduColor;\n"
|
||||
" vtf.position = particle.mvp * v.posIn[vertId];\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_METAL_NOTEX =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color;\n"
|
||||
"}\n";
|
||||
|
||||
struct MetalElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGenShaders& shader)
|
||||
{
|
||||
CElementGen& gen = shader.m_gen;
|
||||
CGenDescription* desc = gen.GetDesc();
|
||||
|
||||
CUVElement* texr = desc->x54_x40_TEXR.get();
|
||||
CUVElement* tind = desc->x58_x44_TIND.get();
|
||||
int texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> textures[3];
|
||||
|
||||
if (texr)
|
||||
{
|
||||
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 1;
|
||||
if (tind)
|
||||
{
|
||||
textures[1] = CGraphics::g_SpareTexture.get();
|
||||
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
||||
texCount = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (gen.m_instBuf)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
||||
|
||||
if (shader.m_regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(shader.m_regPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shader.m_regPipelineSub)
|
||||
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shader.m_regPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shader.m_redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shader.m_redToAlphaPipelineSub)
|
||||
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shader.m_redToAlphaPipelineSub, nullptr, nullptr,
|
||||
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
if (gen.m_instBufPmus)
|
||||
{
|
||||
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
||||
texCount = std::min(texCount, 1);
|
||||
|
||||
if (shader.m_regPipelinePmus)
|
||||
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shader.m_regPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (shader.m_redToAlphaPipelinePmus)
|
||||
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shader.m_redToAlphaPipelinePmus, nullptr, nullptr,
|
||||
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}
|
||||
};
|
||||
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtIndTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4}
|
||||
};
|
||||
m_vtxFormatIndTex = ctx.newVertexFormat(10, TexFmtIndTex);
|
||||
|
||||
static const boo::VertexElementDescriptor TexFmtNoTex[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced}
|
||||
};
|
||||
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
||||
|
||||
m_texZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_texAdditiveZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, true, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, true, boo::CullMode::None);
|
||||
|
||||
m_texZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZTestNoZWriteSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_texRedToAlphaZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, true, boo::CullMode::None);
|
||||
m_texRedToAlphaNoZTestSub = ctx.newShaderPipeline(VS_METAL_TEX, FS_METAL_TEX_REDTOALPHA, nullptr, nullptr, m_vtxFormatTex,
|
||||
boo::BlendFactor::Subtract, boo::BlendFactor::Subtract,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
||||
true, true, boo::CullMode::None);
|
||||
|
||||
m_indTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
m_indTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
m_indTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_INDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
|
||||
m_cindTexZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
m_cindTexAdditive = ctx.newShaderPipeline(VS_METAL_INDTEX, FS_METAL_CINDTEX, nullptr, nullptr, m_vtxFormatIndTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true, true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, true, true, false, boo::CullMode::None);
|
||||
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_vtxFormatNoTex,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
|
||||
return new struct MetalElementDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CElementGenShaders::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
m_texZTestZWrite.reset();
|
||||
m_texNoZTestZWrite.reset();
|
||||
m_texZTestNoZWrite.reset();
|
||||
m_texNoZTestNoZWrite.reset();
|
||||
m_texAdditiveZTest.reset();
|
||||
m_texAdditiveNoZTest.reset();
|
||||
m_texRedToAlphaZTest.reset();
|
||||
m_texRedToAlphaNoZTest.reset();
|
||||
m_texZTestNoZWriteSub.reset();
|
||||
m_texNoZTestNoZWriteSub.reset();
|
||||
m_texRedToAlphaZTestSub.reset();
|
||||
m_texRedToAlphaNoZTestSub.reset();
|
||||
|
||||
m_indTexZWrite.reset();
|
||||
m_indTexNoZWrite.reset();
|
||||
m_indTexAdditive.reset();
|
||||
|
||||
m_cindTexZWrite.reset();
|
||||
m_cindTexNoZWrite.reset();
|
||||
m_cindTexAdditive.reset();
|
||||
|
||||
m_noTexZTestZWrite.reset();
|
||||
m_noTexNoZTestZWrite.reset();
|
||||
m_noTexZTestNoZWrite.reset();
|
||||
m_noTexNoZTestNoZWrite.reset();
|
||||
m_noTexAdditiveZTest.reset();
|
||||
m_noTexAdditiveNoZTest.reset();
|
||||
|
||||
m_vtxFormatTex.reset();
|
||||
m_vtxFormatIndTex.reset();
|
||||
m_vtxFormatNoTex.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,8 +1,23 @@
|
||||
#include "CEnergyBarShader.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
void CEnergyBarShader::Initialize()
|
||||
{
|
||||
s_Pipeline = hecl::conv->convert(Shader_CEnergyBarShader{});
|
||||
}
|
||||
|
||||
void CEnergyBarShader::Shutdown()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
void CEnergyBarShader::updateModelMatrix()
|
||||
{
|
||||
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
|
||||
@ -24,9 +39,17 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
|
||||
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {m_tex->GetBooTexture()};
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
{
|
||||
m_uniBuf[i] = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
TShader<CEnergyBarShader>::BuildShaderDataBinding(ctx, *this);
|
||||
bufs[0] = m_uniBuf[i].get();
|
||||
m_dataBind[i] = ctx.newShaderDataBinding(s_Pipeline,
|
||||
m_vbo.get(), nullptr, nullptr, 1, bufs, stages,
|
||||
nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -75,6 +98,4 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
|
||||
}
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __URDE_CENERGYBARSHADER_HPP__
|
||||
#define __URDE_CENERGYBARSHADER_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
@ -12,11 +11,6 @@ namespace urde
|
||||
|
||||
class CEnergyBarShader
|
||||
{
|
||||
friend struct CEnergyBarShaderGLDataBindingFactory;
|
||||
friend struct CEnergyBarShaderVulkanDataBindingFactory;
|
||||
friend struct CEnergyBarShaderMetalDataBindingFactory;
|
||||
friend struct CEnergyBarShaderD3DDataBindingFactory;
|
||||
|
||||
public:
|
||||
struct Vertex
|
||||
{
|
||||
@ -38,14 +32,13 @@ private:
|
||||
size_t m_maxVerts = 0;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
void updateModelMatrix();
|
||||
void draw(const zeus::CColor& color0, const std::vector<Vertex>& verts0,
|
||||
const zeus::CColor& color1, const std::vector<Vertex>& verts1,
|
||||
const zeus::CColor& color2, const std::vector<Vertex>& verts2,
|
||||
const CTexture* tex);
|
||||
|
||||
using _CLS = CEnergyBarShader;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,146 +0,0 @@
|
||||
#include "CEnergyBarShader.hpp"
|
||||
#include "TShader.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec4 uvIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform EnergyBarUniform\n"
|
||||
"{\n"
|
||||
" mat4 xf;\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = uvIn.xy;\n"
|
||||
" gl_Position = xf * vec4(posIn.xyz, 1.0);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D tex;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CEnergyBarShaderGLDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::ObjToken<boo::IVertexFormat> vtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::PipelineStage stages[] = {boo::PipelineStage::Vertex};
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
{
|
||||
bufs[0] = filter.m_uniBuf[i].get();
|
||||
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline,
|
||||
vtxFmt, filter.m_vbo.get(), nullptr, nullptr,
|
||||
1, bufs, stages, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CEnergyBarShaderVulkanDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
{
|
||||
bufs[0] = filter.m_uniBuf[i].get();
|
||||
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TShader<CEnergyBarShader>::IDataBindingFactory*
|
||||
CEnergyBarShader::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* uniNames[] = {"EnergyBarUniform"};
|
||||
const char* texNames[] = {"tex"};
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
return new CEnergyBarShaderGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CEnergyBarShader>::IDataBindingFactory*
|
||||
CEnergyBarShader::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
return new CEnergyBarShaderVulkanDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
#include "CEnergyBarShader.hpp"
|
||||
#include "TShader.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer EnergyBarUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = mul(xf, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D tex : register(t0);\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CEnergyBarShaderD3DDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::D3DDataFactory::Context& cctx = static_cast<boo::D3DDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
{
|
||||
bufs[0] = filter.m_uniBuf[i].get();
|
||||
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CEnergyBarShader>::IDataBindingFactory*
|
||||
CEnergyBarShader::Initialize(boo::D3DDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, nullptr,
|
||||
s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::LEqual, false, true, false, boo::CullMode::None);
|
||||
return new CEnergyBarShaderD3DDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::D3DDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
#include "CEnergyBarShader.hpp"
|
||||
#include "TShader.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn [[ attribute(0) ]];\n"
|
||||
" float4 uvIn [[ attribute(1) ]];\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct EnergyBarUniform\n"
|
||||
"{\n"
|
||||
" float4x4 xf;\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant EnergyBarUniform& ebu [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.color = ebu.color;\n"
|
||||
" vtf.uv = v.uvIn.xy;\n"
|
||||
" vtf.position = ebu.xf * float4(v.posIn.xyz, 1.0);\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS =
|
||||
"#include <metal_stdlib>\n"
|
||||
"using namespace metal;\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position [[ position ]];\n"
|
||||
" float4 color;\n"
|
||||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n"
|
||||
" sampler samp [[ sampler(0) ]],\n"
|
||||
" texture2d<float> tex [[ texture(0) ]])\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CEnergyBarShader)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
|
||||
|
||||
struct CEnergyBarShaderMetalDataBindingFactory : TShader<CEnergyBarShader>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CEnergyBarShader& filter)
|
||||
{
|
||||
boo::MetalDataFactory::Context& cctx = static_cast<boo::MetalDataFactory::Context&>(ctx);
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBuffer> bufs[1];
|
||||
boo::ObjToken<boo::ITexture> texs[] = {filter.m_tex->GetBooTexture()};
|
||||
for (int i=0 ; i<3 ; ++i)
|
||||
{
|
||||
bufs[0] = filter.m_uniBuf[i].get();
|
||||
filter.m_dataBind[i] = cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, bufs,
|
||||
nullptr, nullptr, nullptr, 1, texs, nullptr, nullptr);
|
||||
}
|
||||
return filter.m_dataBind[0];
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CEnergyBarShader>::IDataBindingFactory*
|
||||
CEnergyBarShader::Initialize(boo::MetalDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_Pipeline = ctx.newShaderPipeline(VS, FS, nullptr, nullptr, s_VtxFmt,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual,
|
||||
false, true, false, boo::CullMode::None);
|
||||
return new CEnergyBarShaderMetalDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CEnergyBarShader::Shutdown<boo::MetalDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_Pipeline.reset();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#include "CFluidPlaneShader.hpp"
|
||||
#include "World/CRipple.hpp"
|
||||
#include "World/CRippleManager.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
@ -90,54 +91,32 @@ u16 CFluidPlaneShader::Cache::MakeCacheKey(const SFluidPlaneDoorShaderInfo& info
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
CFluidPlaneShader::ShaderPair CFluidPlaneShader::Cache::GetOrBuildShader(const T& info)
|
||||
template<> CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info)
|
||||
{
|
||||
u16 key = MakeCacheKey(info);
|
||||
auto& slot = CacheSlot(info, key);
|
||||
if (slot.m_regular)
|
||||
return slot;
|
||||
|
||||
if (CGraphics::g_BooFactory == nullptr)
|
||||
return {};
|
||||
|
||||
CGraphics::CommitResources(
|
||||
[&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
{
|
||||
switch (ctx.platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
slot = BuildShader(static_cast<boo::GLDataFactory::Context&>(ctx), info);
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
slot = BuildShader(static_cast<boo::D3DDataFactory::Context&>(ctx), info);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
slot = BuildShader(static_cast<boo::MetalDataFactory::Context&>(ctx), info);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
slot = BuildShader(static_cast<boo::VulkanDataFactory::Context&>(ctx), info);
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
return true;
|
||||
} BooTrace);
|
||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneShader{info, false});
|
||||
if (info.m_tessellation)
|
||||
slot.m_tessellation = hecl::conv->convert(Shader_CFluidPlaneShader{info, true});
|
||||
|
||||
return slot;
|
||||
}
|
||||
template<> CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info)
|
||||
{
|
||||
u16 key = MakeCacheKey(info);
|
||||
auto& slot = CacheSlot(info, key);
|
||||
if (slot.m_regular)
|
||||
return slot;
|
||||
|
||||
template CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneShaderInfo>(const SFluidPlaneShaderInfo& info);
|
||||
template CFluidPlaneShader::ShaderPair
|
||||
CFluidPlaneShader::Cache::GetOrBuildShader<SFluidPlaneDoorShaderInfo>(const SFluidPlaneDoorShaderInfo& info);
|
||||
slot.m_regular = hecl::conv->convert(Shader_CFluidPlaneDoorShader{info});
|
||||
|
||||
return slot;
|
||||
}
|
||||
|
||||
void CFluidPlaneShader::Cache::Clear()
|
||||
{
|
||||
@ -157,30 +136,37 @@ void CFluidPlaneShader::PrepareBinding(const ShaderPair& pipeline, u32 maxVertCo
|
||||
m_pvbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(PatchVertex), maxVertCount);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
|
||||
|
||||
switch (ctx.platform())
|
||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = { m_uniBuf.get(), m_uniBuf.get(), m_uniBuf.get() };
|
||||
boo::PipelineStage ubufStages[] = { boo::PipelineStage::Vertex, boo::PipelineStage::Vertex,
|
||||
boo::PipelineStage::Fragment };
|
||||
size_t ubufOffs[] = {0, 0, 1280};
|
||||
size_t ubufSizes[] = {1280, 1280, sizeof(CModelShaders::LightingUniform)};
|
||||
size_t texCount = 0;
|
||||
boo::ObjToken<boo::ITexture> texs[8];
|
||||
if (m_patternTex1)
|
||||
texs[texCount++] = m_patternTex1->GetBooTexture();
|
||||
if (m_patternTex2)
|
||||
texs[texCount++] = m_patternTex2->GetBooTexture();
|
||||
if (m_colorTex)
|
||||
texs[texCount++] = m_colorTex->GetBooTexture();
|
||||
if (m_bumpMap)
|
||||
texs[texCount++] = m_bumpMap->GetBooTexture();
|
||||
if (m_envMap)
|
||||
texs[texCount++] = m_envMap->GetBooTexture();
|
||||
if (m_envBumpMap)
|
||||
texs[texCount++] = m_envBumpMap->GetBooTexture();
|
||||
if (m_lightmap)
|
||||
texs[texCount++] = m_lightmap->GetBooTexture();
|
||||
auto regular = ctx.newShaderDataBinding(pipeline.m_regular, m_vbo.get(), nullptr, nullptr, 3,
|
||||
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
||||
boo::ObjToken<boo::IShaderDataBinding> tessellation;
|
||||
if (pipeline.m_tessellation)
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
m_dataBind = BuildBinding(static_cast<boo::GLDataFactory::Context&>(ctx), pipeline);
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
m_dataBind = BuildBinding(static_cast<boo::D3DDataFactory::Context&>(ctx), pipeline);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
m_dataBind = BuildBinding(static_cast<boo::MetalDataFactory::Context&>(ctx), pipeline);
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
m_dataBind = BuildBinding(static_cast<boo::VulkanDataFactory::Context&>(ctx), pipeline);
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
texs[texCount++] = m_rippleMap.get();
|
||||
tessellation = ctx.newShaderDataBinding(pipeline.m_tessellation, m_pvbo.get(), nullptr, nullptr, 3,
|
||||
ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr);
|
||||
}
|
||||
m_dataBind = {regular, tessellation};
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -188,30 +174,6 @@ void CFluidPlaneShader::PrepareBinding(const ShaderPair& pipeline, u32 maxVertCo
|
||||
void CFluidPlaneShader::Shutdown()
|
||||
{
|
||||
_cache.Clear();
|
||||
switch (CGraphics::g_BooFactory->platform())
|
||||
{
|
||||
#if BOO_HAS_GL
|
||||
case boo::IGraphicsDataFactory::Platform::OpenGL:
|
||||
CFluidPlaneShader::_Shutdown<boo::GLDataFactory>();
|
||||
break;
|
||||
#endif
|
||||
#if _WIN32
|
||||
case boo::IGraphicsDataFactory::Platform::D3D11:
|
||||
CFluidPlaneShader::_Shutdown<boo::D3DDataFactory>();
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_METAL
|
||||
case boo::IGraphicsDataFactory::Platform::Metal:
|
||||
CFluidPlaneShader::_Shutdown<boo::MetalDataFactory>();
|
||||
break;
|
||||
#endif
|
||||
#if BOO_HAS_VULKAN
|
||||
case boo::IGraphicsDataFactory::Platform::Vulkan:
|
||||
CFluidPlaneShader::_Shutdown<boo::VulkanDataFactory>();
|
||||
break;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
CFluidPlaneShader::CFluidPlaneShader(EFluidType type,
|
||||
|
@ -4,52 +4,15 @@
|
||||
#include "RetroTypes.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
#include "CModelShaders.hpp"
|
||||
#include "boo/graphicsdev/GL.hpp"
|
||||
#include "boo/graphicsdev/D3D.hpp"
|
||||
#include "boo/graphicsdev/Metal.hpp"
|
||||
#include "boo/graphicsdev/Vulkan.hpp"
|
||||
#include "World/CFluidPlaneManager.hpp"
|
||||
#include "Graphics/CTexture.hpp"
|
||||
#include "CToken.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "Shaders/shader_CFluidPlaneShader.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
struct SFluidPlaneShaderInfo
|
||||
{
|
||||
EFluidType m_type;
|
||||
bool m_hasPatternTex1;
|
||||
bool m_hasPatternTex2;
|
||||
bool m_hasColorTex;
|
||||
bool m_hasBumpMap;
|
||||
bool m_hasEnvMap;
|
||||
bool m_hasEnvBumpMap;
|
||||
bool m_hasLightmap;
|
||||
bool m_tessellation;
|
||||
bool m_doubleLightmapBlend;
|
||||
bool m_additive;
|
||||
|
||||
SFluidPlaneShaderInfo(EFluidType type, bool hasPatternTex1, bool hasPatternTex2, bool hasColorTex,
|
||||
bool hasBumpMap, bool hasEnvMap, bool hasEnvBumpMap, bool hasLightmap,
|
||||
bool tessellation, bool doubleLightmapBlend, bool additive)
|
||||
: m_type(type), m_hasPatternTex1(hasPatternTex1), m_hasPatternTex2(hasPatternTex2), m_hasColorTex(hasColorTex),
|
||||
m_hasBumpMap(hasBumpMap), m_hasEnvMap(hasEnvMap), m_hasEnvBumpMap(hasEnvBumpMap), m_hasLightmap(hasLightmap),
|
||||
m_tessellation(tessellation), m_doubleLightmapBlend(doubleLightmapBlend), m_additive(additive)
|
||||
{}
|
||||
};
|
||||
|
||||
struct SFluidPlaneDoorShaderInfo
|
||||
{
|
||||
bool m_hasPatternTex1;
|
||||
bool m_hasPatternTex2;
|
||||
bool m_hasColorTex;
|
||||
|
||||
SFluidPlaneDoorShaderInfo(bool hasPatternTex1, bool hasPatternTex2, bool hasColorTex)
|
||||
: m_hasPatternTex1(hasPatternTex1), m_hasPatternTex2(hasPatternTex2), m_hasColorTex(hasColorTex)
|
||||
{}
|
||||
};
|
||||
|
||||
class CFluidPlaneShader
|
||||
{
|
||||
public:
|
||||
|
@ -1,8 +1,27 @@
|
||||
#include "CFogVolumeFilter.hpp"
|
||||
#include "hecl/Pipeline.hpp"
|
||||
#include "Graphics/CGraphics.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
void CFogVolumeFilter::Initialize()
|
||||
{
|
||||
s_1WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter1Way{});
|
||||
s_2WayPipeline = hecl::conv->convert(Shader_CFogVolumeFilter2Way{});
|
||||
}
|
||||
|
||||
void CFogVolumeFilter::Shutdown()
|
||||
{
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
|
||||
CFogVolumeFilter::CFogVolumeFilter()
|
||||
{
|
||||
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
|
||||
@ -20,7 +39,18 @@ CFogVolumeFilter::CFogVolumeFilter()
|
||||
};
|
||||
m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts, sizeof(Vert), 4);
|
||||
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CColor), 1);
|
||||
TShader<CFogVolumeFilter>::BuildShaderDataBinding(ctx, *this);
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer->GetFogRampTex().get() };
|
||||
int bindIdxs[] = {0, 1, 0};
|
||||
bool bindDepth[] = {true, true, false};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {m_uniBuf.get()};
|
||||
|
||||
m_dataBind1Way = ctx.newShaderDataBinding(s_1WayPipeline,
|
||||
m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
m_dataBind2Way = ctx.newShaderDataBinding(s_2WayPipeline,
|
||||
m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
return true;
|
||||
} BooTrace);
|
||||
}
|
||||
@ -39,6 +69,4 @@ void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color)
|
||||
CGraphics::DrawArray(0, 4);
|
||||
}
|
||||
|
||||
URDE_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
}
|
||||
|
@ -1,33 +1,27 @@
|
||||
#ifndef __URDE_CFOGVOLUMEFILTER_HPP__
|
||||
#define __URDE_CFOGVOLUMEFILTER_HPP__
|
||||
|
||||
#include "TShader.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CColor.hpp"
|
||||
#include "zeus/CRectangle.hpp"
|
||||
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
class CFogVolumeFilter
|
||||
{
|
||||
friend struct CFogVolumeFilterGLDataBindingFactory;
|
||||
friend struct CFogVolumeFilterVulkanDataBindingFactory;
|
||||
friend struct CFogVolumeFilterMetalDataBindingFactory;
|
||||
friend struct CFogVolumeFilterD3DDataBindingFactory;
|
||||
|
||||
boo::ObjToken<boo::IGraphicsBufferS> m_vbo;
|
||||
boo::ObjToken<boo::IGraphicsBufferD> m_uniBuf;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind1Way;
|
||||
boo::ObjToken<boo::IShaderDataBinding> m_dataBind2Way;
|
||||
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
CFogVolumeFilter();
|
||||
void draw2WayPass(const zeus::CColor& color);
|
||||
void draw1WayPass(const zeus::CColor& color);
|
||||
|
||||
using _CLS = CFogVolumeFilter;
|
||||
#include "TShaderDecl.hpp"
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,196 +0,0 @@
|
||||
#include "CFogVolumeFilter.hpp"
|
||||
#include "TShader.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"layout(location=0) in vec4 posIn;\n"
|
||||
"layout(location=1) in vec2 uvIn;\n"
|
||||
"\n"
|
||||
"UBINDING0 uniform FogVolumeFilterUniform\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = vec4(posIn.xy, 0.0, 1.0);\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = uvIn;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS1Way =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D zFrontfaceTex;\n"
|
||||
"TBINDING1 uniform sampler2D zBackfaceTex;\n"
|
||||
"TBINDING2 uniform sampler2D zLinearizer;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" float y;\n"
|
||||
" const float linScale = 65535.0 / 65536.0 * 256.0;\n"
|
||||
" float x = modf(texture(zFrontfaceTex, vtf.uv).r * linScale, y);\n"
|
||||
" const float uvBias = 0.5 / 256.0;\n"
|
||||
" float alpha = texture(zLinearizer, vec2(x * 255.0 / 256.0 + uvBias, y / 256.0 + uvBias)).r * 10.0;\n"
|
||||
" colorOut = vtf.color * alpha;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS2Way =
|
||||
"#version 330\n"
|
||||
BOO_GLSL_BINDING_HEAD
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
" vec2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) in VertToFrag vtf;\n"
|
||||
"layout(location=0) out vec4 colorOut;\n"
|
||||
"TBINDING0 uniform sampler2D zFrontfaceTex;\n"
|
||||
"TBINDING1 uniform sampler2D zBackfaceTex;\n"
|
||||
"TBINDING2 uniform sampler2D zLinearizer;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" float frontY;\n"
|
||||
" float backY;\n"
|
||||
" const float linScale = 65535.0 / 65536.0 * 256.0;\n"
|
||||
" float frontX = modf(texture(zFrontfaceTex, vtf.uv).r * linScale, frontY);\n"
|
||||
" float backX = modf(texture(zBackfaceTex, vtf.uv).r * linScale, backY);\n"
|
||||
" const float uvBias = 0.5 / 256.0;\n"
|
||||
" float frontLin = texture(zLinearizer, vec2(frontX * 255.0 / 256.0 + uvBias, frontY / 256.0 + uvBias)).r;\n"
|
||||
" float backLin = texture(zLinearizer, vec2(backX * 255.0 / 256.0 + uvBias, backY / 256.0 + uvBias)).r;\n"
|
||||
" colorOut = vec4(vtf.color.rgb, (frontLin - backLin) * 10.0);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
struct CFogVolumeFilterGLDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumeFilter& filter)
|
||||
{
|
||||
boo::GLDataFactory::Context& cctx = static_cast<boo::GLDataFactory::Context&>(ctx);
|
||||
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::Position4},
|
||||
{filter.m_vbo.get(), nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
boo::ObjToken<boo::IVertexFormat> VtxVmtObj = cctx.newVertexFormat(2, VtxVmt);
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer->GetFogRampTex().get() };
|
||||
int bindIdxs[] = {0, 1, 0};
|
||||
bool bindDepth[] = {true, true, false};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
|
||||
|
||||
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, VtxVmtObj,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, VtxVmtObj,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
return filter.m_dataBind1Way;
|
||||
}
|
||||
};
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct CFogVolumeFilterVulkanDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumeFilter& filter)
|
||||
{
|
||||
boo::VulkanDataFactory::Context& cctx = static_cast<boo::VulkanDataFactory::Context&>(ctx);
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer->GetFogRampTex().get() };
|
||||
int bindIdxs[] = {0, 1, 0};
|
||||
bool bindDepth[] = {true, true, false};
|
||||
boo::ObjToken<boo::IGraphicsBuffer> ubufs[] = {filter.m_uniBuf.get()};
|
||||
|
||||
filter.m_dataBind1Way = cctx.newShaderDataBinding(s_1WayPipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
filter.m_dataBind2Way = cctx.newShaderDataBinding(s_2WayPipeline, s_VtxFmt,
|
||||
filter.m_vbo.get(), nullptr, nullptr, 1, ubufs,
|
||||
nullptr, nullptr, nullptr, 3, texs, bindIdxs, bindDepth);
|
||||
return filter.m_dataBind1Way;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
TShader<CFogVolumeFilter>::IDataBindingFactory*
|
||||
CFogVolumeFilter::Initialize(boo::GLDataFactory::Context& ctx)
|
||||
{
|
||||
const char* texNames[] = {"zFrontfaceTex", "zBackfaceTex", "zLinearizer"};
|
||||
const char* uniNames[] = {"FogVolumeFilterUniform"};
|
||||
s_1WayPipeline = ctx.newShaderPipeline(VS, FS1Way, 3, texNames, 1, uniNames, boo::BlendFactor::DstAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_2WayPipeline = ctx.newShaderPipeline(VS, FS2Way, 3, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CFogVolumeFilterGLDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CFogVolumeFilter::Shutdown<boo::GLDataFactory>()
|
||||
{
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
TShader<CFogVolumeFilter>::IDataBindingFactory*
|
||||
CFogVolumeFilter::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
const boo::VertexElementDescriptor VtxVmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4}
|
||||
};
|
||||
s_VtxFmt = ctx.newVertexFormat(2, VtxVmt);
|
||||
s_1WayPipeline = ctx.newShaderPipeline(VS, FS1Way, s_VtxFmt, boo::BlendFactor::DstAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
s_2WayPipeline = ctx.newShaderPipeline(VS, FS2Way, s_VtxFmt, boo::BlendFactor::SrcAlpha,
|
||||
boo::BlendFactor::One, boo::Primitive::TriStrips,
|
||||
boo::ZTest::None, false, true, false, boo::CullMode::None);
|
||||
return new CFogVolumeFilterVulkanDataBindingFactory;
|
||||
}
|
||||
|
||||
template <>
|
||||
void CFogVolumeFilter::Shutdown<boo::VulkanDataFactory>()
|
||||
{
|
||||
s_VtxFmt.reset();
|
||||
s_1WayPipeline.reset();
|
||||
s_2WayPipeline.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
#include "CFogVolumeFilter.hpp"
|
||||
#include "TShader.hpp"
|
||||
#include "GameGlobalObjects.hpp"
|
||||
#include "Graphics/CBooRenderer.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float2 uvIn : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer FogVolumeFilterUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4 color;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"VertToFrag main(in VertData v)\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
" vtf.position = float4(v.posIn.x, -v.posIn.y, 0.0, 1.0);\n"
|
||||
" vtf.color = color;\n"
|
||||
" vtf.uv = v.uvIn;\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS1Way =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D zFrontfaceTex : register(t0);\n"
|
||||
"Texture2D zBackfaceTex : register(t1);\n"
|
||||
"Texture2D zLinearizer : register(t2);\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float y;\n"
|
||||
" const float linScale = 65535.0 / 65536.0 * 256.0;\n"
|
||||
" float x = modf((1.0 - zFrontfaceTex.Sample(samp, vtf.uv).r) * linScale, y);\n"
|
||||
" const float uvBias = 0.5 / 256.0;\n"
|
||||
" float alpha = zLinearizer.Sample(samp, float2(x * 255.0 / 256.0 + uvBias, y / 256.0 + uvBias)).r * 10.0;\n"
|
||||
" return vtf.color * alpha;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS2Way =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 position : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"Texture2D zFrontfaceTex : register(t0);\n"
|
||||
"Texture2D zBackfaceTex : register(t1);\n"
|
||||
"Texture2D zLinearizer : register(t2);\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" float frontY;\n"
|
||||
" float backY;\n"
|
||||
" const float linScale = 65535.0 / 65536.0 * 256.0;\n"
|
||||
" float frontX = modf((1.0 - zFrontfaceTex.Sample(samp, vtf.uv).r) * linScale, frontY);\n"
|
||||
" float backX = modf((1.0 - zBackfaceTex.Sample(samp, vtf.uv).r) * linScale, backY);\n"
|
||||
" const float uvBias = 0.5 / 256.0;\n"
|
||||
" float frontLin = zLinearizer.Sample(samp, float2(frontX * 255.0 / 256.0 + uvBias, frontY / 256.0 + uvBias)).r;\n"
|
||||
" float backLin = zLinearizer.Sample(samp, float2(backX * 255.0 / 256.0 + uvBias, backY / 256.0 + uvBias)).r;\n"
|
||||
" return float4(vtf.color.rgb, (frontLin - backLin) * 10.0);\n"
|
||||
"}\n";
|
||||
|
||||
URDE_DECL_SPECIALIZE_SHADER(CFogVolumeFilter)
|
||||
|
||||
static boo::ObjToken<boo::IVertexFormat> s_VtxFmt;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_1WayPipeline;
|
||||
static boo::ObjToken<boo::IShaderPipeline> s_2WayPipeline;
|
||||
|
||||
struct CFogVolumeFilterD3DDataBindingFactory : TShader<CFogVolumeFilter>::IDataBindingFactory
|
||||
{
|
||||
boo::ObjToken<boo::IShaderDataBinding>
|
||||
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CFogVolumeFilter& filter)
|
||||
{
|
||||
boo::D3DDataFactory::Context& cctx = static_cast<boo::D3DDataFactory::Context&>(ctx);
|
||||
boo::ObjToken<boo::ITexture> texs[] = { CGraphics::g_SpareTexture.get(), CGraphics::g_SpareTexture.get(),
|
||||
g_Renderer- |