| 2994 | } |
| 2995 | |
| 2996 | void SceneGraph::PreloadShaders() { |
| 2997 | LOGI << "Preloading shaders..." << std::endl; |
| 2998 | PROFILER_ZONE(g_profiler_ctx, "Preload shaders"); |
| 2999 | // There is no easy way to call DetailObjectSurface::GetShaderNames, so do it here for now |
| 3000 | const char* detail_object_names[6] = |
| 3001 | { |
| 3002 | "envobject #DETAIL_OBJECT", "envobject #DETAIL_OBJECT #PLANT", "envobject #DETAIL_OBJECT #PLANT #LESS_PLANT_MOVEMENT", "envobject #DETAIL_OBJECT #TERRAIN", "envobject #DETAIL_OBJECT #TERRAIN #PLANT", "envobject #DETAIL_OBJECT #TERRAIN #PLANT #LESS_PLANT_MOVEMENT"}; |
| 3003 | |
| 3004 | for (auto& detail_object_name : detail_object_names) { |
| 3005 | const int kShaderStrSize = 1024; |
| 3006 | char buf[2][kShaderStrSize]; |
| 3007 | char* shader_str[2] = {buf[0], buf[1]}; |
| 3008 | |
| 3009 | FormatString(shader_str[0], kShaderStrSize, "%s", detail_object_name); |
| 3010 | if (!Graphics::Instance()->config_.detail_object_decals()) { |
| 3011 | FormatString(shader_str[1], kShaderStrSize, "%s %s", shader_str[0], "#NO_DECALS"); |
| 3012 | std::swap(shader_str[0], shader_str[1]); |
| 3013 | } |
| 3014 | if (!Graphics::Instance()->config_.detail_object_shadows()) { |
| 3015 | FormatString(shader_str[1], kShaderStrSize, "%s %s", shader_str[0], "#NO_DETAIL_OBJECT_SHADOWS"); |
| 3016 | std::swap(shader_str[0], shader_str[1]); |
| 3017 | } |
| 3018 | preload_shaders[shader_str[0]] = kFullDraw | kDrawDepthOnly; |
| 3019 | } |
| 3020 | |
| 3021 | GetParticleShaderNames(preload_shaders); |
| 3022 | Engine::Instance()->GetShaderNames(preload_shaders); |
| 3023 | Graphics::Instance()->GetShaderNames(preload_shaders); |
| 3024 | sky->GetShaderNames(preload_shaders); |
| 3025 | flares.GetShaderNames(preload_shaders); |
| 3026 | const PreloadType preload_types[6] = { |
| 3027 | kDrawDepthOnly, kDrawAllShadowCascades, kDrawDepthNoAA, kFullDraw, kWireframe, kDecal}; |
| 3028 | for (auto preload_type : preload_types) |
| 3029 | PreloadForDrawType(preload_shaders, preload_type); |
| 3030 | |
| 3031 | // Load everything that isn't any of the above types |
| 3032 | Shaders* shaders = Shaders::Instance(); |
| 3033 | for (auto& preload_shader : preload_shaders) { |
| 3034 | if ((preload_shader.second & kPreloadTypeAll) == 0) { |
| 3035 | Shaders::OptionalShaders optional = Shaders::kNone; |
| 3036 | if (preload_shader.second & kOptionalGeometry) |
| 3037 | optional = Shaders::kGeometry; |
| 3038 | else if (preload_shader.second & kOptionalTessellation) |
| 3039 | optional = Shaders::kTesselation; |
| 3040 | shaders->createProgram(shaders->returnProgram(preload_shader.first, optional)); |
| 3041 | } |
| 3042 | } |
| 3043 | } |
| 3044 | |
| 3045 | void SceneGraph::LoadReflectionCaptureCubemaps() { |
| 3046 | PROFILER_ZONE(g_profiler_ctx, "Load reflection capture cubemaps"); |
no test coverage detected