| 107 | } |
| 108 | |
| 109 | bool DeformableMaterialShader::Load() |
| 110 | { |
| 111 | _drawModes = DrawPass::Depth | DrawPass::QuadOverdraw; |
| 112 | auto psDesc = GPUPipelineState::Description::Default; |
| 113 | psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; |
| 114 | psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; |
| 115 | |
| 116 | #if GPU_ALLOW_TESSELLATION_SHADERS |
| 117 | // Check if use tessellation (both material and runtime supports it) |
| 118 | const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation; |
| 119 | if (useTess) |
| 120 | { |
| 121 | psDesc.HS = _shader->GetHS("HS"); |
| 122 | psDesc.DS = _shader->GetDS("DS"); |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | #if USE_EDITOR |
| 127 | if (_shader->HasShader("PS_QuadOverdraw")) |
| 128 | { |
| 129 | // Quad Overdraw |
| 130 | psDesc.VS = _shader->GetVS("VS_SplineModel"); |
| 131 | psDesc.PS = _shader->GetPS("PS_QuadOverdraw"); |
| 132 | _cache.QuadOverdraw.Init(psDesc); |
| 133 | } |
| 134 | #endif |
| 135 | |
| 136 | if (_info.BlendMode == MaterialBlendMode::Opaque) |
| 137 | { |
| 138 | _drawModes |= DrawPass::GBuffer | DrawPass::GlobalSurfaceAtlas; |
| 139 | |
| 140 | psDesc.StencilEnable = true; |
| 141 | psDesc.StencilReadMask = 0; |
| 142 | psDesc.StencilPassOp = StencilOperation::Replace; |
| 143 | |
| 144 | // GBuffer Pass |
| 145 | psDesc.VS = _shader->GetVS("VS_SplineModel"); |
| 146 | psDesc.PS = _shader->GetPS("PS_GBuffer"); |
| 147 | _cache.Default.Init(psDesc); |
| 148 | |
| 149 | psDesc.StencilEnable = false; |
| 150 | psDesc.StencilPassOp = StencilOperation::Keep; |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | _drawModes |= DrawPass::Forward; |
| 155 | |
| 156 | // Forward Pass |
| 157 | psDesc.VS = _shader->GetVS("VS_SplineModel"); |
| 158 | psDesc.PS = _shader->GetPS("PS_Forward"); |
| 159 | psDesc.DepthWriteEnable = false; |
| 160 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 161 | switch (_info.BlendMode) |
| 162 | { |
| 163 | case MaterialBlendMode::Transparent: |
| 164 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 165 | break; |
| 166 | case MaterialBlendMode::Additive: |