2016-02-15 04:00:26 +00:00
|
|
|
#include "CElementGenShaders.hpp"
|
2017-06-10 05:34:39 +00:00
|
|
|
#include "Particle/CElementGen.hpp"
|
|
|
|
#include "Particle/CGenDescription.hpp"
|
|
|
|
#include "Particle/CElectricDescription.hpp"
|
|
|
|
#include "Particle/CSwooshDescription.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "Graphics/CModel.hpp"
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
static const char* VS_GLSL_TEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-16 05:50:41 +00:00
|
|
|
"layout(location=0) in vec4 posIn[4];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=4) in vec4 colorIn;\n"
|
2016-02-16 19:42:24 +00:00
|
|
|
"layout(location=5) in vec4 uvsIn[4];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
"UBINDING0 uniform ParticleUniform\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"{\n"
|
|
|
|
" mat4 mvp;\n"
|
|
|
|
" vec4 moduColor;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
|
|
|
" vec2 uv;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) out VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" vec4 pos = posIn[gl_VertexID];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vtf.color = colorIn * moduColor;\n"
|
2016-02-16 19:42:24 +00:00
|
|
|
" vtf.uv = uvsIn[gl_VertexID].xy;\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" gl_Position = mvp * pos;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* FS_GLSL_TEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-15 04:00:26 +00:00
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
|
|
|
" vec2 uv;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) in VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=0) out vec4 colorOut;\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
"TBINDING0 uniform sampler2D tex;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
" colorOut = vtf.color * texture(tex, vtf.uv);\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* FS_GLSL_TEX_REDTOALPHA =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-15 04:00:26 +00:00
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
|
|
|
" vec2 uv;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) in VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=0) out vec4 colorOut;\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
"TBINDING0 uniform sampler2D tex;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2017-09-05 03:00:19 +00:00
|
|
|
" colorOut = vtf.color;\n"
|
|
|
|
" colorOut.a = texture(tex, vtf.uv).r;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* VS_GLSL_INDTEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-16 05:50:41 +00:00
|
|
|
"layout(location=0) in vec4 posIn[4];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=4) in vec4 colorIn;\n"
|
|
|
|
"layout(location=5) in vec4 uvsInTexrTind[4];\n"
|
2016-02-25 05:09:45 +00:00
|
|
|
"layout(location=9) in vec4 uvsInScene;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
"UBINDING0 uniform ParticleUniform\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"{\n"
|
|
|
|
" mat4 mvp;\n"
|
|
|
|
" vec4 moduColor;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
2016-02-25 05:09:45 +00:00
|
|
|
" vec4 uvScene;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vec2 uvTexr;\n"
|
|
|
|
" vec2 uvTind;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) out VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" vec4 pos = posIn[gl_VertexID];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vtf.color = colorIn * moduColor;\n"
|
2016-02-25 05:09:45 +00:00
|
|
|
" vtf.uvScene = uvsInScene;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vtf.uvTexr = uvsInTexrTind[gl_VertexID].xy;\n"
|
|
|
|
" vtf.uvTind = uvsInTexrTind[gl_VertexID].zw;\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" gl_Position = mvp * pos;\n"
|
2016-07-02 03:46:02 +00:00
|
|
|
" gl_Position = FLIPFROMGL(gl_Position);\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* FS_GLSL_INDTEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-15 04:00:26 +00:00
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
2016-02-25 05:09:45 +00:00
|
|
|
" vec4 uvScene;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vec2 uvTexr;\n"
|
|
|
|
" vec2 uvTind;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) in VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=0) out vec4 colorOut;\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
"TBINDING0 uniform sampler2D texrMap;\n"
|
|
|
|
"TBINDING1 uniform sampler2D sceneMap;\n"
|
|
|
|
"TBINDING2 uniform sampler2D tindMap;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
" 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"
|
2018-02-12 22:27:40 +00:00
|
|
|
" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) + texrTexel;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* FS_GLSL_CINDTEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-15 04:00:26 +00:00
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
2016-02-25 05:09:45 +00:00
|
|
|
" vec4 uvScene;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vec2 uvTexr;\n"
|
|
|
|
" vec2 uvTind;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) in VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=0) out vec4 colorOut;\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
"TBINDING0 uniform sampler2D texrMap;\n"
|
|
|
|
"TBINDING1 uniform sampler2D sceneMap;\n"
|
|
|
|
"TBINDING2 uniform sampler2D tindMap;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2016-07-08 00:07:11 +00:00
|
|
|
" vec2 tindTexel = texture(tindMap, vtf.uvTind).zw;\n"
|
|
|
|
" vec4 sceneTexel = texture(sceneMap, mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
|
2018-02-12 22:27:40 +00:00
|
|
|
" colorOut = vtf.color * vec4(sceneTexel.rgb, 1.0) * texture(texrMap, vtf.uvTexr);\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* VS_GLSL_NOTEX =
|
|
|
|
"#version 330\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-16 05:50:41 +00:00
|
|
|
"layout(location=0) in vec4 posIn[4];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=4) in vec4 colorIn;\n"
|
|
|
|
"\n"
|
2016-02-24 03:20:07 +00:00
|
|
|
"UBINDING0 uniform ParticleUniform\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"{\n"
|
|
|
|
" mat4 mvp;\n"
|
|
|
|
" vec4 moduColor;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) out VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" vec4 pos = posIn[gl_VertexID];\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
" vtf.color = colorIn * moduColor;\n"
|
2018-06-22 03:08:47 +00:00
|
|
|
" gl_Position = mvp * pos;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char* FS_GLSL_NOTEX =
|
|
|
|
"#version 330\n"
|
2016-07-03 23:35:03 +00:00
|
|
|
BOO_GLSL_BINDING_HEAD
|
2016-02-15 04:00:26 +00:00
|
|
|
"struct VertToFrag\n"
|
|
|
|
"{\n"
|
|
|
|
" vec4 color;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
2016-07-01 02:33:16 +00:00
|
|
|
"SBINDING(0) in VertToFrag vtf;\n"
|
2016-02-15 04:00:26 +00:00
|
|
|
"layout(location=0) out vec4 colorOut;\n"
|
|
|
|
"void main()\n"
|
|
|
|
"{\n"
|
|
|
|
" colorOut = vtf.color;\n"
|
|
|
|
"}\n";
|
|
|
|
|
2017-06-10 05:34:39 +00:00
|
|
|
struct OGLElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IShaderDataBinding> BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
|
|
|
CElementGenShaders& shaders)
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-06-24 09:13:33 +00:00
|
|
|
CElementGen& gen = shaders.m_gen;
|
2016-02-15 04:00:26 +00:00
|
|
|
CGenDescription* desc = gen.GetDesc();
|
|
|
|
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IVertexFormat> vtxFmt;
|
|
|
|
boo::ObjToken<boo::IVertexFormat> vtxFmtPmus;
|
2016-03-03 01:06:42 +00:00
|
|
|
CUVElement* texr = desc->x54_x40_TEXR.get();
|
|
|
|
CUVElement* tind = desc->x58_x44_TIND.get();
|
2016-02-15 04:00:26 +00:00
|
|
|
int texCount = 0;
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::ITexture> textures[3];
|
2016-02-15 04:00:26 +00:00
|
|
|
|
|
|
|
if (texr)
|
|
|
|
{
|
|
|
|
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
|
|
|
texCount = 1;
|
2017-06-12 18:20:07 +00:00
|
|
|
if (gen.m_instBuf)
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-06-12 18:20:07 +00:00
|
|
|
if (tind)
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
textures[1] = CGraphics::g_SpareTexture.get();
|
2017-06-12 18:20:07 +00:00
|
|
|
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
|
|
|
texCount = 3;
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2017-06-12 18:20:07 +00:00
|
|
|
const boo::VertexElementDescriptor TexFmtIndTex[] =
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
{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},
|
2017-06-12 18:20:07 +00:00
|
|
|
};
|
|
|
|
vtxFmt = ctx.newVertexFormat(10, TexFmtIndTex);
|
|
|
|
}
|
|
|
|
else
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-06-12 18:20:07 +00:00
|
|
|
const boo::VertexElementDescriptor TexFmtTex[] =
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
{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}
|
2017-06-12 18:20:07 +00:00
|
|
|
};
|
|
|
|
vtxFmt = ctx.newVertexFormat(9, TexFmtTex);
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|
2017-06-12 18:20:07 +00:00
|
|
|
if (gen.m_instBufPmus)
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
|
|
|
const boo::VertexElementDescriptor TexFmtTex[] =
|
2017-06-12 18:20:07 +00:00
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
{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}
|
2017-06-12 18:20:07 +00:00
|
|
|
};
|
|
|
|
vtxFmtPmus = ctx.newVertexFormat(9, TexFmtTex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gen.m_instBuf)
|
|
|
|
{
|
|
|
|
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
{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}
|
2016-02-15 04:00:26 +00:00
|
|
|
};
|
2017-06-12 18:20:07 +00:00
|
|
|
vtxFmt = ctx.newVertexFormat(5, TexFmtNoTex);
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|
2017-06-12 18:20:07 +00:00
|
|
|
if (gen.m_instBufPmus)
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2017-06-12 18:20:07 +00:00
|
|
|
const boo::VertexElementDescriptor TexFmtNoTex[] =
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
{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}
|
2017-06-12 18:20:07 +00:00
|
|
|
};
|
|
|
|
vtxFmtPmus = ctx.newVertexFormat(5, TexFmtNoTex);
|
|
|
|
}
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|
|
|
|
|
2017-06-12 18:20:07 +00:00
|
|
|
if (gen.m_instBuf)
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_regPipeline)
|
|
|
|
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, vtxFmt, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-03-14 07:03:58 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-09-05 03:00:19 +00:00
|
|
|
if (shaders.m_regPipelineSub)
|
|
|
|
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, vtxFmt, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-09-05 03:00:19 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_redToAlphaPipeline)
|
|
|
|
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, vtxFmt, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-09-05 03:00:19 +00:00
|
|
|
if (shaders.m_redToAlphaPipelineSub)
|
|
|
|
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, vtxFmt, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-09-05 03:00:19 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-06-12 18:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gen.m_instBufPmus)
|
|
|
|
{
|
2017-11-05 06:17:12 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
2017-06-12 18:20:07 +00:00
|
|
|
texCount = std::min(texCount, 1);
|
|
|
|
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_regPipelinePmus)
|
|
|
|
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, vtxFmtPmus, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_redToAlphaPipelinePmus)
|
|
|
|
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, vtxFmtPmus, nullptr,
|
2017-11-05 06:17:12 +00:00
|
|
|
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
|
|
|
}
|
|
|
|
|
2017-06-10 05:34:39 +00:00
|
|
|
return nullptr;
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-04-15 03:26:01 +00:00
|
|
|
static const char* UniNames[] = {"ParticleUniform"};
|
2016-07-08 00:07:11 +00:00
|
|
|
static const char* TexNames[] = {"tex"};
|
|
|
|
static const char* TindTexNames[] = {"texrMap", "sceneMap", "tindMap"};
|
2016-04-15 03:26:01 +00:00
|
|
|
|
2017-06-10 05:34:39 +00:00
|
|
|
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::GLDataFactory::Context& ctx)
|
2016-02-15 04:00:26 +00:00
|
|
|
{
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, 1, TexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2017-09-05 03:00:19 +00:00
|
|
|
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);
|
|
|
|
|
2016-07-08 00:07:11 +00:00
|
|
|
m_indTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_indTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_indTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-07-08 00:07:11 +00:00
|
|
|
m_cindTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-07-08 00:07:11 +00:00
|
|
|
m_cindTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, 3, TindTexNames, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
|
2017-03-14 07:03:58 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
|
|
|
true, false, boo::CullMode::None);
|
2016-02-15 04:00:26 +00:00
|
|
|
|
2016-02-23 02:34:16 +00:00
|
|
|
return new struct OGLElementDataBindingFactory;
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|
|
|
|
|
2017-11-05 06:17:12 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2016-02-23 02:34:16 +00:00
|
|
|
#if BOO_HAS_VULKAN
|
2017-06-10 06:13:16 +00:00
|
|
|
struct VulkanElementDataBindingFactory : TShader<CElementGenShaders>::IDataBindingFactory
|
2016-02-23 02:34:16 +00:00
|
|
|
{
|
2017-11-06 06:58:04 +00:00
|
|
|
boo::ObjToken<boo::IShaderDataBinding>
|
|
|
|
BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
|
|
|
|
CElementGenShaders& shaders)
|
2016-02-23 02:34:16 +00:00
|
|
|
{
|
2017-06-10 06:13:16 +00:00
|
|
|
CElementGen& gen = shaders.m_gen;
|
2016-02-23 02:34:16 +00:00
|
|
|
CGenDescription* desc = gen.GetDesc();
|
|
|
|
|
2016-03-03 01:06:42 +00:00
|
|
|
CUVElement* texr = desc->x54_x40_TEXR.get();
|
|
|
|
CUVElement* tind = desc->x58_x44_TIND.get();
|
2016-02-23 02:34:16 +00:00
|
|
|
int texCount = 0;
|
2017-11-06 06:58:04 +00:00
|
|
|
boo::ObjToken<boo::ITexture> textures[3];
|
2016-02-23 02:34:16 +00:00
|
|
|
|
|
|
|
if (texr)
|
|
|
|
{
|
|
|
|
textures[0] = texr->GetValueTexture(0).GetObj()->GetBooTexture();
|
|
|
|
texCount = 1;
|
|
|
|
if (tind)
|
|
|
|
{
|
2017-11-06 06:58:04 +00:00
|
|
|
textures[1] = CGraphics::g_SpareTexture.get();
|
2016-02-23 02:34:16 +00:00
|
|
|
textures[2] = tind->GetValueTexture(0).GetObj()->GetBooTexture();
|
|
|
|
texCount = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-24 09:13:33 +00:00
|
|
|
if (gen.m_instBuf)
|
2017-06-12 18:20:07 +00:00
|
|
|
{
|
2017-11-06 06:58:04 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBuf.get()};
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2017-06-12 18:20:07 +00:00
|
|
|
if (shaders.m_regPipeline)
|
|
|
|
gen.m_normalDataBind = ctx.newShaderDataBinding(shaders.m_regPipeline, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-03-17 23:33:02 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-09-05 03:00:19 +00:00
|
|
|
if (shaders.m_regPipelineSub)
|
|
|
|
gen.m_normalSubDataBind = ctx.newShaderDataBinding(shaders.m_regPipelineSub, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-09-05 03:00:19 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-06-12 18:20:07 +00:00
|
|
|
if (shaders.m_redToAlphaPipeline)
|
|
|
|
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipeline, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-09-05 03:00:19 +00:00
|
|
|
if (shaders.m_redToAlphaPipelineSub)
|
|
|
|
gen.m_redToAlphaSubDataBind = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelineSub, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBuf.get(), nullptr, 1, uniforms,
|
2017-09-05 03:00:19 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
|
|
|
|
2017-06-12 18:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gen.m_instBufPmus)
|
|
|
|
{
|
2017-11-06 06:58:04 +00:00
|
|
|
boo::ObjToken<boo::IGraphicsBuffer> uniforms[] = {gen.m_uniformBufPmus.get()};
|
2017-06-12 18:20:07 +00:00
|
|
|
texCount = std::min(texCount, 1);
|
|
|
|
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_regPipelinePmus)
|
|
|
|
gen.m_normalDataBindPmus = ctx.newShaderDataBinding(shaders.m_regPipelinePmus, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
2017-06-24 09:13:33 +00:00
|
|
|
if (shaders.m_redToAlphaPipelinePmus)
|
|
|
|
gen.m_redToAlphaDataBindPmus = ctx.newShaderDataBinding(shaders.m_redToAlphaPipelinePmus, nullptr, nullptr,
|
2017-11-06 06:58:04 +00:00
|
|
|
gen.m_instBufPmus.get(), nullptr, 1, uniforms,
|
2017-06-12 18:20:07 +00:00
|
|
|
nullptr, texCount, textures, nullptr, nullptr);
|
|
|
|
}
|
2017-06-10 06:13:16 +00:00
|
|
|
|
|
|
|
return nullptr;
|
2016-02-23 02:34:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-10 06:13:16 +00:00
|
|
|
TShader<CElementGenShaders>::IDataBindingFactory* CElementGenShaders::Initialize(boo::VulkanDataFactory::Context& ctx)
|
2016-02-23 02:34:16 +00:00
|
|
|
{
|
|
|
|
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}
|
|
|
|
};
|
2016-03-30 19:16:01 +00:00
|
|
|
m_vtxFormatTex = ctx.newVertexFormat(9, TexFmtTex);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
};
|
2016-03-30 19:16:01 +00:00
|
|
|
m_vtxFormatIndTex = ctx.newVertexFormat(13, TexFmtIndTex);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
};
|
2016-03-30 19:16:01 +00:00
|
|
|
m_vtxFormatNoTex = ctx.newVertexFormat(5, TexFmtNoTex);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texRedToAlphaZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_texRedToAlphaNoZTest = ctx.newShaderPipeline(VS_GLSL_TEX, FS_GLSL_TEX_REDTOALPHA, m_vtxFormatTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2017-09-05 03:00:19 +00:00
|
|
|
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);
|
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_indTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_indTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_indTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_INDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_cindTexZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_cindTexNoZWrite = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_cindTexAdditive = ctx.newShaderPipeline(VS_GLSL_INDTEX, FS_GLSL_CINDTEX, m_vtxFormatIndTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexNoZTestZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, true,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexNoZTestNoZWrite = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexAdditiveZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::LEqual, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-03-30 19:16:01 +00:00
|
|
|
m_noTexAdditiveNoZTest = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_vtxFormatNoTex,
|
2017-03-10 20:52:53 +00:00
|
|
|
boo::BlendFactor::SrcAlpha, boo::BlendFactor::One,
|
2017-03-17 23:33:02 +00:00
|
|
|
boo::Primitive::TriStrips, boo::ZTest::None, false,
|
2017-03-14 07:03:58 +00:00
|
|
|
true, false, boo::CullMode::None);
|
2016-02-23 02:34:16 +00:00
|
|
|
|
|
|
|
return new struct VulkanElementDataBindingFactory;
|
|
|
|
}
|
2017-11-06 06:58:04 +00:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2016-02-23 02:34:16 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-15 04:00:26 +00:00
|
|
|
}
|