Ticket #1771: no_preview_shadows_08172013.patch

File no_preview_shadows_08172013.patch, 5.3 KB (added by historic_bruno, 11 years ago)

update disabling decal shadows

  • binaries/data/mods/public/shaders/arb/terrain_common.fp

     
    3636
    3737// Compute color = texture * (ambient + diffuse*shadow)
    3838// (diffuse is 2*fragment.color due to clamp-avoidance in the vertex program)
    39 #if USE_SHADOW
     39#if USE_SHADOW && !DISABLE_RECEIVE_SHADOWS
    4040  TEMP shadowBias;
    4141  TEMP biasedShdw;
    4242  MOV shadowBias.x, 0.0005;
  • binaries/data/mods/public/shaders/glsl/terrain_common.fs

     
    7070float get_shadow()
    7171{
    7272  float shadowBias = 0.0005;
    73   #if USE_SHADOW
     73  #if USE_SHADOW && !DISABLE_RECEIVE_SHADOWS
    7474    float biasedShdwZ = v_shadow.z - shadowBias;
    7575    #if USE_SHADOW_SAMPLER
    7676      #if USE_SHADOW_PCF
  • source/graphics/Decal.cpp

     
    107107    CRenderableObject::SetTransform(newTransform);
    108108    InvalidatePosition();
    109109}
     110
     111void CModelDecal::RemoveShadows()
     112{
     113    m_Decal.m_Material.AddShaderDefine("DISABLE_RECEIVE_SHADOWS", "1");
     114}
  • source/graphics/Decal.h

     
    7575    virtual void InvalidatePosition();
    7676    virtual void SetTransform(const CMatrix3D& transform);
    7777
     78    // remove shadow casting and receiving, recursively through props
     79    void RemoveShadows();
     80
    7881    /**
    7982     * Compute the terrain vertex indexes that bound the decal's
    8083     * projection onto the terrain.
  • source/graphics/Model.cpp

     
    2222#include "precompiled.h"
    2323
    2424#include "Model.h"
     25
     26#include "Decal.h"
    2527#include "ModelDef.h"
    2628#include "maths/Quaternion.h"
    2729#include "maths/BoundingBoxAligned.h"
     
    631633            m_Props[i].m_Model->ToCModel()->AddFlagsRec(flags);
    632634}
    633635
     636void CModel::RemoveShadowsRec()
     637{
     638    m_Flags &= ~MODELFLAG_CASTSHADOWS;
     639
     640    m_Material.AddShaderDefine("DISABLE_RECEIVE_SHADOWS", "1");
     641
     642    for (size_t i = 0; i < m_Props.size(); ++i)
     643    {
     644        if (m_Props[i].m_Model->ToCModel())
     645            m_Props[i].m_Model->ToCModel()->RemoveShadowsRec();
     646        else if (m_Props[i].m_Model->ToCModelDecal())
     647            m_Props[i].m_Model->ToCModelDecal()->RemoveShadows();
     648    }
     649}
     650
    634651void CModel::SetMaterial(const CMaterial &material)
    635652{
    636653    m_Material = material;
  • source/graphics/Model.h

     
    123123    int GetFlags() const { return m_Flags; }
    124124    // add object flags, recursively through props
    125125    void AddFlagsRec(int flags);
     126    // remove shadow casting and receiving, recursively through props
     127    void RemoveShadowsRec();
    126128
    127129    // recurse down tree setting dirty bits
    128130    virtual void SetDirtyRec(int dirtyflags) {
  • source/simulation2/components/CCmpTemplateManager.cpp

     
    525525    if (out.GetChild("Entity").GetChild("Obstruction").IsOk())
    526526        CParamNode::LoadXMLString(out, "<Entity><Obstruction><Active>false</Active></Obstruction></Entity>");
    527527
     528    if (out.GetChild("Entity").GetChild("VisualActor").IsOk())
     529        CParamNode::LoadXMLString(out, "<Entity><VisualActor><DisableShadows/></VisualActor></Entity>");
     530
    528531    if (!corpse)
    529532    {
    530533        // Previews should always be visible in fog-of-war/etc
  • source/simulation2/components/CCmpVisualActor.cpp

     
    121121                    "<empty/>"
    122122                "</element>"
    123123            "</optional>"
     124            "<optional>"
     125                "<element name='DisableShadows' a:help='Used internally; if present, shadows will be disabled'>"
     126                    "<empty/>"
     127                "</element>"
     128            "</optional>"
    124129            "<element name='SilhouetteDisplay'>"
    125130                "<data type='boolean'/>"
    126131            "</element>"
     
    515520
    516521                if (paramNode.GetChild("SilhouetteDisplay").ToBool())
    517522                    modelFlags |= MODELFLAG_SILHOUETTE_DISPLAY;
    518 
    519523                if (paramNode.GetChild("SilhouetteOccluder").ToBool())
    520524                    modelFlags |= MODELFLAG_SILHOUETTE_OCCLUDER;
    521525
     
    524528                    modelFlags |= MODELFLAG_IGNORE_LOS;
    525529
    526530                model.ToCModel()->AddFlagsRec(modelFlags);
     531
     532                if (paramNode.GetChild("DisableShadows").IsOk())
     533                    model.ToCModel()->RemoveShadowsRec();
    527534            }
    528535
    529536            // Initialize the model's selection shape descriptor. This currently relies on the component initialization order; the