| 185 | } |
| 186 | |
| 187 | bool ParticleMaterialShader::Load() |
| 188 | { |
| 189 | _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; |
| 190 | GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; |
| 191 | psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; |
| 192 | psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; |
| 193 | |
| 194 | auto vsSprite = _shader->GetVS("VS_Sprite"); |
| 195 | auto vsMesh = _shader->GetVS("VS_Model"); |
| 196 | auto vsRibbon = _shader->GetVS("VS_Ribbon"); |
| 197 | |
| 198 | #if USE_EDITOR |
| 199 | if (_shader->HasShader("PS_QuadOverdraw")) |
| 200 | { |
| 201 | // Quad Overdraw |
| 202 | psDesc.PS = _shader->GetPS("PS_QuadOverdraw"); |
| 203 | psDesc.VS = vsSprite; |
| 204 | _cacheSprite.QuadOverdraw.Init(psDesc); |
| 205 | psDesc.VS = vsMesh; |
| 206 | _cacheModel.QuadOverdraw.Init(psDesc); |
| 207 | psDesc.VS = vsRibbon; |
| 208 | _cacheRibbon.QuadOverdraw.Init(psDesc); |
| 209 | } |
| 210 | #endif |
| 211 | |
| 212 | // Check if use transparent distortion pass |
| 213 | if (_shader->HasShader("PS_Distortion")) |
| 214 | { |
| 215 | _drawModes |= DrawPass::Distortion; |
| 216 | |
| 217 | // Accumulate Distortion Pass |
| 218 | psDesc.PS = _shader->GetPS("PS_Distortion"); |
| 219 | psDesc.BlendMode = BlendingMode::Add; |
| 220 | psDesc.DepthWriteEnable = false; |
| 221 | psDesc.VS = vsSprite; |
| 222 | _cacheSprite.Distortion.Init(psDesc); |
| 223 | psDesc.VS = vsMesh; |
| 224 | _cacheModel.Distortion.Init(psDesc); |
| 225 | psDesc.VS = vsRibbon; |
| 226 | _cacheRibbon.Distortion.Init(psDesc); |
| 227 | } |
| 228 | |
| 229 | // Forward Pass |
| 230 | psDesc.PS = _shader->GetPS("PS_Forward"); |
| 231 | psDesc.DepthWriteEnable = false; |
| 232 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 233 | switch (_info.BlendMode) |
| 234 | { |
| 235 | case MaterialBlendMode::Transparent: |
| 236 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 237 | break; |
| 238 | case MaterialBlendMode::Additive: |
| 239 | psDesc.BlendMode = BlendingMode::Additive; |
| 240 | break; |
| 241 | case MaterialBlendMode::Multiply: |
| 242 | psDesc.BlendMode = BlendingMode::Multiply; |
| 243 | break; |
| 244 | } |