mirror of https://github.com/AxioDL/metaforce.git
Merge branch 'master' of https://github.com/AxioDL/urde
This commit is contained in:
commit
806cd54b75
|
@ -103,7 +103,7 @@ struct HLSLLineDataBindingFactory : CLineRendererShaders::IDataBindingFactory
|
||||||
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf};
|
boo::IGraphicsBuffer* uniforms[] = {renderer.m_uniformBuf};
|
||||||
|
|
||||||
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf,
|
renderer.m_shaderBind = ctx.newShaderDataBinding(pipeline, nullptr, renderer.m_vertBuf,
|
||||||
nullptr, nullptr, 1, uniforms,
|
nullptr, nullptr, 1, uniforms, nullptr,
|
||||||
texCount, textures);
|
texCount, textures);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,7 +89,6 @@ private:
|
||||||
|
|
||||||
/* urde addition: boo! */
|
/* urde addition: boo! */
|
||||||
boo::GraphicsDataToken m_gfxToken;
|
boo::GraphicsDataToken m_gfxToken;
|
||||||
std::unique_ptr<u8[]> m_uniformData;
|
|
||||||
size_t m_uniformDataSize = 0;
|
size_t m_uniformDataSize = 0;
|
||||||
boo::IGraphicsBufferD* m_uniformBuffer = nullptr;
|
boo::IGraphicsBufferD* m_uniformBuffer = nullptr;
|
||||||
std::vector<std::vector<boo::IShaderDataBinding*>> m_shaderDataBindings;
|
std::vector<std::vector<boo::IShaderDataBinding*>> m_shaderDataBindings;
|
||||||
|
|
|
@ -105,7 +105,6 @@ void CBooModel::BuildGfxToken()
|
||||||
|
|
||||||
/* Allocate resident buffer */
|
/* Allocate resident buffer */
|
||||||
m_uniformDataSize = uniBufSize;
|
m_uniformDataSize = uniBufSize;
|
||||||
m_uniformData.reset(new u8[uniBufSize]);
|
|
||||||
m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
|
m_uniformBuffer = ctx.newDynamicBuffer(boo::BufferUse::Uniform, uniBufSize, 1);
|
||||||
|
|
||||||
boo::IGraphicsBuffer* bufs[] = {m_uniformBuffer, m_uniformBuffer, m_uniformBuffer};
|
boo::IGraphicsBuffer* bufs[] = {m_uniformBuffer, m_uniformBuffer, m_uniformBuffer};
|
||||||
|
@ -410,7 +409,8 @@ void CBooModel::UVAnimationBuffer::Update(u8*& bufOut, const MaterialSet* matSet
|
||||||
|
|
||||||
void CBooModel::UpdateUniformData() const
|
void CBooModel::UpdateUniformData() const
|
||||||
{
|
{
|
||||||
u8* dataOut = m_uniformData.get();
|
u8* dataOut = reinterpret_cast<u8*>(m_uniformBuffer->map(m_uniformDataSize));
|
||||||
|
u8* dataCur = dataOut;
|
||||||
|
|
||||||
if (m_skinBankCount)
|
if (m_skinBankCount)
|
||||||
{
|
{
|
||||||
|
@ -419,47 +419,47 @@ void CBooModel::UpdateUniformData() const
|
||||||
{
|
{
|
||||||
for (size_t w=0 ; w<m_weightVecCount*4 ; ++w)
|
for (size_t w=0 ; w<m_weightVecCount*4 ; ++w)
|
||||||
{
|
{
|
||||||
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
mv = CGraphics::g_GXModelView.toMatrix4f();
|
mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
}
|
}
|
||||||
for (size_t w=0 ; w<m_weightVecCount*4 ; ++w)
|
for (size_t w=0 ; w<m_weightVecCount*4 ; ++w)
|
||||||
{
|
{
|
||||||
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
}
|
}
|
||||||
zeus::CMatrix4f& proj = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& proj = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
|
|
||||||
dataOut = m_uniformData.get() + ROUND_UP_256(dataOut - m_uniformData.get());
|
dataCur = dataOut + ROUND_UP_256(dataCur - dataOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Non-Skinned */
|
/* Non-Skinned */
|
||||||
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& mv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
mv = CGraphics::g_GXModelView.toMatrix4f();
|
mv = CGraphics::g_GXModelView.toMatrix4f();
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
|
|
||||||
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& mvinv = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
mvinv = CGraphics::g_GXModelViewInvXpose.toMatrix4f();
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
|
|
||||||
zeus::CMatrix4f& proj = reinterpret_cast<zeus::CMatrix4f&>(*dataOut);
|
zeus::CMatrix4f& proj = reinterpret_cast<zeus::CMatrix4f&>(*dataCur);
|
||||||
proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
proj = CGraphics::GetPerspectiveProjectionMatrix(true);
|
||||||
dataOut += sizeof(zeus::CMatrix4f);
|
dataCur += sizeof(zeus::CMatrix4f);
|
||||||
|
|
||||||
dataOut = m_uniformData.get() + ROUND_UP_256(dataOut - m_uniformData.get());
|
dataCur = dataOut + ROUND_UP_256(dataCur - dataOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
UVAnimationBuffer::Update(dataOut, x4_matSet);
|
UVAnimationBuffer::Update(dataCur, x4_matSet);
|
||||||
|
|
||||||
CModelShaders::LightingUniform& lightingOut = reinterpret_cast<CModelShaders::LightingUniform&>(*dataOut);
|
CModelShaders::LightingUniform& lightingOut = reinterpret_cast<CModelShaders::LightingUniform&>(*dataCur);
|
||||||
lightingOut = m_lightingData;
|
lightingOut = m_lightingData;
|
||||||
|
|
||||||
m_uniformBuffer->load(m_uniformData.get(), m_uniformDataSize);
|
m_uniformBuffer->unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBooModel::DrawAlpha(const CModelFlags& flags) const
|
void CBooModel::DrawAlpha(const CModelFlags& flags) const
|
||||||
|
|
|
@ -3,10 +3,48 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const char* LightingHLSL =
|
||||||
|
"struct Light\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 pos;\n"
|
||||||
|
" float4 dir;\n"
|
||||||
|
" float4 color;\n"
|
||||||
|
" float4 linAtt;\n"
|
||||||
|
" float4 angAtt;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"cbuffer LightingUniform : register(b2)\n"
|
||||||
|
"{\n"
|
||||||
|
" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n"
|
||||||
|
" float4 ambient;\n"
|
||||||
|
"};\n"
|
||||||
|
"\n"
|
||||||
|
"static float4 LightingFunc(float4 mvPosIn, float4 mvNormIn)\n"
|
||||||
|
"{\n"
|
||||||
|
" float4 ret = ambient;\n"
|
||||||
|
" \n"
|
||||||
|
" for (int i=0 ; i<" _XSTR(URDE_MAX_LIGHTS) " ; ++i)\n"
|
||||||
|
" {\n"
|
||||||
|
" float3 delta = mvPosIn.xyz - lights[i].pos.xyz;\n"
|
||||||
|
" float dist = length(delta);\n"
|
||||||
|
" float angDot = saturate(dot(normalize(delta), lights[i].dir.xyz));\n"
|
||||||
|
" float att = 1.0 / (lights[i].linAtt[2] * dist * dist +\n"
|
||||||
|
" lights[i].linAtt[1] * dist +\n"
|
||||||
|
" lights[i].linAtt[0]);\n"
|
||||||
|
" float angAtt = lights[i].angAtt[2] * angDot * angDot +\n"
|
||||||
|
" lights[i].angAtt[1] * angDot +\n"
|
||||||
|
" lights[i].angAtt[0];\n"
|
||||||
|
" ret += lights[i].color * saturate(angAtt) * att * saturate(dot(normalize(-delta), mvNormIn.xyz));\n"
|
||||||
|
" }\n"
|
||||||
|
" \n"
|
||||||
|
" return saturate(ret);\n"
|
||||||
|
"}\n";
|
||||||
|
|
||||||
hecl::Runtime::ShaderCacheExtensions
|
hecl::Runtime::ShaderCacheExtensions
|
||||||
CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat)
|
CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat)
|
||||||
{
|
{
|
||||||
hecl::Runtime::ShaderCacheExtensions ext(plat);
|
hecl::Runtime::ShaderCacheExtensions ext(plat);
|
||||||
|
ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {}, 0, nullptr);
|
||||||
return ext;
|
return ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -219,11 +219,11 @@ struct D3DElementDataBindingFactory : CElementGenShaders::IDataBindingFactory
|
||||||
if (regPipeline)
|
if (regPipeline)
|
||||||
gen.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr, nullptr,
|
gen.m_normalDataBind = ctx.newShaderDataBinding(regPipeline, nullptr, nullptr,
|
||||||
gen.m_instBuf, nullptr, 1, uniforms,
|
gen.m_instBuf, nullptr, 1, uniforms,
|
||||||
texCount, textures);
|
nullptr, texCount, textures);
|
||||||
if (redToAlphaPipeline)
|
if (redToAlphaPipeline)
|
||||||
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, nullptr,
|
gen.m_redToAlphaDataBind = ctx.newShaderDataBinding(redToAlphaPipeline, nullptr, nullptr,
|
||||||
gen.m_instBuf, nullptr, 1, uniforms,
|
gen.m_instBuf, nullptr, 1, uniforms,
|
||||||
texCount, textures);
|
nullptr, texCount, textures);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 115b998e207dfaf095a987dbe0e21fb40e4f0e52
|
Subproject commit a50a7ac3685ebaf5bd5c7a5c31493710a8f8f125
|
Loading…
Reference in New Issue