Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "Headers/SceneEnvironmentProbePool.h"
#include "Scenes/Headers/Scene.h"

namespace Divide {

SceneEnvironmentProbePool::SceneEnvironmentProbePool(Scene& parentScene)
    : SceneComponent(parentScene),
      _isSorted(false)
{
}

SceneEnvironmentProbePool::~SceneEnvironmentProbePool()
{
    MemoryManager::DELETE_VECTOR(_envProbes);
}

const vectorImpl<EnvironmentProbe*>& SceneEnvironmentProbePool::getNearestSorted() {
    if (!_isSorted) {
        _sortedProbes.resize(0);
        const vec3<F32>& camPosition = _parentScene.renderState().getCamera().getEye();

        _sortedProbes.insert(std::cend(_sortedProbes), std::cbegin(_envProbes), std::cend(_envProbes));

        auto sortFunc = [&camPosition](EnvironmentProbe* a, EnvironmentProbe* b) -> bool {
            return a->distanceSqTo(camPosition) < b->distanceSqTo(camPosition);
        };

        std::sort(std::begin(_sortedProbes), std::end(_sortedProbes), sortFunc);
        U32 lowerLimit = std::min(Config::MAX_REFLECTIVE_PROBES_PER_PASS, to_uint(_sortedProbes.size()));
        _sortedProbes.erase(std::begin(_sortedProbes) + lowerLimit, std::end(_sortedProbes));
        _isSorted = true;
    }

    return _sortedProbes;
}


EnvironmentProbe* SceneEnvironmentProbePool::addInfiniteProbe(const vec3<F32>& position) {
    EnvironmentProbe* probe = MemoryManager_NEW EnvironmentProbe(EnvironmentProbe::ProbeType::TYPE_INFINITE);
    probe->setBounds(position, 1000.0f);
    _envProbes.push_back(probe);
    _isSorted = false;
    return probe;
}

EnvironmentProbe* SceneEnvironmentProbePool::addLocalProbe(const vec3<F32>& bbMin,
                                                           const vec3<F32>& bbMax) {
    EnvironmentProbe* probe = MemoryManager_NEW EnvironmentProbe(EnvironmentProbe::ProbeType::TYPE_LOCAL);
    probe->setBounds(bbMin, bbMax);
    _envProbes.push_back(probe);
    _isSorted = false;
    return probe;
}

void SceneEnvironmentProbePool::removeProbe(EnvironmentProbe*& probe) {
    if (probe != nullptr) {
        I64 probeGUID = probe->getGUID();
        _envProbes.erase(std::remove_if(std::begin(_envProbes), std::end(_envProbes),
                                       [&probeGUID](EnvironmentProbe* probe)
                                            -> bool { return probe->getGUID() == probeGUID; }),
                         std::end(_envProbes));
        probe = nullptr;
        _isSorted = false;
    }
}

void SceneEnvironmentProbePool::debugDraw(RenderSubPassCmds& subPassesInOut) {
    for (EnvironmentProbe* probe : _envProbes) {
        probe->debugDraw(subPassesInOut);
    }
}

}; //namespace Divide

Commits for Divide-Framework/trunk/Source Code/Scenes/SceneEnvironmentProbePool.cpp

Diff revisions: vs.
Revision Author Commited Message
781 Diff Diff IonutCava picture IonutCava Wed 12 Oct, 2016 16:03:46 +0000

[IonutCava]
- ShaderComputeQueue <-> Material shader request bug fix (element stuck in QUEUED state)
- More Camera class cleanups
- Add a method of removing EnvironmentProbes from their Pool

777 Diff Diff IonutCava picture IonutCava Fri 07 Oct, 2016 16:14:48 +0000

[IonutCava]
- Continue to implement CommandBuffer / RenderPass / RenderSubPass system.
— Rendering artefacts are still present.

749 IonutCava picture IonutCava Mon 04 Jul, 2016 16:01:34 +0000

[IonutCava]
- Added initial environment mapping code:
— Allow adding, per scene, of multiple environment probes that generate cube map reflections
— Support 2 types of probes: infinite (such as sky only probes) and local. Local probes use an AABB that will later be used for parallax correction
— Probes are held in a scene specific pool, can be updated at different rates and their results can be passed on to materials (if materials don’t need specific reflection systems such as for water or mirrors)
- ToDo:
— Blend between probes (currently, only the closes one is selected)
— Reduce VRAM usage
— Set as fallback for screen space reflections