Allow normal map karts to be used in ghost race
Also split ghost karts out of additive shader, so fixed issues like "drivers are facing backwards", "water in abyss affects ghost karts" Todo: maybe transparency depend on current track color?
This commit is contained in:
parent
929b9b5c20
commit
23a1b08efe
19
data/shaders/ghost_karts.frag
Normal file
19
data/shaders/ghost_karts.frag
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifdef Use_Bindless_Texture
|
||||||
|
layout(bindless_sampler) uniform sampler2D tex;
|
||||||
|
#else
|
||||||
|
uniform sampler2D tex;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
in vec2 uv;
|
||||||
|
in vec4 color;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 Color = texture(tex, uv);
|
||||||
|
#ifdef Use_Bindless_Texture
|
||||||
|
Color.xyz = pow(Color.xyz, vec3(2.2));
|
||||||
|
#endif
|
||||||
|
Color.xyz *= pow(color.xyz, vec3(2.2));
|
||||||
|
FragColor = vec4(Color.rgb * 0.5, 0.5);
|
||||||
|
}
|
@ -1555,14 +1555,24 @@ static video::ITexture *displaceTex = 0;
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void IrrDriver::renderTransparent()
|
void IrrDriver::renderTransparent()
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
irr_driver->setPhase(TRANSPARENT_PASS);
|
irr_driver->setPhase(TRANSPARENT_PASS);
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
renderTransparenPass<Shaders::GhostKartsShader, video::EVT_STANDARD, 2, 1>(
|
||||||
|
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||||
|
ListGhostKart::getInstance());
|
||||||
|
|
||||||
|
renderTransparenPass<Shaders::GhostKartsShader, video::EVT_TANGENTS, 2, 1>(
|
||||||
|
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||||
|
ListGhostKartTangents::getInstance());
|
||||||
|
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
for (unsigned i = 0; i < ImmediateDrawList::getInstance()->size(); i++)
|
for (unsigned i = 0; i < ImmediateDrawList::getInstance()->size(); i++)
|
||||||
ImmediateDrawList::getInstance()->at(i)->render();
|
ImmediateDrawList::getInstance()->at(i)->render();
|
||||||
|
|
||||||
|
@ -369,6 +369,15 @@ Shaders::TransparentShader::TransparentShader()
|
|||||||
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||||
} // TransparentShader
|
} // TransparentShader
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
Shaders::GhostKartsShader::GhostKartsShader()
|
||||||
|
{
|
||||||
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert",
|
||||||
|
GL_FRAGMENT_SHADER, "ghost_karts.frag");
|
||||||
|
assignUniforms("ModelMatrix", "TextureMatrix");
|
||||||
|
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||||
|
} // GhostKartsShader
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
Shaders::TransparentFogShader::TransparentFogShader()
|
Shaders::TransparentFogShader::TransparentFogShader()
|
||||||
{
|
{
|
||||||
|
@ -126,6 +126,14 @@ public:
|
|||||||
TransparentShader();
|
TransparentShader();
|
||||||
}; // TransparentShader
|
}; // TransparentShader
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
class GhostKartsShader : public TextureShader<GhostKartsShader, 1,
|
||||||
|
core::matrix4, core::matrix4 >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GhostKartsShader();
|
||||||
|
}; // TransparentShader
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
class TransparentFogShader : public TextureShader<TransparentFogShader, 1,
|
class TransparentFogShader : public TextureShader<TransparentFogShader, 1,
|
||||||
core::matrix4, core::matrix4, float, float,
|
core::matrix4, core::matrix4, float, float,
|
||||||
|
@ -165,7 +165,10 @@ void STKAnimatedMesh::updateNoGL()
|
|||||||
}
|
}
|
||||||
else if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
else if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
||||||
{
|
{
|
||||||
TransparentMesh[TM_ADDITIVE].push_back(&mesh);
|
if (mesh.VAOType == video::EVT_TANGENTS)
|
||||||
|
TransparentMesh[TM_GHOST_KART_TANGENTS].push_back(&mesh);
|
||||||
|
else
|
||||||
|
TransparentMesh[TM_GHOST_KART].push_back(&mesh);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,8 @@ enum TransparentMaterial
|
|||||||
TM_DEFAULT,
|
TM_DEFAULT,
|
||||||
TM_ADDITIVE,
|
TM_ADDITIVE,
|
||||||
TM_DISPLACEMENT,
|
TM_DISPLACEMENT,
|
||||||
|
TM_GHOST_KART,
|
||||||
|
TM_GHOST_KART_TANGENTS,
|
||||||
TM_COUNT
|
TM_COUNT
|
||||||
}; // TransparentMaterial
|
}; // TransparentMaterial
|
||||||
|
|
||||||
@ -206,6 +208,18 @@ class ListAdditiveTransparent : public MiscList<ListAdditiveTransparent,
|
|||||||
core::matrix4>
|
core::matrix4>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class ListGhostKart : public MiscList<ListGhostKart,
|
||||||
|
GLMesh *, core::matrix4,
|
||||||
|
core::matrix4>
|
||||||
|
{};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class ListGhostKartTangents : public MiscList<ListGhostKartTangents,
|
||||||
|
GLMesh *, core::matrix4,
|
||||||
|
core::matrix4>
|
||||||
|
{};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
class ListBlendTransparentFog : public MiscList<ListBlendTransparentFog,
|
class ListBlendTransparentFog : public MiscList<ListBlendTransparentFog,
|
||||||
GLMesh *, core::matrix4,
|
GLMesh *, core::matrix4,
|
||||||
|
@ -209,10 +209,11 @@ void STKMeshSceneNode::updateNoGL()
|
|||||||
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
||||||
if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
||||||
{
|
{
|
||||||
if (!immediate_draw)
|
assert(!immediate_draw);
|
||||||
TransparentMesh[TM_ADDITIVE].push_back(&mesh);
|
if (mesh.VAOType == video::EVT_TANGENTS)
|
||||||
|
TransparentMesh[TM_GHOST_KART_TANGENTS].push_back(&mesh);
|
||||||
else
|
else
|
||||||
additive = true;
|
TransparentMesh[TM_GHOST_KART].push_back(&mesh);
|
||||||
}
|
}
|
||||||
else if (rnd->isTransparent())
|
else if (rnd->isTransparent())
|
||||||
{
|
{
|
||||||
|
@ -344,6 +344,10 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
|
|||||||
for (GLMesh *mesh : node->TransparentMesh[TM_ADDITIVE])
|
for (GLMesh *mesh : node->TransparentMesh[TM_ADDITIVE])
|
||||||
pushVector(ListAdditiveTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix);
|
pushVector(ListAdditiveTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix);
|
||||||
}
|
}
|
||||||
|
for (GLMesh *mesh : node->TransparentMesh[TM_GHOST_KART])
|
||||||
|
pushVector(ListGhostKart::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix);
|
||||||
|
for (GLMesh *mesh : node->TransparentMesh[TM_GHOST_KART_TANGENTS])
|
||||||
|
pushVector(ListGhostKartTangents::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix);
|
||||||
for (GLMesh *mesh : node->TransparentMesh[TM_DISPLACEMENT])
|
for (GLMesh *mesh : node->TransparentMesh[TM_DISPLACEMENT])
|
||||||
pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation());
|
pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation());
|
||||||
|
|
||||||
@ -606,6 +610,8 @@ void IrrDriver::PrepareDrawCalls(scene::ICameraSceneNode *camnode)
|
|||||||
windDir = getWindDir();
|
windDir = getWindDir();
|
||||||
ListBlendTransparent::getInstance()->clear();
|
ListBlendTransparent::getInstance()->clear();
|
||||||
ListAdditiveTransparent::getInstance()->clear();
|
ListAdditiveTransparent::getInstance()->clear();
|
||||||
|
ListGhostKart::getInstance()->clear();
|
||||||
|
ListGhostKartTangents::getInstance()->clear();
|
||||||
ListBlendTransparentFog::getInstance()->clear();
|
ListBlendTransparentFog::getInstance()->clear();
|
||||||
ListAdditiveTransparentFog::getInstance()->clear();
|
ListAdditiveTransparentFog::getInstance()->clear();
|
||||||
ListDisplacement::getInstance()->clear();
|
ListDisplacement::getInstance()->clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user