MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / UpdateShaderSuffix

Function UpdateShaderSuffix

Source/Main/scenegraph.cpp:463–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461extern VBOContainer quad_index_vbo;
462
463static void UpdateShaderSuffix(SceneGraph* scenegraph, Object::DrawType object_draw_type) {
464 const int kShaderStrSize = 1024;
465 char buf[2][kShaderStrSize];
466 char* shader_str[2] = {buf[0], buf[1]};
467 FormatString(shader_str[0], kShaderStrSize, "");
468 if (object_draw_type == Object::kFullDraw) {
469 if (g_simple_shadows || !g_level_shadows) {
470 FormatString(shader_str[1], kShaderStrSize, "%s #SIMPLE_SHADOW", shader_str[0]);
471 std::swap(shader_str[0], shader_str[1]);
472 }
473 if (scenegraph->light_probe_collection.probe_lighting_enabled &&
474 scenegraph->light_probe_collection.light_probe_buffer_object_id != -1 &&
475 !scenegraph->light_probe_collection.light_probes.empty()) {
476 FormatString(shader_str[1], kShaderStrSize, "%s #CAN_USE_LIGHT_PROBES", shader_str[0]);
477 std::swap(shader_str[0], shader_str[1]);
478 }
479 if (g_albedo_only) {
480 FormatString(shader_str[1], kShaderStrSize, "%s #ALBEDO_ONLY", shader_str[0]);
481 std::swap(shader_str[0], shader_str[1]);
482 }
483 if (g_simple_water) {
484 FormatString(shader_str[1], kShaderStrSize, "%s #SIMPLE_WATER", shader_str[0]);
485 std::swap(shader_str[0], shader_str[1]);
486 }
487 if (g_disable_fog) {
488 FormatString(shader_str[1], kShaderStrSize, "%s #DISABLE_FOG", shader_str[0]);
489 std::swap(shader_str[0], shader_str[1]);
490 }
491 if (g_no_reflection_capture) {
492 FormatString(shader_str[1], kShaderStrSize, "%s #NO_REFLECTION_CAPTURE", shader_str[0]);
493 std::swap(shader_str[0], shader_str[1]);
494 }
495 if (g_no_detailmaps) {
496 FormatString(shader_str[1], kShaderStrSize, "%s #NO_DETAILMAPS", shader_str[0]);
497 std::swap(shader_str[0], shader_str[1]);
498 }
499 if (g_no_decals) {
500 FormatString(shader_str[1], kShaderStrSize, "%s #NO_DECALS", shader_str[0]);
501 std::swap(shader_str[0], shader_str[1]);
502 }
503 if (config["ssao"].toNumber<bool>()) {
504 FormatString(shader_str[1], kShaderStrSize, "%s #SSAO_TEST", shader_str[0]);
505 std::swap(shader_str[0], shader_str[1]);
506 }
507 if (config["volume_shadows"].toNumber<bool>()) {
508 FormatString(shader_str[1], kShaderStrSize, "%s #VOLUME_SHADOWS", shader_str[0]);
509 std::swap(shader_str[0], shader_str[1]);
510 }
511 }
512 if (object_draw_type == Object::kFullDraw || object_draw_type == Object::kDrawDepthOnly || object_draw_type == Object::kDrawDepthNoAA || Object::kDrawAllShadowCascades) {
513 static int ubo_batch_size_multiplier = 1;
514 static GLint max_ubo_size = -1;
515 if (max_ubo_size == -1) {
516 glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &max_ubo_size);
517
518 if (max_ubo_size >= 131072) {
519 ubo_batch_size_multiplier = 8;
520 } else if (max_ubo_size >= 65536) {

Callers 3

DrawMethod · 0.85
DrawDepthMapMethod · 0.85
PreloadForDrawTypeMethod · 0.85

Calls 7

FormatStringFunction · 0.85
HasParamMethod · 0.80
simple_fogMethod · 0.80
swapFunction · 0.50
emptyMethod · 0.45
validMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected