mirror of https://github.com/AxioDL/metaforce.git
CParticleSwooshShaders HLSL implementation
This commit is contained in:
parent
f3acc97d63
commit
6701ac264d
|
@ -5,15 +5,15 @@
|
|||
#include "CParticleGenInfo.hpp"
|
||||
#include "zeus/CFrustum.hpp"
|
||||
#include "CToken.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
#include "Particle/CElectricDescription.hpp"
|
||||
#include <map>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CPoseAsTransforms;
|
||||
class CCharLayoutInfo;
|
||||
class CGenDescription;
|
||||
class CSwooshDescription;
|
||||
class CElectricDescription;
|
||||
|
||||
class CParticleDatabase
|
||||
{
|
||||
|
|
|
@ -370,13 +370,12 @@ TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize
|
|||
}
|
||||
|
||||
#if BOO_HAS_VULKAN
|
||||
struct VulkanElementDataBindingFactory : CElementGenShaders::IDataBindingFactory
|
||||
struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
||||
{
|
||||
void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CElementGen& gen,
|
||||
boo::IShaderPipeline* regPipeline,
|
||||
boo::IShaderPipeline* redToAlphaPipeline)
|
||||
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();
|
||||
|
@ -398,18 +397,20 @@ struct VulkanElementDataBindingFactory : CElementGenShaders::IDataBindingFactory
|
|||
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf};
|
||||
|
||||
if (regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr, nullptr,
|
||||
if (shaders.m_regPipeline)
|
||||
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf, nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
if (redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, nullptr,
|
||||
if (shaders.m_redToAlphaPipeline)
|
||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
||||
gen.m_instBuf, nullptr, 1, uniforms,
|
||||
nullptr, texCount, textures, nullptr, nullptr);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
CElementGenShaders::IDataBindingFactory* CElementGenShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor TexFmtTex[] =
|
||||
{
|
||||
|
|
|
@ -109,9 +109,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, 1, TexNames, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
|
@ -126,9 +126,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, 0, nullptr, 1, UniNames,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct OGLParticleSwooshDataBindingFactory;
|
||||
}
|
||||
|
@ -176,9 +176,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
|
@ -193,9 +193,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct VulkanParticleSwooshDataBindingFactory;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
#include "CParticleSwooshShaders.hpp"
|
||||
#include "Particle/CParticleSwoosh.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
static const char* VS =
|
||||
"struct VertData\n"
|
||||
"{\n"
|
||||
" float4 posIn : POSITION;\n"
|
||||
" float4 uvIn : UV;\n"
|
||||
" float4 colorIn : COLOR;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"cbuffer SwooshUniform : register(b0)\n"
|
||||
"{\n"
|
||||
" float4x4 mvp;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : 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 = v.colorIn;\n"
|
||||
" vtf.uv = v.uvIn;\n"
|
||||
" vtf.pos = mul(mvp, float4(v.posIn.xyz, 1.0));\n"
|
||||
" return vtf;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_TEX =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : SV_Position;\n"
|
||||
" float4 color : COLOR;\n"
|
||||
" float2 uv : UV;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SamplerState samp : register(s0);\n"
|
||||
"Texture2D tex : register(t0);\n"
|
||||
"float4 main(in VertToFrag vtf) : SV_Target0\n"
|
||||
"{\n"
|
||||
" return vtf.color * tex.Sample(samp, vtf.uv);\n"
|
||||
"}\n";
|
||||
|
||||
static const char* FS_NOTEX =
|
||||
"struct VertToFrag\n"
|
||||
"{\n"
|
||||
" float4 pos : 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;\n"
|
||||
"}\n";
|
||||
|
||||
struct D3DParticleSwooshDataBindingFactory : TShader<CParticleSwooshShaders>::IDataBindingFactory
|
||||
{
|
||||
boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
||||
CParticleSwooshShaders& shaders)
|
||||
{
|
||||
CParticleSwoosh& gen = shaders.m_gen;
|
||||
CSwooshDescription* desc = gen.GetDesc();
|
||||
|
||||
CUVElement* texr = desc->x3c_TEXR.get();
|
||||
boo::ITexture* textures[] = {texr->GetValueTexture(0).GetObj()->GetBooTexture()};
|
||||
|
||||
boo::IGraphicsBuffer* uniforms[] = {gen.m_uniformBuf};
|
||||
gen.m_dataBind = ctx.newShaderDataBinding(shaders.m_pipeline, CParticleSwooshShaders::m_vtxFormat,
|
||||
gen.m_vertBuf, nullptr, nullptr, 1, uniforms,
|
||||
nullptr, texr ? 1 : 0, textures, nullptr, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::Initialize(boo::ID3DDataFactory::Context& ctx)
|
||||
{
|
||||
static const boo::VertexElementDescriptor VtxFmt[] =
|
||||
{
|
||||
{nullptr, nullptr, boo::VertexSemantic::Position4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::UV4},
|
||||
{nullptr, nullptr, boo::VertexSemantic::Color},
|
||||
};
|
||||
m_vtxFormat = ctx.newVertexFormat(3, VtxFmt);
|
||||
|
||||
m_texZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, nullptr, nullptr, nullptr, m_vtxFormat,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct D3DParticleSwooshDataBindingFactory;
|
||||
}
|
||||
|
||||
}
|
|
@ -27,7 +27,6 @@ static const char* VS =
|
|||
" float2 uv;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"SBINDING(0) out VertToFrag vtf;\n"
|
||||
"vertex VertToFrag vmain(VertData v [[ stage_in ]], constant SwooshUniform& su [[ buffer(2) ]])\n"
|
||||
"{\n"
|
||||
" VertToFrag vtf;\n"
|
||||
|
@ -111,9 +110,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_texAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_TEX, m_vtxFormat, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
m_noTexZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
||||
|
@ -128,9 +127,9 @@ TShader<CParticleSwooshShaders>::IDataBindingFactory* CParticleSwooshShaders::In
|
|||
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
||||
true, false, boo::CullMode::None);
|
||||
m_noTexAdditiveNoZWrite = ctx.newShaderPipeline(VS, FS_NOTEX, m_vtxFormat, CGraphics::g_ViewportSamples,
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
||||
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
||||
true, false, boo::CullMode::None);
|
||||
|
||||
return new struct MetalParticleSwooshDataBindingFactory;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "CProjectileWeapon.hpp"
|
||||
#include "Particle/CWeaponDescription.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
|
|
@ -5,13 +5,15 @@
|
|||
#include "CRandom16.hpp"
|
||||
#include "CToken.hpp"
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "Particle/CParticleSwoosh.hpp"
|
||||
#include "Particle/CElementGen.hpp"
|
||||
#include "Particle/CParticleSwoosh.hpp"
|
||||
#include "Particle/CGenDescription.hpp"
|
||||
#include "Particle/CSwooshDescription.hpp"
|
||||
#include "Particle/CWeaponDescription.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
class CModel;
|
||||
class CWeaponDescription;
|
||||
class CProjectileWeapon
|
||||
{
|
||||
static CRandom16 g_GlobalSeed;
|
||||
|
|
Loading…
Reference in New Issue