| 105 | } |
| 106 | |
| 107 | bool ForwardMaterialShader::Load() |
| 108 | { |
| 109 | _drawModes = DrawPass::Depth | DrawPass::Forward | DrawPass::QuadOverdraw; |
| 110 | |
| 111 | auto psDesc = GPUPipelineState::Description::Default; |
| 112 | psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; |
| 113 | psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; |
| 114 | |
| 115 | #if GPU_ALLOW_TESSELLATION_SHADERS |
| 116 | // Check if use tessellation (both material and runtime supports it) |
| 117 | const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation; |
| 118 | if (useTess) |
| 119 | { |
| 120 | psDesc.HS = _shader->GetHS("HS"); |
| 121 | psDesc.DS = _shader->GetDS("DS"); |
| 122 | } |
| 123 | #endif |
| 124 | |
| 125 | #if USE_EDITOR |
| 126 | if (_shader->HasShader("PS_QuadOverdraw")) |
| 127 | { |
| 128 | // Quad Overdraw |
| 129 | psDesc.VS = _shader->GetVS("VS"); |
| 130 | psDesc.PS = _shader->GetPS("PS_QuadOverdraw"); |
| 131 | _cache.QuadOverdraw.Init(psDesc); |
| 132 | psDesc.VS = _shader->GetVS("VS", 1); |
| 133 | _cacheInstanced.Depth.Init(psDesc); |
| 134 | psDesc.VS = _shader->GetVS("VS_Skinned"); |
| 135 | _cache.QuadOverdrawSkinned.Init(psDesc); |
| 136 | } |
| 137 | #endif |
| 138 | |
| 139 | // Check if use transparent distortion pass |
| 140 | if (_shader->HasShader("PS_Distortion")) |
| 141 | { |
| 142 | _drawModes |= DrawPass::Distortion; |
| 143 | |
| 144 | // Accumulate Distortion Pass |
| 145 | psDesc.VS = _shader->GetVS("VS"); |
| 146 | psDesc.PS = _shader->GetPS("PS_Distortion"); |
| 147 | psDesc.BlendMode = BlendingMode::Add; |
| 148 | psDesc.DepthWriteEnable = false; |
| 149 | _cache.Distortion.Init(psDesc); |
| 150 | //psDesc.VS = _shader->GetVS("VS", 1); |
| 151 | //_cacheInstanced.Distortion.Init(psDesc); |
| 152 | psDesc.VS = _shader->GetVS("VS_Skinned"); |
| 153 | _cache.DistortionSkinned.Init(psDesc); |
| 154 | } |
| 155 | |
| 156 | // Forward Pass |
| 157 | psDesc.VS = _shader->GetVS("VS"); |
| 158 | if (psDesc.VS == nullptr) |
| 159 | return true; |
| 160 | psDesc.PS = _shader->GetPS("PS_Forward"); |
| 161 | psDesc.DepthWriteEnable = false; |
| 162 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 163 | switch (_info.BlendMode) |
| 164 | { |