| 131 | } |
| 132 | |
| 133 | bool TerrainMaterialShader::Load() |
| 134 | { |
| 135 | GPUPipelineState::Description psDesc = GPUPipelineState::Description::Default; |
| 136 | psDesc.DepthEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthTest) == MaterialFeaturesFlags::None; |
| 137 | psDesc.DepthWriteEnable = (_info.FeaturesFlags & MaterialFeaturesFlags::DisableDepthWrite) == MaterialFeaturesFlags::None; |
| 138 | |
| 139 | psDesc.StencilEnable = true; |
| 140 | psDesc.StencilReadMask = 0; |
| 141 | psDesc.StencilPassOp = StencilOperation::Replace; |
| 142 | |
| 143 | #if GPU_ALLOW_TESSELLATION_SHADERS |
| 144 | // Check if use tessellation (both material and runtime supports it) |
| 145 | const bool useTess = _info.TessellationMode != TessellationMethod::None && GPUDevice::Instance->Limits.HasTessellation; |
| 146 | if (useTess) |
| 147 | { |
| 148 | psDesc.HS = _shader->GetHS("HS"); |
| 149 | psDesc.DS = _shader->GetDS("DS"); |
| 150 | } |
| 151 | #endif |
| 152 | |
| 153 | // Support blending but then use only emissive channel |
| 154 | switch (_info.BlendMode) |
| 155 | { |
| 156 | case MaterialBlendMode::Transparent: |
| 157 | psDesc.BlendMode = BlendingMode::AlphaBlend; |
| 158 | break; |
| 159 | case MaterialBlendMode::Additive: |
| 160 | psDesc.BlendMode = BlendingMode::Additive; |
| 161 | break; |
| 162 | case MaterialBlendMode::Multiply: |
| 163 | psDesc.BlendMode = BlendingMode::Multiply; |
| 164 | break; |
| 165 | default: ; |
| 166 | } |
| 167 | |
| 168 | // GBuffer Pass |
| 169 | psDesc.VS = _shader->GetVS("VS"); |
| 170 | psDesc.PS = _shader->GetPS("PS_GBuffer"); |
| 171 | _cache.Default.Init(psDesc); |
| 172 | |
| 173 | // GBuffer Pass with lightmap (use pixel shader permutation for USE_LIGHTMAP=1) |
| 174 | psDesc.PS = _shader->GetPS("PS_GBuffer", 1); |
| 175 | _cache.DefaultLightmap.Init(psDesc); |
| 176 | |
| 177 | #if USE_EDITOR |
| 178 | if (_shader->HasShader("PS_QuadOverdraw")) |
| 179 | { |
| 180 | // Quad Overdraw |
| 181 | psDesc.PS = _shader->GetPS("PS_QuadOverdraw"); |
| 182 | _cache.QuadOverdraw.Init(psDesc); |
| 183 | } |
| 184 | #endif |
| 185 | |
| 186 | // Depth Pass |
| 187 | psDesc.CullMode = CullMode::TwoSided; |
| 188 | psDesc.BlendMode = BlendingMode::Opaque; |
| 189 | psDesc.DepthClipEnable = false; |
| 190 | psDesc.DepthWriteEnable = true; |
nothing calls this directly
no test coverage detected