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
#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"

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),
    _threadedLoadComplete(false),
    _stopLoadingRequest(false),
    _terrainSGN(nullptr),
    _terrainChunk(nullptr),
    _instanceCountGrass(0),
    _instanceCountTrees(0),
    _grassStateBlockHash(0),
    _stateRefreshIntervalBuffer(0ULL),
    _stateRefreshInterval(getSecToUs(1)) ///<Every second?
{
    _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;
        boost::this_thread::sleep(boost::posix_time::milliseconds(10));
        timer += 10;
        if (timer > 1500) break;
    }
    assert(_threadedLoadComplete);
    _grassPositions.clear();
    RemoveResource(_cullShader);

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

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

    _terrainChunk = terrainChunk;
    _terrainSGN = terrainSGN;
    
    _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->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->setShaderLoadThreaded(false);
    vegMaterial->dumpToFile(false);
    setMaterial(vegMaterial);

    Kernel* kernel = Application::getInstance().getKernel();
    _generateVegetation.reset(kernel->AddTask(0, true, true, DELEGATE_BIND(&Vegetation::generateGrass, this), DELEGATE_BIND(&Vegetation::uploadGrassData, this)));
    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;
};

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

    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 = getMaterial();
    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);
        buffer->SetFeedbackBuffer(CulledPositionBuffer, 0); // position culled will be generated using transform feedback using shader output 'posLocation' writing to buffer "CulledPositionBuffer"
        buffer->SetFeedbackBuffer(CulledSizeBuffer,     1);
        buffer->SetFeedbackBuffer(CulledInstanceBuffer, 2);

        buffer->SetBuffer(UnculledPositionBuffer, _instanceCountGrass,     sizeof(vec4<F32>), &_grassPositions[0], false, false);
        buffer->SetBuffer(UnculledSizeBuffer,     _instanceCountGrass,     sizeof(F32),       &_grassScales[0],    false, false);
        buffer->SetBuffer(CulledPositionBuffer,   _instanceCountGrass * 3, sizeof(vec4<F32>), NULL,                true,  false); // "true, false" = DYNAMIC_COPY
        buffer->SetBuffer(CulledSizeBuffer,       _instanceCountGrass * 3, sizeof(F32),       NULL,                true,  false);
        buffer->SetBuffer(CulledInstanceBuffer,   _instanceCountGrass * 3, sizeof(I32),       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;

    return 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 = getMaterial();
            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.setInstanceCount(_instanceCountGrass);
        _cullDrawCommand.setQueryID(queryId);
        _cullDrawCommand.setDrawToBuffer(true);
        _cullDrawCommand.setShaderProgram(_cullShader);
        GFX_DEVICE.submitRenderCommand(buffer, _cullDrawCommand);
        //_cullDrawCommand.setInstanceCount(_instanceCountTrees);
        //GFX_DEVICE.submitRenderCommand(_treeGPUBuffer, _cullDrawCommand);
        GFX_DEVICE.toggleRasterization(true);
    }
}

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)));
    return false;
}

void Vegetation::render(SceneGraphNode* const sgn, const SceneRenderState& sceneRenderState, const RenderStage& currentRenderStage){
    U32 queryId = getQueryID();
    //gpuCull();
    GenericVertexData* buffer = _grassGPUBuffer[_readBuffer];
    I32 instanceCount = buffer->GetFeedbackPrimitiveCount(queryId);
    if (instanceCount == 0)
        return;

    _grassBillboards->Bind(0);

    _renderDrawCommand.setStateHash(_grassStateBlockHash);
    _renderDrawCommand.setInstanceCount(instanceCount);
    _renderDrawCommand.setLoD(1);
    _renderDrawCommand.setDrawIDs(GFX_DEVICE.getDrawIDs(sgn->getGUID()));
    _renderDrawCommand.setShaderProgram(getDrawShader(currentRenderStage));
    buffer->getDrawAttribDescriptor(posLocation).setOffset(_instanceCountGrass * queryId);
    buffer->getDrawAttribDescriptor(scaleLocation).setOffset(_instanceCountGrass * queryId);
    buffer->getDrawAttribDescriptor(instLocation).setOffset(_instanceCountGrass * queryId);
        
    GFX_DEVICE.submitRenderCommand(buffer, _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
286 Diff Diff IonutCava picture IonutCava Fri 18 Jul, 2014 16:32:03 +0000

[Ionut] [[BR]]

    • very buggy commit ** [[BR]]

- New rendering pipeline: [[BR]]
— Bumped OpenGL version to 4.4 [[BR]]
— Command based rendering. GFXDevice dispatches rendering commands to their respective buffers [[BR]]
— State changing is exclusively controlled by the GFXDevice class [[BR]]
— Material properties and transform matrices are stored in shader storage buffers that are updated after culling and uploaded once per RenderPass. Objects use drawIDs to index data in shaders [[BR]]
— Removed all custom matrices and other, per shader, bind data [[BR]]
— Removed per node light data. Light culling and shader buffers will replace the old light management system [[BR]]
— Framebuffers now use the Texture class for attachments [[BR]]
— Sampler objects now work like RenderStateBlocks. GL_API handles them and stores them in a hash indexed map [[BR]]
— Removed “prepareMaterial” calls. Pre-draw material setup is now only limited to texture binding [[BR]]
— Moved immediate mode emulation and primitive rendering from API level to GFXDevice level [[BR]]
— Framebuffer rendering must be completed with a call to end() to ensure proper MSAA resolve (asserts, otherwise) [[BR]]
- Fixed hash code generation for RenderStateBlock (and now, glSamplerObject) using boost::hash_combine [[BR]]
- Temporarily disabled XML caching for materials [[BR]]

279 Diff Diff IonutCava picture IonutCava Sat 28 Jun, 2014 16:20:46 +0000

[Ionut][[BR]]
- Unified draw command system into GenericDrawCommand [[BR]]
- Fixed double VB creation in Object3D [[BR]]
- Reworked triangle data computation (now Object3D’s responsibility) [[BR]]
- VertexArrays can now render using the primitive type specified in the draw command instead of the fixed type specified at creation [[BR]]
- Optimized terrain shader [[BR]]

278 Diff Diff IonutCava picture IonutCava Thu 19 Jun, 2014 18:09:59 +0000

[Ionut][[BR]]
- Preliminary work on generic shader function selection infrastructure [[BR]]

276 Diff Diff IonutCava picture IonutCava Fri 13 Jun, 2014 18:23:32 +0000

[Ionut][[BR]]
- Terrain now inherits from Object3D (instead of directly from SceneNode) [[BR]]
- Restructured RenderInstance to support multiple draw commands [[BR]]
— Multiple draw commands per instance are separated to different LoD batches automatically on render [[BR]]

274 Diff Diff IonutCava picture IonutCava Fri 13 Jun, 2014 12:56:03 +0000

[Ionut] [[BR]]
- Simplified buffer based rendering (VertexBuffer & GenericVertexData are now exclusively command based) [[BR]]
- Update bone buffer to persistent mapped-SSBO system with double-buffering [[BR]]
- Simplified sky rendering and (finally) reduced the sun’s radius [[BR]]

273 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 20:34:00 +0000

[Ionut] [[BR]]
- Improved batching part2: [[BR]]
— Moved all bone transformation matrices upload from uniform functions in SceneNode to Shader Storage Buffers in AnimationController class with updates controlled by SceneGraphNode’s AnimationComponent [[BR]]
-— No double-buffering or efficient mapping of data yet. Just raw buffer updates [[BR]]
— Replaced all RenderStateBlock* pointers with I64 hash values [[BR]]
-— Will be used later in draw commands as per-shader state hash [[BR]]
— Moved getShaderProgram from Material to Material::ShaderInfo [[BR]]
-— Improved redundant uniform checks [[BR]]
— Improved texture unit changing in case of redundant texture bind case (i.e. skip changing the texture unit) [[BR]]
[[BR]]
- Improved float and double comparison functions using algorithms described in http://randomascii.wordpress.com/2012/02/13/dont-store-that-in-a-float/ [[BR]]
- Added a new utility function, DIVIDE_ASSERT, to more easily bind an assert check with a specific message [[BR]]
- Added missing files from Forward+ renderer’s initial code [[BR]]

272 Diff Diff IonutCava picture IonutCava Wed 11 Jun, 2014 11:30:51 +0000

[Ionut] [[BR]]
- Added initial code for Forward+ rendering (grid based light culling) [[BR]]
- Simplified Light class [[BR]]
- Moved more light uniform data to ShaderBuffers [[BR]]
- Double buffered grass rendering [[BR]]
- Added a better attribute interface to GenericVertexData [[BR]]
- Fixed screenshot capture [[BR]]
- Fixed texture double-bind checks [[BR]]

271 Diff Diff IonutCava picture IonutCava Fri 06 Jun, 2014 19:27:02 +0000

[Ionut] [[BR]]
- Preparing GVD class to support persistent mapping [[BR]]
- Updates to grass buffer. Better eat up the cost of waiting for culling result than going through the severe visual artifacts cause by skipping draws [[BR]]

270 Diff Diff IonutCava picture IonutCava Thu 05 Jun, 2014 19:08:07 +0000

[Ionut][[BR]]
- SubMeshes now use a single vertex buffer (owned by the parent mesh) with proper offsetting and querying [[BR]]
— Implementation not optimal yet [[BR]]
- Cleaned up VertexBuffer related classes [[BR]]

268 IonutCava picture IonutCava Wed 04 Jun, 2014 10:20:27 +0000

[IonutCava] [[BR]]
- Terrain and vegetation updates: [[BR]]
— Use standard phong lighting model [[BR]]
— Separate grass patches per chunk [[BR]]
— Reduce number of required texture bind points for terrain by adding both textures and normal maps in a single texture array [[BR]]
— Draw terrain with 2 drawcalls (using glMultiDrawElements twice, once for LoD == 0 and once for LoD > 0) [[BR]]
[[BR]]
- Buffer management updates: [[BR]]
— Unified buffer binding system [[BR]]
— Made Uniform buffer objects visible to all classes and moved lightUBO to LightManager, matricesUBO to GFXDevice etc [[BR]]
— Added initial support for Shader Buffer Objects [[BR]]
— Moved viewport management to GFXDevice class [[BR]]
[[BR]]
- Rendering improvements: [[BR]]
— Added Hi-Z occlusion culling to instanceCull shader (using Hi-Z depth buffer constructed in GFXDevice class) [[BR]]
— Resolved issues with shadow maps overriding texture bind locations [[[BR]]
— Improved shader and shader program loading [[BR]]
— Improved material transparency support [[BR]]
— Added buffer lock manager class from “Approaching Zero Driver Overhead in OpenGL (Presented by NVIDIA)” speech at GDC14 [[BR]]