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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
#include "Headers\Vegetation.h"

#include "Core/Headers/ParamHandler.h"
#include "Managers/Headers/SceneManager.h"
#include "Managers/Headers/CameraManager.h"
#include "Graphs/Headers/SceneGraphNode.h"
#include "Hardware/Video/Headers/GFXDevice.h"
#include "Hardware/Video/Headers/RenderStateBlock.h"
#include "Geometry/Material/Headers/Material.h"
#include "Environment/Terrain/Headers/Terrain.h"
#include "Environment/Terrain/Headers/TerrainChunk.h"
#include "Environment/Terrain/Quadtree/Headers/Quadtree.h"
#include "Environment/Terrain/Quadtree/Headers/QuadtreeNode.h"
#include "Hardware/Video/Buffers/VertexBuffer/Headers/VertexBuffer.h"

namespace Divide {

bool Vegetation::_staticDataUpdated = false;

Vegetation::Vegetation(const VegetationDetails& details) : SceneNode(details.name, TYPE_VEGETATION_GRASS),
    _billboardCount(details.billboardCount),
    _grassDensity(details.grassDensity),
    _grassScale(details.grassScale),
    _treeScale(details.treeScale),
    _treeDensity(details.treeDensity),
    _grassBillboards(details.grassBillboards),
    _terrain(details.parentTerrain),
    _render(false),
    _success(false),
    _culledFinal(false),
    _shadowMapped(true),
    _terrainChunk(nullptr),
    _instanceCountGrass(0),
    _instanceCountTrees(0),
    _grassStateBlockHash(0),
    _stateRefreshIntervalBuffer(0ULL),
    _stateRefreshInterval(getSecToUs(1)) ///<Every second?
{
	_threadedLoadComplete = false;
	_stopLoadingRequest = false;
    _readBuffer = 1;
    _writeBuffer = 0;

    _map.create(details.map);
    _grassShaderName = details.grassShaderName;
    _grassGPUBuffer[0] = GFX_DEVICE.newGVD(false);
    _grassGPUBuffer[1] = GFX_DEVICE.newGVD(false);
    _treeGPUBuffer[0] = GFX_DEVICE.newGVD(false);
    _treeGPUBuffer[1] = GFX_DEVICE.newGVD(false);
    _grassMatrices = GFX_DEVICE.newSB(true);

    _cullDrawCommand   = GenericDrawCommand(API_POINTS,     0, 1);
    _renderDrawCommand = GenericDrawCommand(TRIANGLE_STRIP, 0, 12 * 3);

    memset(_instanceRoutineIdx, 0, CullType_PLACEHOLDER * sizeof(U32));

    ResourceDescriptor instanceCullShader("instanceCull");
    instanceCullShader.setThreadedLoading(false);
    instanceCullShader.setId(3);
    _cullShader = CreateResource<ShaderProgram>(instanceCullShader);
}

Vegetation::~Vegetation() {
    PRINT_FN(Locale::get("UNLOAD_VEGETATION_BEGIN"), getName().c_str());
    _stopLoadingRequest = true;
    U32 timer = 0;
	while (!_threadedLoadComplete){
		// wait for the loading thread to finish first;
		std::this_thread::sleep_for(std::chrono::milliseconds(10));
		timer += 10;
		if (timer > 3000) {
			break;
		}
	}
    assert(_threadedLoadComplete);
    _grassPositions.clear();
    RemoveResource(_cullShader);

    MemoryManager::DELETE( _grassGPUBuffer[0] );
    MemoryManager::DELETE( _grassGPUBuffer[1] );
    MemoryManager::DELETE( _treeGPUBuffer[0] );
    MemoryManager::DELETE( _treeGPUBuffer[1] );
    MemoryManager::DELETE( _grassMatrices );
    PRINT_FN(Locale::get("UNLOAD_VEGETATION_END"));
}

void Vegetation::initialize( TerrainChunk* const terrainChunk ) {
    assert(terrainChunk);
    assert(_map.data() != nullptr);

    _terrainChunk = terrainChunk;
    
    _cullShader->Uniform("ObjectExtent", vec3<F32>(1.0f, 1.0f, 1.0f));
    _cullShader->UniformTexture("HiZBuffer", 0);
    _cullShader->Uniform("dvd_frustumBias", 12.5f);
    _instanceRoutineIdx[PASS_THROUGH]             = _cullShader->GetSubroutineIndex(VERTEX_SHADER, "PassThrough");
    _instanceRoutineIdx[INSTANCE_CLOUD_REDUCTION] = _cullShader->GetSubroutineIndex(VERTEX_SHADER, "InstanceCloudReduction");
    _instanceRoutineIdx[HI_Z_CULL]                = _cullShader->GetSubroutineIndex(VERTEX_SHADER, "HiZOcclusionCull");

    RenderStateBlockDescriptor transparent;
    transparent.setCullMode(CULL_MODE_CW);
    //transparent.setBlend(true);
    _grassStateBlockHash = GFX_DEVICE.getOrCreateStateBlock( transparent );

    ResourceDescriptor vegetationMaterial("vegetationMaterial" + getName());
    Material* vegMaterial = CreateResource<Material>(vegetationMaterial);

    vegMaterial->setDiffuse(DefaultColors::WHITE());
    vegMaterial->setAmbient(DefaultColors::WHITE() / 3);
    vegMaterial->setSpecular(vec4<F32>(0.1f, 0.1f, 0.1f, 1.0f));
    vegMaterial->setShininess(5.0f);
    vegMaterial->setShadingMode(Material::SHADING_BLINN_PHONG);
    vegMaterial->addShaderDefines("SKIP_TEXTURES");
    vegMaterial->setShaderProgram(_grassShaderName, FINAL_STAGE, true);
    vegMaterial->setShaderProgram(_grassShaderName + ".Shadow", SHADOW_STAGE, true);
    vegMaterial->setShaderProgram(_grassShaderName + ".PrePass", Z_PRE_PASS_STAGE, true);
    vegMaterial->addCustomTexture(_grassBillboards, ShaderProgram::TEXTURE_UNIT0);
    vegMaterial->setShaderLoadThreaded(false);
    vegMaterial->dumpToFile(false);
    setMaterialTpl(vegMaterial);

    Kernel* kernel = Application::getInstance().getKernel();
    _generateVegetation.reset(kernel->AddTask(0, 
                                              1, 
                                              DELEGATE_BIND(&Vegetation::generateGrass, this), 
                                              DELEGATE_BIND(&Vegetation::uploadGrassData, this)));
	_generateVegetation->startTask();
    setState(RES_LOADED);
}

namespace{
    enum BufferUsage {
        UnculledPositionBuffer = 0,
        CulledPositionBuffer = 1,
        UnculledSizeBuffer = 2,
        CulledSizeBuffer = 3,
        CulledInstanceBuffer = 4,
        BufferUsage_PLACEHOLDER = 5
    };

    const U32 posLocation   = 10;
    const U32 scaleLocation = 11;
    const U32 instLocation  = 12;
    const U32 instanceDiv = 1;
};

void Vegetation::uploadGrassData(){
    if (_grassPositions.empty()){
        _threadedLoadComplete = true;
		return;
    }

    static const vec2<F32> pos000(cosf(RADIANS(0.000f)), sinf(RADIANS(0.000f)));
    static const vec2<F32> pos120(cosf(RADIANS(120.0f)), sinf(RADIANS(120.0f)));
    static const vec2<F32> pos240(cosf(RADIANS(240.0f)), sinf(RADIANS(240.0f)));

    static const vec3<F32> vertices[] = {
        vec3<F32>(-pos000.x, 0.0f, -pos000.y), 
        vec3<F32>(-pos000.x, 1.0f, -pos000.y), 
        vec3<F32>( pos000.x, 1.0f,  pos000.y), 
        vec3<F32>( pos000.x, 0.0f,  pos000.y),

        vec3<F32>(-pos120.x, 0.0f, -pos120.y), 
        vec3<F32>(-pos120.x, 1.0f, -pos120.y), 
        vec3<F32>( pos120.x, 1.0f,  pos120.y), 
        vec3<F32>( pos120.x, 0.0f,  pos120.y),

        vec3<F32>(-pos240.x, 0.0f, -pos240.y), 
        vec3<F32>(-pos240.x, 1.0f, -pos240.y), 
        vec3<F32>( pos240.x, 1.0f,  pos240.y), 
        vec3<F32>( pos240.x, 0.0f,  pos240.y)
    };

    static const U32 indices[] = { 2, 1, 0, 2, 0, 1, 2, 0, 3, 2, 3, 0 };

    static const vec2<F32> texcoords[] = { vec2<F32>(0.0f, 0.99f), 
                                           vec2<F32>(0.0f, 0.01f), 
                                           vec2<F32>(1.0f, 0.01f), 
                                           vec2<F32>(1.0f, 0.99f) };

    vectorImpl<vec3<F32> > grassBlades;
    vectorImpl<vec2<F32> > texCoord;

    U32 indexOffset = 0;
    for (U8 j = 0; j < 3; ++j) {
        indexOffset = (j * 4);
        for (U8 l = 0; l < 12; ++l) {
            grassBlades.push_back(vertices[indices[l] + indexOffset]);
            texCoord.push_back(texcoords[(indices[l] + indexOffset) % 4]);
        }
    }
    
    static vectorImpl<mat3<F32> > rotationMatrices;
    if (rotationMatrices.empty()){
        vectorImpl<F32 > angles;
        angles.resize(18, 0.0f);
        for (U8 i = 0; i < 18; ++i){
            F32 temp = random(360.0f);
            while (std::find(angles.begin(), angles.end(), temp) != angles.end()){
                temp = random(360.0f);
            }
            angles[i] = temp;
        }

        mat3<F32> temp;
        for (U8 i = 0; i < 18; ++i){
            temp.identity();
            temp.rotate_y(angles[i]);
            rotationMatrices.push_back(temp);
        }
    }

    Material* mat = getMaterialTpl();
    for (U8 i = 0; i < 3; ++i){
        ShaderProgram* const shaderProg = mat->getShaderInfo(i == 0 ? FINAL_STAGE : 
                                                                      (i == 1 ? SHADOW_STAGE : 
                                                                                Z_PRE_PASS_STAGE)).getProgram();

        shaderProg->Uniform("positionOffsets", grassBlades);
        shaderProg->Uniform("texCoordOffsets", texCoord);
        shaderProg->Uniform("rotationMatrices", rotationMatrices);
        shaderProg->Uniform("lod_metric", 100.0f);
        shaderProg->UniformTexture("texDiffuseGrass", 0);
    }
    
    for(U8 i = 0; i < 2; ++i){
        GenericVertexData* buffer = _grassGPUBuffer[i];

        buffer->Create(BufferUsage_PLACEHOLDER, 3);
        // position culled will be generated using transform feedback using shader output 'posLocation' 
        // writing to buffer "CulledPositionBuffer"
        buffer->SetFeedbackBuffer(CulledPositionBuffer, 0); 
        buffer->SetFeedbackBuffer(CulledSizeBuffer,     1);
        buffer->SetFeedbackBuffer(CulledInstanceBuffer, 2);

        buffer->SetBuffer(UnculledPositionBuffer, _instanceCountGrass,   sizeof(vec4<F32>), 3, &_grassPositions[0], false, false);
        buffer->SetBuffer(UnculledSizeBuffer,     _instanceCountGrass,   sizeof(F32),       3, &_grassScales[0],    false, false);
        buffer->SetBuffer(CulledPositionBuffer,   _instanceCountGrass*3, sizeof(vec4<F32>), 3, NULL,                true,  false); 
        buffer->SetBuffer(CulledSizeBuffer,       _instanceCountGrass*3, sizeof(F32),       3, NULL,                true,  false);
        buffer->SetBuffer(CulledInstanceBuffer,   _instanceCountGrass*3, sizeof(I32),       3, NULL,                true,  false);

        buffer->getDrawAttribDescriptor(posLocation).set(CulledPositionBuffer,   instanceDiv, 4, false, 0, 0, FLOAT_32);
        buffer->getDrawAttribDescriptor(scaleLocation).set(CulledSizeBuffer,     instanceDiv, 1, false, 0, 0, FLOAT_32);
        buffer->getDrawAttribDescriptor(instLocation).set( CulledInstanceBuffer, instanceDiv, 1, false, 0, 0, SIGNED_INT);
        buffer->getFdbkAttribDescriptor(posLocation).set(UnculledPositionBuffer, instanceDiv, 4, false, 0, 0, FLOAT_32);
        buffer->getFdbkAttribDescriptor(scaleLocation).set(UnculledSizeBuffer,   instanceDiv, 1, false, 0, 0, FLOAT_32);

        /*
        _grassMatrices->Create(false, false, (I32)_grassMatricesTemp.size(), sizeof(_grassMatricesTemp[0]));
        _grassMatrices->UpdateData(0, _grassMatricesTemp.size() * sizeof(_grassMatricesTemp[0]), &_grassMatricesTemp[0]);
        _grassMatrices->bind(10);
        _grassMatricesTemp.clear();
        */

        buffer->toggleDoubleBufferedQueries(false);
    }

    _grassPositions.clear();
    _grassScales.clear();

    _render = _threadedLoadComplete = true;
}

void Vegetation::sceneUpdate(const U64 deltaTime, SceneGraphNode* const sgn, SceneState& sceneState){
    if(_threadedLoadComplete && !_success){
        generateTrees();
        sceneState.getRenderState().getCameraMgr().addCameraUpdateListener(DELEGATE_BIND(&Vegetation::gpuCull, this));
        _success = true;
    }
      
    if(!_render || !_success) return;

    //Query shadow state every "_stateRefreshInterval" microseconds
    if (_stateRefreshIntervalBuffer >= _stateRefreshInterval){
        if(!_staticDataUpdated){
            _windX = sceneState.getWindDirX();
            _windZ = sceneState.getWindDirZ();
            _windS = sceneState.getWindSpeed();
            Material* mat = sgn->getComponent<RenderingComponent>()->getMaterialInstance();
            for (U8 i = 0; i < 3; ++i){
                RenderStage stage = (i == 0 ? FINAL_STAGE : (i == 1 ? SHADOW_STAGE : Z_PRE_PASS_STAGE));
                mat->getShaderInfo(stage).getProgram()->Uniform("grassScale",/* _grassSize*/1.0f);
            }
            _stateRefreshIntervalBuffer -= _stateRefreshInterval;
            _cullShader->Uniform("dvd_visibilityDistance", sceneState.getGrassVisibility());
            _staticDataUpdated = true;
        }
    }
    _stateRefreshIntervalBuffer += deltaTime;

    _writeBuffer = (_writeBuffer + 1) % 2;
    _readBuffer = (_writeBuffer + 1) % 2;
    _culledFinal = false;
}

U32 Vegetation::getQueryID(){
    switch (GFX_DEVICE.getRenderStage()){
        case SHADOW_STAGE: return 0;
        case REFLECTION_STAGE: return 1;
        default: return 2;
    };
}

void Vegetation::gpuCull(){
    U32 queryId = getQueryID();

    if (GFX_DEVICE.is2DRendering()) return;

    bool draw = false;
    switch (queryId){
        case 0/*SHADOW_STAGE*/: {
            draw = LightManager::getInstance().currentShadowPass() == 0;
            _culledFinal = false;
        }break;
        case 1/*REFLECTION_STAGE*/:{
            draw = true;
            _culledFinal = false;
        }break;
        default:{
            draw = !_culledFinal;
            _culledFinal = true;
        }break;
    }

    if (draw && _threadedLoadComplete && _terrainChunk->getLoD() == 0){
        GenericVertexData* buffer = _grassGPUBuffer[_writeBuffer];
        //_cullShader->SetSubroutine(VERTEX_SHADER, _instanceRoutineIdx[HI_Z_CULL]);
        _cullShader->Uniform("cullType", /*queryId*/(U32)INSTANCE_CLOUD_REDUCTION);

        GFX_DEVICE.toggleRasterization(false);
        GFX_DEVICE.getRenderTarget(GFXDevice::RENDER_TARGET_DEPTH)->Bind(0, TextureDescriptor::Depth);
        buffer->BindFeedbackBufferRange(CulledPositionBuffer, _instanceCountGrass * queryId, _instanceCountGrass);
        buffer->BindFeedbackBufferRange(CulledSizeBuffer,     _instanceCountGrass * queryId, _instanceCountGrass);
        buffer->BindFeedbackBufferRange(CulledInstanceBuffer, _instanceCountGrass * queryId, _instanceCountGrass);

        _cullDrawCommand.instanceCount(_instanceCountGrass);
        _cullDrawCommand.queryID(queryId);
        _cullDrawCommand.drawToBuffer(true);
        _cullDrawCommand.shaderProgram(_cullShader);
        _cullDrawCommand.sourceBuffer(buffer);

        GFX_DEVICE.submitRenderCommand(_cullDrawCommand);

        //_cullDrawCommand.setInstanceCount(_instanceCountTrees);
        //_cullDrawCommand.sourceBuffer(_treeGPUBuffer);
        //GFX_DEVICE.submitRenderCommand(_cullDrawCommand);
        GFX_DEVICE.toggleRasterization(true);
    }
}

void Vegetation::getDrawCommands(SceneGraphNode* const sgn, 
                                 const RenderStage& renderStage, 
                                 SceneRenderState& sceneRenderState, 
                                 vectorImpl<GenericDrawCommand>& drawCommandsOut) {
    GenericVertexData* buffer = _grassGPUBuffer[_readBuffer];
    U32 queryId = getQueryID();
    //gpuCull();

    I32 instanceCount = buffer->GetFeedbackPrimitiveCount(queryId);
    if (instanceCount == 0) {
        return;
    }
    buffer->getDrawAttribDescriptor(posLocation).offset(_instanceCountGrass * queryId);
    buffer->getDrawAttribDescriptor(scaleLocation).offset(_instanceCountGrass * queryId);
    buffer->getDrawAttribDescriptor(instLocation).offset(_instanceCountGrass * queryId);

    RenderingComponent* const renderable = sgn->getComponent<RenderingComponent>();
    assert(renderable != nullptr);

    _renderDrawCommand.renderWireframe(renderable->renderWireframe());
    _renderDrawCommand.stateHash(_grassStateBlockHash);
    _renderDrawCommand.instanceCount(instanceCount);
    _renderDrawCommand.LoD(1);
    _renderDrawCommand.shaderProgram(renderable->getDrawShader(renderStage));
    _renderDrawCommand.sourceBuffer(buffer);
    drawCommandsOut.push_back(_renderDrawCommand);
}

bool Vegetation::onDraw(SceneGraphNode* const sgn, const RenderStage& renderStage){
    _staticDataUpdated = false;
    return !(!_render || 
             !_success || 
             !_threadedLoadComplete || 
             _terrainChunk->getLoD() > 0 || 
             (LightManager::getInstance().currentShadowPass() > 0 && 
              GFX_DEVICE.isCurrentRenderStage(SHADOW_STAGE)));
}

void Vegetation::render(SceneGraphNode* const sgn, 
                        const SceneRenderState& sceneRenderState, 
                        const RenderStage& currentRenderStage) {
    GFX_DEVICE.submitRenderCommand(_renderDrawCommand);
}

void Vegetation::generateTrees(){

}

void Vegetation::generateGrass(){
    const vec2<F32>& chunkPos  = _terrainChunk->getOffsetAndSize().xy();
    const vec2<F32>& chunkSize = _terrainChunk->getOffsetAndSize().zw();
    const F32 waterLevel = GET_ACTIVE_SCENE()->state().getWaterLevel() + 1.0f;
    const I32 currentCount = std::min((I32)_billboardCount, 4);
    const U16 mapWidth = _map.dimensions().width;
    const U16 mapHeight = _map.dimensions().height;
    const U32 grassElements = _grassDensity * chunkSize.x * chunkSize.y;

    PRINT_FN(Locale::get("CREATE_GRASS_BEGIN"), grassElements);

    _grassPositions.reserve(grassElements);
    //_grassMatricesTemp.reserve(grassElements);
    F32 densityFactor = 1.0f / _grassDensity;
    #pragma omp parallel for
    for (I32 index = 0; index < currentCount; ++index){
        densityFactor += 0.1f;
        for (F32 width = 0; width < chunkSize.x - densityFactor; width += densityFactor){
            for (F32 height = 0; height < chunkSize.y - densityFactor; height += densityFactor){
				if (_stopLoadingRequest) {
					continue;
				}
                F32 x = width  + random(densityFactor) + chunkPos.x;
                F32 y = height + random(densityFactor) + chunkPos.y;
                CLAMP<F32>(x, 0.0f, (F32)mapWidth  - 1.0f);
                CLAMP<F32>(y, 0.0f, (F32)mapHeight - 1.0f);
                F32 x_fac = x  / _map.dimensions().width;
                F32 y_fac = y  / _map.dimensions().height;

                I32 map_color = _map.getColor((U16)x, (U16)y)[index];
				if (map_color < 150) {
					continue;
				}
                const vec3<F32>& P = _terrain->getPosition(x_fac, y_fac);
				if (P.y < waterLevel) {
					continue;
				}
                const vec3<F32>& N = _terrain->getNormal(x_fac, y_fac);
				if (N.y < 0.7f) {
					continue;
				}
                #pragma omp critical 
                {
                    /*position.set(P);
                    mat4<F32> matRot1;
                    matRot1.scale(vec3<F32>(grassScale));
                    mat4<F32> matRot2;
                    matRot2.rotate_y(random(360.0f));
                    _grassMatricesTemp.push_back(matRot1 * matRot2 * rotationFromVToU(WORLD_Y_AXIS, N).getMatrix());*/

                    _grassPositions.push_back(vec4<F32>(P, index));
                    _grassScales.push_back(((map_color + 1) / 256.0f));
                    _instanceCountGrass++;
                }
            }
        }
    }

    PRINT_FN(Locale::get("CREATE_GRASS_END"));
}

};

Commits for Divide-Framework/trunk/Source Code/Environment/Vegetation/Vegetation.cpp

Diff revisions: vs.
Revision Author Commited Message
331 Diff Diff IonutCava picture IonutCava Sat 06 Dec, 2014 20:53:45 +0000

[Ionut]
- Limited line length to 132 characters to improve readability and diff-comparisons
- Refactored memory allocation/deallocation functions
- Fixed a few compatibility issues with HashMap.h
- Fixed a bug in GPU Skinning shaders (cast a float to int)

330 Diff Diff IonutCava picture IonutCava Fri 10 Oct, 2014 17:19:11 +0000

[Ionut]
- New rendering algorithm :
— Perform second pass for visible nodes gathering all render commands and uploading them to an indirect draw buffer
— Render geometry with indirect draw commands
— Removed per-node range binding of the node buffer. Instead, bind the entire buffer once and index data in shaders
— Use “baseInstance” parameter from IndirectDrawCommand as a node buffer index
— Prefer DSA extensions for updating buffer data where applicable
- Moved all rendering specific code from SceneGraphNode to a new RenderingComponent
- Optimized “toString” utility function

329 Diff Diff IonutCava picture IonutCava Tue 07 Oct, 2014 12:51:37 +0000

[Ionut]
- Modified material class and shaders to support multiple BRDFs (currently, only Flat, Phong and Blinn-Phong supported with Cook-Torrance and Oren-Nayar in future commits)
- Optimized transform updates and queries
- Fixed an indirect draw command (no buffer was bound to GL_DRAW_INDIRECT_BUFFER, violating a core requirement)

328 Diff Diff IonutCava picture IonutCava Sat 04 Oct, 2014 18:03:36 +0000

[Ionut]
- Added per SceneGraphNode material instances. (Cloned from the SceneNode’s material)
- Improved shader loading for materials

326 Diff Diff IonutCava picture IonutCava Tue 30 Sep, 2014 21:11:32 +0000

[Ionut]
- Fixed more memory leaks
- Simplified Task interface and timing System
- Improved compatibility between Boost, STL and EASTL with random combinations of vectors, strings and maps
- Simplified Light class by removing the “slot” member
- Random optimizations

325 Diff Diff IonutCava picture IonutCava Wed 17 Sep, 2014 20:06:13 +0000

[Ionut]
- Reworked transform system:
— Parent transform chain system moved from Transform class to the PhysicsComponent
— PhysicsComponent now returns all transform values needed both global and local (still needs heavy optimization and caching)

- Reworked SceneGraph node management:
— Proper ref counting of SceneNodes and proper removing of resource (ResourceCache is now empty on destruction, as it should be)
— Removed parent transform tracking as that’s the PhysicsComponent’s responsibility
— Only nodes loaded via the ResourceCache are allowed to be added to the SceneGraph (added proper loaders for Impostors, Sky, etc)

- Optimized some of the math classes (mat4, mat3)

322 Diff Diff IonutCava picture IonutCava Sat 06 Sep, 2014 20:33:47 +0000

[Ionut]
- Refactored most of Boost related code to be C++11 based
— Boost is only used for ThreadPool, Mutex handling, XML parsing and networking (ASIO)
— Function binds, threads, regex, NonCopyable base, Hashing algorithms and more are now using C++11 libraries
- Replaced all FOR_EACH calls with standard, range, “for” calls

318 Diff Diff IonutCava picture IonutCava Sat 30 Aug, 2014 17:35:53 +0000

[Ionut]
- Wrapped the entire code in a “Divide” namespace
- VertexBuffers now call “shrink_to_fit” on all internal data storage
- Improved some vector performance by preferring “emplace_back” instead of “push_back” + proepr usage of reserve / resize
- Wrapped OIS specific types and classes in Divide::Input namespace
- Added the messageBox.layout file (forgot it in the previous few commits)

307 Diff Diff IonutCava picture IonutCava Tue 12 Aug, 2014 19:45:12 +0000

[Ionut]
- More editor work:
— Per object skeleton rendering, bounding box rendering and shadow map toggling
— Full screen depth preview toggle
— Text entry based transforms

302 IonutCava picture IonutCava Wed 06 Aug, 2014 22:09:55 +0000

[Ionut]
- GenericVertexData buffer size (for read/write buffering) is now configurable instead of a fixed 3x and also applies to non-persistently mapped buffers
- Moved OpenGL enum tables to Divide::GLUtil::GL_ENUM_TABLE
- More code cleanups (glResources, glError, glVertexArray, glGenericVertexData, glIMPrimitive)