Ticket #4351: 4351_shadows.patch

File 4351_shadows.patch, 4.6 KB (added by Vladislav Belov, 7 years ago)

Current state

  • binaries/data/config/default.cfg

     
    7575shadowsonwater = false
    7676
    7777shadows = true
     78shadowquality = 0
    7879shadowpcf = true
    7980vsync = false
    8081particles = true
  • binaries/data/mods/public/gui/options/options.js

     
    199199                let val = +Engine.ConfigDB_GetValue("user", key);
    200200                if (key === "materialmgr.quality")
    201201                    val = val > 5 ? 2 : val > 2 ? 1 : 0;
     202                if (key === "shadowquality")
     203                    val = val + 2;
    202204                control.selected = val;
    203205                break;
    204206            case "list":
     
    219221                let val = this.selected;
    220222                if (key === "materialmgr.quality")
    221223                    val = val == 0 ? 2 : val == 1 ? 5 : 8;
     224                if (key === "shadowquality")
     225                    val = val - 2;
    222226                Engine.ConfigDB_CreateValue("user", key, val);
    223227                Engine.ConfigDB_SetChanges("user", true);
    224228                updateOptionPanel();
  • binaries/data/mods/public/gui/options/options.json

     
    123123            "label": "Shadows",
    124124            "tooltip": "Enable shadows",
    125125            "parameters": {  "config": "shadows", "renderer": "Shadows" },
    126             "dependencies": [ "shadowpcf" ]
     126            "dependencies": [ "shadowquality", "shadowpcf" ]
    127127        },
    128128        {
     129            "type": "dropdown",
     130            "label": "Shadow Quality",
     131            "tooltip": "Shadow quality. REQUIRES GAME RESTART",
     132            "parameters": { "list": [ "Very Low", "Low", "Medium", "High", "Very High" ], "config": "shadowquality" }
     133        },
     134        {
    129135            "type": "boolean",
    130136            "label": "Shadow Filtering",
    131137            "tooltip": "Smooth shadows",
  • binaries/data/mods/public/gui/options/options.xml

     
    3434            <object style="ModernLabelText" type="text" size="0 5 100% 25">
    3535                <translatableAttribute id="caption">Graphics Settings</translatableAttribute>
    3636            </object>
    37             <repeat count="21">
     37            <repeat count="22">
    3838                <object name="graphicsSetting[n]" size="0 25 100% 50" hidden="true">
    3939                    <object name="graphicsSettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/>
    4040                    <object name="graphicsSettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>
  • source/renderer/ShadowMap.cpp

     
    1 /* Copyright (C) 2013 Wildfire Games.
     1/* Copyright (C) 2016 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2525#include "lib/bits.h"
    2626#include "lib/ogl.h"
    2727#include "ps/CLogger.h"
     28#include "ps/ConfigDB.h"
    2829#include "ps/Profile.h"
    2930
    3031#include "graphics/LightEnv.h"
     
    9495    // Helper functions
    9596    void CalcShadowMatrices();
    9697    void CreateTexture();
     98
     99    // Shadow map quality (-2 - Very Low, -1 - Low, 0 - Medium, 1 - High, 2 - Ultra)
     100    int QualityLevel;
    97101};
    98102
    99103
     
    118122
    119123    // Avoid using uninitialised values in AddShadowedBound if SetupFrame wasn't called first
    120124    m->LightTransform.SetIdentity();
     125
     126    // Default quality is medium
     127    m->QualityLevel = 0;
    121128}
    122129
    123130
     
    385392    }
    386393    else
    387394    {
     395        CFG_GET_VAL("shadowquality", QualityLevel);
     396
    388397        // get shadow map size as next power of two up from view width/height
    389         Width = Height = (int)round_up_to_pow2((unsigned)std::max(g_Renderer.GetWidth(), g_Renderer.GetHeight()));
     398        int shadow_map_size = (int)round_up_to_pow2((unsigned)std::max(g_Renderer.GetWidth(), g_Renderer.GetHeight()));
     399        switch (QualityLevel)
     400        {
     401        // Very Low
     402        case -2:
     403            shadow_map_size /= 4;
     404            break;
     405        // Low
     406        case -1:
     407            shadow_map_size /= 2;
     408            break;
     409        // High
     410        case 1:
     411            shadow_map_size *= 2;
     412            break;
     413        // Ultra
     414        case 2:
     415            shadow_map_size *= 4;
     416            break;
     417        // Medium as is
     418        default:
     419            break;
     420        }
     421        Width = Height = shadow_map_size;
    390422    }
    391423    // Clamp to the maximum texture size
    392424    Width = std::min(Width, (int)ogl_max_tex_size);