TIND element shader working

This commit is contained in:
Jack Andersen 2016-02-24 19:09:45 -10:00
parent 23688360c9
commit d044adf7e1
6 changed files with 22 additions and 31 deletions

View File

@ -29,6 +29,7 @@ void ViewManager::BuildTestPART(pshag::IObjectStore& objStore)
m_particleView.reset(new ParticleView(*this, m_viewResources, *m_rootView));
m_lineRenderer.reset(new pshag::CLineRenderer(pshag::CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true));
//m_rootView->accessContentViews().clear();
m_rootView->accessContentViews().push_back(m_particleView.get());
m_rootView->updateSize();
}

View File

@ -207,7 +207,7 @@ SClipScreenRect CGraphics::ClipScreenRectFromVS(const Zeus::CVector3f& p1,
int height = maxY2 - minY2;
return {true, minX2, minY2, width, height, width,
minX2 / float(g_ViewportResolution.x), maxX2 / float(g_ViewportResolution.x),
minY2 / float(g_ViewportResolution.y), maxY2 / float(g_ViewportResolution.y)};
1.f - maxY2 / float(g_ViewportResolution.y), 1.f - minY2 / float(g_ViewportResolution.y)};
}

View File

@ -209,10 +209,10 @@ public:
{
g_BooMainCommandQueue->setShaderDataBinding(binding);
}
static void ResolveSpareTexture(const SClipScreenRect& rect)
static void ResolveSpareTexture(const SClipScreenRect& rect, bool color, bool depth)
{
boo::SWindowRect wrect = {rect.x4_left, rect.x8_top, rect.xc_width, rect.x10_height};
g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true);
g_BooMainCommandQueue->resolveBindTexture(g_SpareTexture, wrect, true, color, depth);
}
static void DrawInstances(size_t start, size_t count, size_t instCount)
{

View File

@ -220,7 +220,7 @@ struct SParticleInstanceIndTex
Zeus::CVector4f pos[4];
Zeus::CColor color;
Zeus::CVector4f texrTindUVs[4];
Zeus::CVector2f sceneUVs[4];
Zeus::CVector4f sceneUVs;
};
static std::vector<SParticleInstanceIndTex> g_instIndTexData;
@ -361,7 +361,6 @@ CElementGen::CElementGen(const TToken<CGenDescription>& gen,
CIntElement* maxpElem = desc->x28_MAXP.get();
if (maxpElem)
maxpElem->GetValue(x50_curFrame, x70_MAXP);
x70_MAXP = 1;
x2c_particleLists.reserve(x70_MAXP);
if (x28_orientType == EModelOrientationType::One)
@ -527,7 +526,6 @@ bool CElementGen::InternalUpdate(double dt)
CIntElement* maxpElem = desc->x28_MAXP.get();
if (maxpElem)
maxpElem->GetValue(x50_curFrame, x70_MAXP);
x70_MAXP = 1;
UpdateExistingParticles();
@ -1993,7 +1991,7 @@ void CElementGen::RenderParticlesIndirectTexture()
if (!clipRect.x0_valid)
continue;
CGraphics::ResolveSpareTexture(clipRect);
CGraphics::ResolveSpareTexture(clipRect, true, false);
g_instIndTexData.emplace_back();
SParticleInstanceIndTex& inst = g_instIndTexData.back();
@ -2002,14 +2000,11 @@ void CElementGen::RenderParticlesIndirectTexture()
inst.pos[2] = Zeus::CVector4f{viewPoint.x + size, viewPoint.y, viewPoint.z - size, 1.f};
inst.pos[3] = Zeus::CVector4f{viewPoint.x - size, viewPoint.y, viewPoint.z - size, 1.f};
inst.color = particle.x34_color;
inst.texrTindUVs[0] = Zeus::CVector4f{uvs.xMax, uvs.yMax, uvsInd.xMax, uvsInd.yMax};
inst.texrTindUVs[0] = Zeus::CVector4f{uvs.xMax, uvs.yMax, uvsInd.xMin, uvsInd.yMin};
inst.texrTindUVs[1] = Zeus::CVector4f{uvs.xMin, uvs.yMax, uvsInd.xMin, uvsInd.yMax};
inst.texrTindUVs[2] = Zeus::CVector4f{uvs.xMax, uvs.yMin, uvsInd.xMax, uvsInd.yMin};
inst.texrTindUVs[3] = Zeus::CVector4f{uvs.xMin, uvs.yMin, uvsInd.xMin, uvsInd.yMin};
inst.sceneUVs[0] = {clipRect.x1c_uvXMax, clipRect.x24_uvYMax};
inst.sceneUVs[1] = {clipRect.x18_uvXMin, clipRect.x24_uvYMax};
inst.sceneUVs[2] = {clipRect.x1c_uvXMax, clipRect.x20_uvYMin};
inst.sceneUVs[3] = {clipRect.x18_uvXMin, clipRect.x20_uvYMin};
inst.texrTindUVs[3] = Zeus::CVector4f{uvs.xMin, uvs.yMin, uvsInd.xMax, uvsInd.yMax};
inst.sceneUVs = Zeus::CVector4f{clipRect.x18_uvXMin, clipRect.x24_uvYMax, clipRect.x1c_uvXMax, clipRect.x20_uvYMin};
}
m_instBuf->load(g_instIndTexData.data(), g_instIndTexData.size() * sizeof(SParticleInstanceIndTex));

View File

@ -76,7 +76,7 @@ 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 vec2 uvsInScene[4];\n"
"layout(location=9) in vec4 uvsInScene;\n"
"\n"
"UBINDING0 uniform ParticleUniform\n"
"{\n"
@ -87,8 +87,8 @@ BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec4 uvScene;\n"
" vec2 uvTexr;\n"
" vec2 uvScene;\n"
" vec2 uvTind;\n"
"};\n"
"\n"
@ -96,8 +96,8 @@ BOO_GLSL_BINDING_HEAD
"void main()\n"
"{\n"
" vtf.color = colorIn * moduColor;\n"
" vtf.uvScene = uvsInScene;\n"
" vtf.uvTexr = uvsInTexrTind[gl_VertexID].xy;\n"
" vtf.uvScene = uvsInScene[gl_VertexID];\n"
" vtf.uvTind = uvsInTexrTind[gl_VertexID].zw;\n"
" gl_Position = mvp * posIn[gl_VertexID];\n"
"}\n";
@ -108,8 +108,8 @@ BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec4 uvScene;\n"
" vec2 uvTexr;\n"
" vec2 uvScene;\n"
" vec2 uvTind;\n"
"};\n"
"\n"
@ -118,12 +118,11 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D texs[3];\n"
"void main()\n"
"{\n"
" vec2 tindTexel = texture(texs[2], vtf.uvTind).ba;\n"
" vec4 sceneTexel = texture(texs[1], vtf.uvScene + tindTexel);\n"
" vec2 tindTexel = texture(texs[2], vtf.uvTind).zw;\n"
" vec4 sceneTexel = texture(texs[1], mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
" vec4 texrTexel = texture(texs[0], vtf.uvTexr);\n"
" //colorOut = vtf.color * sceneTexel + texrTexel;\n"
" colorOut = sceneTexel + vec4(0.5, 0.0, 0.0, 1.0);\n"
" //colorOut.a = vtf.color.a * texrTexel.a;\n"
" colorOut = vtf.color * sceneTexel + texrTexel;\n"
" colorOut.a = vtf.color.a * texrTexel.a;\n"
"}\n";
static const char* FS_GLSL_CINDTEX =
@ -132,8 +131,8 @@ BOO_GLSL_BINDING_HEAD
"struct VertToFrag\n"
"{\n"
" vec4 color;\n"
" vec4 uvScene;\n"
" vec2 uvTexr;\n"
" vec2 uvScene;\n"
" vec2 uvTind;\n"
"};\n"
"\n"
@ -142,10 +141,9 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D texs[3];\n"
"void main()\n"
"{\n"
" vec2 tindTexel = texture(texs[2], vtf.uvTind).ba;\n"
" vec4 sceneTexel = texture(texs[1], vtf.uvScene + tindTexel);\n"
" vec2 tindTexel = texture(texs[2], vtf.uvTind).zw;\n"
" vec4 sceneTexel = texture(texs[1], mix(vtf.uvScene.xy, vtf.uvScene.zw, tindTexel));\n"
" colorOut = vtf.color * sceneTexel * texture(texs[0], vtf.uvTexr);\n"
" //colorOut = vec4(1.0,1.0,1.0,1.0);\n"
"}\n";
static const char* VS_GLSL_NOTEX =
@ -222,11 +220,8 @@ struct OGLElementDataBindingFactory : CElementGenShaders::IDataBindingFactory
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 4},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 5},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 6},
{gen.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 7}
};
vtxFmt = CGraphics::g_BooFactory->newVertexFormat(13, TexFmtIndTex);
vtxFmt = CGraphics::g_BooFactory->newVertexFormat(10, TexFmtIndTex);
}
else
{

2
hecl

@ -1 +1 @@
Subproject commit eafdeee33bdb7d7a1230d687565c0ef5c0b2d6a2
Subproject commit ffb693e3d8682ca6c74747f97bfb92d3365cc863