@@ -112,6 +112,7 @@ bool DeformableMaterialShader::Load()
|
||||
auto psDesc = GPUPipelineState::Description::Default;
|
||||
psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None;
|
||||
psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None;
|
||||
psDesc.VS = _shader->GetVS("VS_SplineModel");
|
||||
|
||||
#if GPU_ALLOW_TESSELLATION_SHADERS
|
||||
// Check if use tessellation (both material and runtime supports it)
|
||||
@@ -127,7 +128,6 @@ bool DeformableMaterialShader::Load()
|
||||
if (_shader->HasShader("PS_QuadOverdraw"))
|
||||
{
|
||||
// Quad Overdraw
|
||||
psDesc.VS = _shader->GetVS("VS_SplineModel");
|
||||
psDesc.PS = _shader->GetPS("PS_QuadOverdraw");
|
||||
_cache.QuadOverdraw.Init(psDesc);
|
||||
}
|
||||
@@ -142,7 +142,6 @@ bool DeformableMaterialShader::Load()
|
||||
psDesc.StencilPassOp = StencilOperation::Replace;
|
||||
|
||||
// GBuffer Pass
|
||||
psDesc.VS = _shader->GetVS("VS_SplineModel");
|
||||
psDesc.PS = _shader->GetPS("PS_GBuffer");
|
||||
_cache.Default.Init(psDesc);
|
||||
|
||||
@@ -154,7 +153,6 @@ bool DeformableMaterialShader::Load()
|
||||
_drawModes |= DrawPass::Forward;
|
||||
|
||||
// Forward Pass
|
||||
psDesc.VS = _shader->GetVS("VS_SplineModel");
|
||||
psDesc.PS = _shader->GetPS("PS_Forward");
|
||||
psDesc.DepthWriteEnable = false;
|
||||
psDesc.BlendMode = BlendingMode::AlphaBlend;
|
||||
@@ -171,6 +169,18 @@ bool DeformableMaterialShader::Load()
|
||||
break;
|
||||
}
|
||||
_cache.Default.Init(psDesc);
|
||||
|
||||
// Check if use transparent distortion pass
|
||||
if (_shader->HasShader("PS_Distortion"))
|
||||
{
|
||||
_drawModes |= DrawPass::Distortion;
|
||||
|
||||
// Accumulate Distortion Pass
|
||||
psDesc.PS = _shader->GetPS("PS_Distortion");
|
||||
psDesc.BlendMode = BlendingMode::Add;
|
||||
psDesc.DepthWriteEnable = false;
|
||||
_cache.Distortion.Init(psDesc);
|
||||
}
|
||||
}
|
||||
|
||||
// Depth Pass
|
||||
|
||||
@@ -14,6 +14,7 @@ private:
|
||||
{
|
||||
PipelineStateCache Default;
|
||||
PipelineStateCache Depth;
|
||||
PipelineStateCache Distortion;
|
||||
#if USE_EDITOR
|
||||
PipelineStateCache QuadOverdraw;
|
||||
#endif
|
||||
@@ -29,6 +30,8 @@ private:
|
||||
case DrawPass::GlobalSurfaceAtlas:
|
||||
case DrawPass::Forward:
|
||||
return &Default;
|
||||
case DrawPass::Distortion:
|
||||
return &Distortion;
|
||||
#if USE_EDITOR
|
||||
case DrawPass::QuadOverdraw:
|
||||
return &QuadOverdraw;
|
||||
@@ -42,6 +45,7 @@ private:
|
||||
{
|
||||
Default.Release();
|
||||
Depth.Release();
|
||||
Distortion.Release();
|
||||
#if USE_EDITOR
|
||||
QuadOverdraw.Release();
|
||||
#endif
|
||||
|
||||
@@ -246,7 +246,9 @@ bool MaterialGenerator::Generate(WriteStream& source, MaterialInfo& materialInfo
|
||||
ADD_FEATURE(TessellationFeature);
|
||||
if (isOpaque)
|
||||
ADD_FEATURE(DeferredShadingFeature);
|
||||
if (materialInfo.BlendMode != MaterialBlendMode::Opaque)
|
||||
if (!isOpaque && (materialInfo.FeaturesFlags & MaterialFeaturesFlags::DisableDistortion) == MaterialFeaturesFlags::None)
|
||||
ADD_FEATURE(DistortionFeature);
|
||||
if (!isOpaque)
|
||||
ADD_FEATURE(ForwardShadingFeature);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user