Add transparent skinned mesh shader
This commit is contained in:
parent
85bd8c3146
commit
a696fd6dff
@ -39,6 +39,8 @@ void main(void)
|
|||||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
|
||||||
vec4 idle_position = vec4(Position, 1.);
|
vec4 idle_position = vec4(Position, 1.);
|
||||||
vec4 idle_normal = vec4(Normal, 0.);
|
vec4 idle_normal = vec4(Normal, 0.);
|
||||||
|
vec4 idle_tangent = vec4(Data1.z, Data1.w, Data2.x, 0.);
|
||||||
|
vec4 idle_bitangent = vec4(Data2.y, Data2.z, Data2.w, 0.);
|
||||||
vec4 skinned_position = vec4(0.);
|
vec4 skinned_position = vec4(0.);
|
||||||
vec4 skinned_normal = vec4(0.);
|
vec4 skinned_normal = vec4(0.);
|
||||||
vec4 skinned_tangent = vec4(0.);
|
vec4 skinned_tangent = vec4(0.);
|
||||||
|
@ -400,6 +400,8 @@ void CBatchingMesh::recalculateDestBufferBoundingBox(u32 i)
|
|||||||
case video::EVT_TANGENTS:
|
case video::EVT_TANGENTS:
|
||||||
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
((SMeshBufferTangents*)DestBuffers[i].Buffer)->recalculateBoundingBox();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ void DrawCalls::clearLists()
|
|||||||
{
|
{
|
||||||
ListBlendTransparent::getInstance()->clear();
|
ListBlendTransparent::getInstance()->clear();
|
||||||
ListAdditiveTransparent::getInstance()->clear();
|
ListAdditiveTransparent::getInstance()->clear();
|
||||||
|
ListTranslucentSkinned::getInstance()->clear();
|
||||||
ListTranslucentStandard::getInstance()->clear();
|
ListTranslucentStandard::getInstance()->clear();
|
||||||
ListTranslucentTangents::getInstance()->clear();
|
ListTranslucentTangents::getInstance()->clear();
|
||||||
ListTranslucent2TCoords::getInstance()->clear();
|
ListTranslucent2TCoords::getInstance()->clear();
|
||||||
@ -47,8 +48,11 @@ void DrawCalls::clearLists()
|
|||||||
ListAdditiveTransparentFog::getInstance()->clear();
|
ListAdditiveTransparentFog::getInstance()->clear();
|
||||||
ListDisplacement::getInstance()->clear();
|
ListDisplacement::getInstance()->clear();
|
||||||
|
|
||||||
ListMatDefault::getInstance()->clear();
|
|
||||||
ListSkinnedSolid::getInstance()->clear();
|
ListSkinnedSolid::getInstance()->clear();
|
||||||
|
ListSkinnedAlphaRef::getInstance()->clear();
|
||||||
|
ListSkinnedNormalMap::getInstance()->clear();
|
||||||
|
ListSkinnedUnlit::getInstance()->clear();
|
||||||
|
ListMatDefault::getInstance()->clear();
|
||||||
ListMatAlphaRef::getInstance()->clear();
|
ListMatAlphaRef::getInstance()->clear();
|
||||||
ListMatSphereMap::getInstance()->clear();
|
ListMatSphereMap::getInstance()->clear();
|
||||||
ListMatDetails::getInstance()->clear();
|
ListMatDetails::getInstance()->clear();
|
||||||
@ -271,6 +275,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
|
|||||||
|
|
||||||
if (!culled_for_cams[0])
|
if (!culled_for_cams[0])
|
||||||
{
|
{
|
||||||
|
for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_SKN])
|
||||||
|
{
|
||||||
|
pushVector(ListTranslucentSkinned::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans,
|
||||||
|
skinning_offset, (mesh->m_render_info && mesh->m_render_info->isTransparent() ? custom_alpha : 1.0f));
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
|
for (unsigned Mat = 0; Mat < Material::SHADERTYPE_COUNT; ++Mat)
|
||||||
{
|
{
|
||||||
if (CVS->supportsIndirectInstancingRendering())
|
if (CVS->supportsIndirectInstancingRendering())
|
||||||
|
@ -241,6 +241,14 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls,
|
|||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
if (CVS->supportsHardwareSkinning())
|
||||||
|
{
|
||||||
|
renderTransparenPass<Shaders::SkinnedTransparentShader, video::EVT_SKINNED_MESH, 4, 3, 2, 1>(
|
||||||
|
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||||
|
ListTranslucentSkinned::getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
renderTransparenPass<Shaders::TransparentShader, video::EVT_STANDARD, 3, 2, 1>(
|
renderTransparenPass<Shaders::TransparentShader, video::EVT_STANDARD, 3, 2, 1>(
|
||||||
TexUnits(RenderGeometry::TexUnit(0, true)),
|
TexUnits(RenderGeometry::TexUnit(0, true)),
|
||||||
ListTranslucentStandard::getInstance());
|
ListTranslucentStandard::getInstance());
|
||||||
|
@ -52,7 +52,6 @@ public:
|
|||||||
SHADERTYPE_ALPHA_TEST,
|
SHADERTYPE_ALPHA_TEST,
|
||||||
SHADERTYPE_ALPHA_TEST_SKINNED_MESH,
|
SHADERTYPE_ALPHA_TEST_SKINNED_MESH,
|
||||||
SHADERTYPE_ALPHA_BLEND,
|
SHADERTYPE_ALPHA_BLEND,
|
||||||
SHADERTYPE_ALPHA_BLEND_SKINNED_MESH,
|
|
||||||
SHADERTYPE_ADDITIVE,
|
SHADERTYPE_ADDITIVE,
|
||||||
SHADERTYPE_SOLID_UNLIT,
|
SHADERTYPE_SOLID_UNLIT,
|
||||||
SHADERTYPE_SOLID_UNLIT_SKINNED_MESH,
|
SHADERTYPE_SOLID_UNLIT_SKINNED_MESH,
|
||||||
|
@ -386,6 +386,16 @@ Shaders::SkinnedMeshPass2Shader::SkinnedMeshPass2Shader()
|
|||||||
5, "colorization_mask", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
5, "colorization_mask", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||||
} // SkinnedMeshPass2Shader
|
} // SkinnedMeshPass2Shader
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
Shaders::SkinnedTransparentShader::SkinnedTransparentShader()
|
||||||
|
{
|
||||||
|
if (!CVS->supportsHardwareSkinning()) return;
|
||||||
|
loadProgram(OBJECT, GL_VERTEX_SHADER, "skinning.vert",
|
||||||
|
GL_FRAGMENT_SHADER, "transparent.frag");
|
||||||
|
assignUniforms("ModelMatrix", "texture_trans", "skinning_offset", "custom_alpha");
|
||||||
|
assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED);
|
||||||
|
} // SkinnedTransparentShader
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
Shaders::TransparentShader::TransparentShader()
|
Shaders::TransparentShader::TransparentShader()
|
||||||
{
|
{
|
||||||
|
@ -173,6 +173,15 @@ public:
|
|||||||
}; // SkinnedMeshPass2Shader
|
}; // SkinnedMeshPass2Shader
|
||||||
|
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
|
class SkinnedTransparentShader : public TextureShader<SkinnedTransparentShader, 1,
|
||||||
|
core::matrix4, core::vector2df,
|
||||||
|
int, float >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SkinnedTransparentShader();
|
||||||
|
}; // SkinnedTransparentShader
|
||||||
|
|
||||||
|
// ========================================================================
|
||||||
|
|
||||||
|
|
||||||
}; // class Shaders
|
}; // class Shaders
|
||||||
|
@ -188,23 +188,26 @@ void STKAnimatedMesh::updateNoGL()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GLMesh &mesh = GLmeshes[i];
|
GLMesh &mesh = GLmeshes[i];
|
||||||
|
video::E_VERTEX_TYPE vt = mb->getVertexType();
|
||||||
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
||||||
|
|
||||||
/*if (rnd->isTransparent())
|
if (rnd->isTransparent())
|
||||||
{
|
{
|
||||||
TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material);
|
TransparentMaterial TranspMat = getTransparentMaterialFromType(type, vt, MaterialTypeParam, material);
|
||||||
TransparentMesh[TranspMat].push_back(&mesh);
|
TransparentMesh[TranspMat].push_back(&mesh);
|
||||||
}
|
}
|
||||||
else if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
else if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent())
|
||||||
{
|
{
|
||||||
if (mesh.VAOType == video::EVT_TANGENTS)
|
if (mesh.VAOType == video::EVT_SKINNED_MESH)
|
||||||
|
TransparentMesh[TM_TRANSLUCENT_SKN].push_back(&mesh);
|
||||||
|
else if (mesh.VAOType == video::EVT_TANGENTS)
|
||||||
TransparentMesh[TM_TRANSLUCENT_TAN].push_back(&mesh);
|
TransparentMesh[TM_TRANSLUCENT_TAN].push_back(&mesh);
|
||||||
else
|
else
|
||||||
TransparentMesh[TM_TRANSLUCENT_STD].push_back(&mesh);
|
TransparentMesh[TM_TRANSLUCENT_STD].push_back(&mesh);
|
||||||
}
|
}
|
||||||
else*/
|
else
|
||||||
{
|
{
|
||||||
Material::ShaderType MatType = getMeshMaterialFromType(type, mb->getVertexType(), material, NULL);
|
Material::ShaderType MatType = getMeshMaterialFromType(type, vt, material, NULL);
|
||||||
MeshSolidMaterial[MatType].push_back(&mesh);
|
MeshSolidMaterial[MatType].push_back(&mesh);
|
||||||
}
|
}
|
||||||
if (m_skinned_mesh) ssmb->VertexType = prev_type;
|
if (m_skinned_mesh) ssmb->VertexType = prev_type;
|
||||||
@ -252,7 +255,7 @@ void STKAnimatedMesh::updateGL()
|
|||||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
|
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(type);
|
||||||
GLMesh &mesh = GLmeshes[i];
|
GLMesh &mesh = GLmeshes[i];
|
||||||
|
|
||||||
if (1)//!rnd->isTransparent())
|
if (!rnd->isTransparent())
|
||||||
{
|
{
|
||||||
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb);
|
||||||
Material* material2 = NULL;
|
Material* material2 = NULL;
|
||||||
|
@ -71,9 +71,13 @@ Material::ShaderType getMeshMaterialFromType(video::E_MATERIAL_TYPE material_typ
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
TransparentMaterial getTransparentMaterialFromType(video::E_MATERIAL_TYPE type,
|
TransparentMaterial getTransparentMaterialFromType(video::E_MATERIAL_TYPE type,
|
||||||
|
video::E_VERTEX_TYPE tp,
|
||||||
f32 MaterialTypeParam,
|
f32 MaterialTypeParam,
|
||||||
Material* material)
|
Material* material)
|
||||||
{
|
{
|
||||||
|
if (tp == video::EVT_SKINNED_MESH)
|
||||||
|
return TM_TRANSLUCENT_SKN;
|
||||||
|
|
||||||
if (type == Shaders::getShader(ES_DISPLACE))
|
if (type == Shaders::getShader(ES_DISPLACE))
|
||||||
{
|
{
|
||||||
if (CVS->isDefferedEnabled())
|
if (CVS->isDefferedEnabled())
|
||||||
@ -378,8 +382,8 @@ static void setTexture(GLMesh &mesh, unsigned i, bool is_srgb,
|
|||||||
{
|
{
|
||||||
if (!mesh.textures[i])
|
if (!mesh.textures[i])
|
||||||
{
|
{
|
||||||
//Log::error("STKMesh", "Missing texture %d for material %s", i,
|
Log::error("STKMesh", "Missing texture %d for material %s", i,
|
||||||
// mat_name.c_str());
|
mat_name.c_str());
|
||||||
// use unicolor texture to replace missing texture
|
// use unicolor texture to replace missing texture
|
||||||
mesh.textures[i] =
|
mesh.textures[i] =
|
||||||
getUnicolorTexture(video::SColor(255, 127, 127, 127));
|
getUnicolorTexture(video::SColor(255, 127, 127, 127));
|
||||||
|
@ -37,6 +37,7 @@ enum TransparentMaterial
|
|||||||
TM_DEFAULT,
|
TM_DEFAULT,
|
||||||
TM_ADDITIVE,
|
TM_ADDITIVE,
|
||||||
TM_DISPLACEMENT,
|
TM_DISPLACEMENT,
|
||||||
|
TM_TRANSLUCENT_SKN,
|
||||||
TM_TRANSLUCENT_STD,
|
TM_TRANSLUCENT_STD,
|
||||||
TM_TRANSLUCENT_TAN,
|
TM_TRANSLUCENT_TAN,
|
||||||
TM_TRANSLUCENT_2TC,
|
TM_TRANSLUCENT_2TC,
|
||||||
@ -197,6 +198,12 @@ class ListAdditiveTransparent : public MiscList<ListAdditiveTransparent,
|
|||||||
core::vector2df, float>
|
core::vector2df, float>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
class ListTranslucentSkinned : public MiscList<ListTranslucentSkinned,
|
||||||
|
GLMesh *, core::matrix4,
|
||||||
|
core::vector2df, int, float>
|
||||||
|
{};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
class ListTranslucentStandard : public MiscList<ListTranslucentStandard,
|
class ListTranslucentStandard : public MiscList<ListTranslucentStandard,
|
||||||
GLMesh *, core::matrix4,
|
GLMesh *, core::matrix4,
|
||||||
@ -243,6 +250,7 @@ Material::ShaderType getMeshMaterialFromType(video::E_MATERIAL_TYPE MaterialType
|
|||||||
Material* layer2Material);
|
Material* layer2Material);
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
TransparentMaterial getTransparentMaterialFromType(video::E_MATERIAL_TYPE,
|
TransparentMaterial getTransparentMaterialFromType(video::E_MATERIAL_TYPE,
|
||||||
|
video::E_VERTEX_TYPE tp,
|
||||||
f32 MaterialTypeParam,
|
f32 MaterialTypeParam,
|
||||||
Material* material);
|
Material* material);
|
||||||
|
|
||||||
|
@ -206,6 +206,7 @@ void STKMeshSceneNode::updateNoGL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLMesh &mesh = GLmeshes[i];
|
GLMesh &mesh = GLmeshes[i];
|
||||||
|
video::E_VERTEX_TYPE vt = mb->getVertexType();
|
||||||
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() && !rnd->isTransparent())
|
if (mesh.m_render_info != NULL && mesh.m_render_info->isTransparent() && !rnd->isTransparent())
|
||||||
{
|
{
|
||||||
@ -217,7 +218,7 @@ void STKMeshSceneNode::updateNoGL()
|
|||||||
}
|
}
|
||||||
else if (rnd->isTransparent())
|
else if (rnd->isTransparent())
|
||||||
{
|
{
|
||||||
TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material);
|
TransparentMaterial TranspMat = getTransparentMaterialFromType(type, vt, MaterialTypeParam, material);
|
||||||
if (!immediate_draw)
|
if (!immediate_draw)
|
||||||
TransparentMesh[TranspMat].push_back(&mesh);
|
TransparentMesh[TranspMat].push_back(&mesh);
|
||||||
else
|
else
|
||||||
@ -229,7 +230,7 @@ void STKMeshSceneNode::updateNoGL()
|
|||||||
Material* material2 = NULL;
|
Material* material2 = NULL;
|
||||||
if (mb->getMaterial().getTexture(1) != NULL)
|
if (mb->getMaterial().getTexture(1) != NULL)
|
||||||
material2 = material_manager->getMaterialFor(mb->getMaterial().getTexture(1), mb);
|
material2 = material_manager->getMaterialFor(mb->getMaterial().getTexture(1), mb);
|
||||||
Material::ShaderType MatType = getMeshMaterialFromType(type, mb->getVertexType(), material, material2);
|
Material::ShaderType MatType = getMeshMaterialFromType(type, vt, material, material2);
|
||||||
if (!immediate_draw)
|
if (!immediate_draw)
|
||||||
MeshSolidMaterial[MatType].push_back(&mesh);
|
MeshSolidMaterial[MatType].push_back(&mesh);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user