Use alphatest as a fallback shader for unlit

Adjust graph shader when advanced pipeline off, and no srgb prefilled
texture when advanced pipeline off
This commit is contained in:
Benau 2018-01-22 13:27:21 +08:00
parent 8fa5ad46c9
commit 86393ba0a9
5 changed files with 15 additions and 5 deletions

View File

@ -31,7 +31,7 @@
(default N).
srgb: Sample mesh texture layers in srgb or not (in 6 Ys / Ns), when
advanced lighting is off, srgb will always be false
advanced lighting is off, srgb will always be false,
default (Y Y N N N N), even if any texture layer is unused in
shader, you cannot skip it from the above Y / N array.
@ -85,6 +85,8 @@
(cannot be empty).
srgb: Sample in srgb or not (specify in Y/N, default is N).
When advanced lighting is off, srgb will always be
false.
sampler: nearest, nearest_clamped, bilinear,
bilinear_clamped, trilinear, trilinear_clamped

View File

@ -1,5 +1,5 @@
<spshader>
<shader-info name="unlit" fallback-shader="solid" use-alpha-channel="Y"/>
<shader-info name="unlit" fallback-shader="alphatest" use-alpha-channel="Y"/>
<first-pass vertex-shader="sp_pass.vert"
fragment-shader="sp_unlit.frag" skinned-mesh-shader="sp_skinning.vert">
</first-pass>

View File

@ -353,10 +353,12 @@ void SPShaderManager::loadPassInfo(const XMLNode* pass, PassInfo& pi)
prefilled_texture->get("name", &name);
prefilled_texture->get("file", &file);
prefilled_texture->get("srgb", &srgb_props);
#ifndef SERVER_ONLY
if (!srgb_props.empty())
{
srgb = srgb_props == "Y";
srgb = srgb_props == "Y" && CVS->isDefferedEnabled();
}
#endif
prefilled_texture->get("sampler", &sampler_props);
if (!sampler_props.empty() &&
m_official_sampler_types.find(sampler_props) !=

View File

@ -348,8 +348,14 @@ void Graph::createMeshSP(bool show_invisible, bool enable_transparency,
spmb->setSPMVertices(vertices);
spmb->setIndices(indices);
spmb->recalculateBoundingBox();
spmb->setSTKMaterial(material_manager->getDefaultSPMaterial(
enable_transparency ? "alphablend" : "unlit"));
std::string shader_name = enable_transparency ? "alphablend" : "unlit";
#ifndef SERVER_ONLY
if (!CVS->isDefferedEnabled())
{
shader_name = "solid";
}
#endif
spmb->setSTKMaterial(material_manager->getDefaultSPMaterial(shader_name));
spm->addSPMeshBuffer(spmb);
spm->setBoundingBox(spmb->getBoundingBox());
#endif