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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
#include "Headers/Material.h"

#include "Rendering/Headers/Renderer.h"
#include "Hardware/Video/Headers/GFXDevice.h"
#include "Hardware/Video/Headers/RenderStateBlock.h"
#include "Hardware/Video/Shaders/Headers/ShaderManager.h"
#include "Core/Resources/Headers/ResourceCache.h"

namespace Divide {

bool Material::_shaderQueueLocked = false;
bool Material::_serializeShaderLoad = false;

Material::Material() : Resource("temp_material"),
                       _parallaxFactor(1.0f),
                       _dirty(false),
                       _doubleSided(false),
                       _shaderThreadedLoad(true),
                       _hardwareSkinning(false),
                       _useAlphaTest(false),
                       _dumpToFile(true),
                       _translucencyCheck(false),
                       _shadingMode(ShadingMode_PLACEHOLDER),
                       _bumpMethod(BUMP_NONE)
{
    _textures.resize(ShaderProgram::TextureUsage_PLACEHOLDER, nullptr);

    _operation = TextureOperation_Replace;

    /// Normal state for final rendering
    RenderStateBlockDescriptor stateDescriptor;
    hashAlg::insert(_defaultRenderStates, 
                    hashAlg::makePair(FINAL_STAGE, GFX_DEVICE.getOrCreateStateBlock(stateDescriptor)));
    /// the reflection descriptor is the same as the normal descriptor
    RenderStateBlockDescriptor reflectorDescriptor(stateDescriptor);
    hashAlg::insert(_defaultRenderStates, 
                    hashAlg::makePair(REFLECTION_STAGE, GFX_DEVICE.getOrCreateStateBlock(reflectorDescriptor)));
    /// the z-pre-pass descriptor does not process colors
    RenderStateBlockDescriptor zPrePassDescriptor(stateDescriptor);
    zPrePassDescriptor.setColorWrites(false, false, false, false);
    hashAlg::insert(_defaultRenderStates, 
                    hashAlg::makePair(Z_PRE_PASS_STAGE, GFX_DEVICE.getOrCreateStateBlock(zPrePassDescriptor)));
    /// A descriptor used for rendering to depth map
    RenderStateBlockDescriptor shadowDescriptor(stateDescriptor);
    shadowDescriptor.setCullMode(CULL_MODE_CCW);
    /// set a polygon offset
    //shadowDescriptor.setZBias(1.0f, 2.0f);
    /// ignore colors - Some shadowing techniques require drawing to the a color buffer
    shadowDescriptor.setColorWrites(true, true, false, false);
    hashAlg::insert(_defaultRenderStates, 
                    hashAlg::makePair(SHADOW_STAGE, GFX_DEVICE.getOrCreateStateBlock(shadowDescriptor)));
   
    assert(_defaultRenderStates[FINAL_STAGE]      != 0);
    assert(_defaultRenderStates[Z_PRE_PASS_STAGE] != 0);
    assert(_defaultRenderStates[SHADOW_STAGE]     != 0);
    assert(_defaultRenderStates[REFLECTION_STAGE] != 0);

    _computedShaderTextures = false;
}

Material::~Material()
{
    _defaultRenderStates.clear();
}

Material* Material::clone(const stringImpl& nameSuffix) {
    DIVIDE_ASSERT(!nameSuffix.empty(),
                  "Material error: clone called without a valid name suffix!");

    const Material& base = *this;
    Material* cloneMat = CreateResource<Material>(ResourceDescriptor(getName() + nameSuffix));

    cloneMat->_translucencySource.clear();
    for (const shaderInfoMap::value_type& it : base._shaderInfo) {
        cloneMat->_shaderInfo[it.first] = it.second;
    }
    for (const TranslucencySource& trans : base._translucencySource){
        cloneMat->_translucencySource.push_back(trans);
    }
    for (const renderStateBlockMap::value_type& it : base._defaultRenderStates){
        cloneMat->_defaultRenderStates[it.first] = it.second;
    }
    for (U8 i = 0; i < static_cast<U8>(base._textures.size()); ++i) {
        Texture* const tex = base._textures[i];
        if (tex) {
            tex->AddRef();
            cloneMat->setTexture(static_cast<ShaderProgram::TextureUsage>(i), tex);
        }
    }
    for (const std::pair<Texture*, U32>& tex : base._customTextures) {
        if (tex.first) {
            tex.first->AddRef();
            cloneMat->addCustomTexture(tex.first, tex.second);
        }
    }
    cloneMat->_shadingMode = base._shadingMode;
    cloneMat->_shaderModifier = base._shaderModifier;
    cloneMat->_translucencyCheck = base._translucencyCheck;
    cloneMat->_dirty = base._dirty;
    cloneMat->_dumpToFile = base._dumpToFile;
    cloneMat->_useAlphaTest = base._useAlphaTest;
    cloneMat->_doubleSided = base._doubleSided;
    cloneMat->_hardwareSkinning = base._hardwareSkinning;
    cloneMat->_shaderThreadedLoad = base._shaderThreadedLoad;
    cloneMat->_computedShaderTextures = base._computedShaderTextures;
    cloneMat->_operation = base._operation;
    cloneMat->_bumpMethod = base._bumpMethod;
    cloneMat->_shaderData = base._shaderData;
    cloneMat->_parallaxFactor = base._parallaxFactor;

    return cloneMat;
}

void Material::update(const U64 deltaTime){
    // build one shader per frame
    computeShaderInternal();
    clean();
}

size_t Material::getRenderStateBlock(RenderStage currentStage) {
    const renderStateBlockMap::const_iterator& it = _defaultRenderStates.find(currentStage);
    if (it == _defaultRenderStates.end()) {
        return _defaultRenderStates[FINAL_STAGE];
    }
    return it->second;
}

size_t Material::setRenderStateBlock(const RenderStateBlockDescriptor& descriptor, const RenderStage& renderStage){
    renderStateBlockMap::iterator it = _defaultRenderStates.find(renderStage);
    size_t stateBlockHash = GFX_DEVICE.getOrCreateStateBlock(descriptor);
    if(it == _defaultRenderStates.end()){
        hashAlg::insert(_defaultRenderStates, hashAlg::makePair(renderStage, stateBlockHash));
        return stateBlockHash;
    }

    it->second = stateBlockHash;
    return it->second;
}

//base = base texture
//second = second texture used for multitexturing
//bump = bump map
void Material::setTexture(ShaderProgram::TextureUsage textureUsageSlot, Texture* const texture, const TextureOperation& op) {
    bool computeShaders = false;

    if(_textures[textureUsageSlot]){
        UNREGISTER_TRACKED_DEPENDENCY(_textures[textureUsageSlot]);
        RemoveResource(_textures[textureUsageSlot]);
    }else{
        //if we add a new type of texture recompute shaders
        computeShaders = true;
    }

    _textures[textureUsageSlot] = texture;

    if ( texture ) {
        REGISTER_TRACKED_DEPENDENCY( _textures[textureUsageSlot] );
    }

    if ( textureUsageSlot == ShaderProgram::TEXTURE_UNIT1 ) {
        _operation = op;
    }
    if ( textureUsageSlot == ShaderProgram::TEXTURE_UNIT0 || textureUsageSlot == ShaderProgram::TEXTURE_UNIT1 ) {
        texture ? _shaderData._textureCount++ : _shaderData._textureCount--;
    }
    if ( textureUsageSlot == ShaderProgram::TEXTURE_UNIT0 || textureUsageSlot == ShaderProgram::TEXTURE_OPACITY ) {
        _translucencyCheck = false;
    }
   
    if ( computeShaders ) {
        recomputeShaders();
    }
    _dirty = true;
}

//Here we set the shader's name
void Material::setShaderProgram(const stringImpl& shader, 
                                const RenderStage& renderStage,
                                const bool computeOnAdd,
                                const DELEGATE_CBK<>& shaderCompileCallback) {
    _shaderInfo[renderStage]._isCustomShader = true;
    setShaderProgramInternal(shader, renderStage, computeOnAdd, shaderCompileCallback);
}

void Material::setShaderProgramInternal(const stringImpl& shader, 
                                        const RenderStage& renderStage, 
                                        const bool computeOnAdd, 
                                        const DELEGATE_CBK<>& shaderCompileCallback) {
    ShaderProgram* shaderReference = _shaderInfo[renderStage]._shaderRef;
    //if we already had a shader assigned ...
    if (!_shaderInfo[renderStage]._shader.empty()){
        //and we are trying to assign the same one again, return.
        shaderReference = FindResourceImpl<ShaderProgram>(_shaderInfo[renderStage]._shader);
        if (_shaderInfo[renderStage]._shader.compare(shader) != 0){
            PRINT_FN(Locale::get("REPLACE_SHADER"), _shaderInfo[renderStage]._shader.c_str(), shader.c_str());
            UNREGISTER_TRACKED_DEPENDENCY( shaderReference );
            RemoveResource(shaderReference);
        }
    }

    (!shader.empty()) ? _shaderInfo[renderStage]._shader = shader : _shaderInfo[renderStage]._shader = "NULL_SHADER";
    
    ResourceDescriptor shaderDescriptor(_shaderInfo[renderStage]._shader);
    std::stringstream ss;
    if (!_shaderInfo[renderStage]._shaderDefines.empty()){
        for(stringImpl& shaderDefine : _shaderInfo[renderStage]._shaderDefines){
            ss << stringAlg::fromBase(shaderDefine);
            ss << ",";
        }
    }
    ss << "DEFINE_PLACEHOLDER";
    shaderDescriptor.setPropertyList(stringAlg::toBase(ss.str()));
    shaderDescriptor.setThreadedLoading(_shaderThreadedLoad);

    _computedShaderTextures = true;
    if (computeOnAdd){
        _shaderInfo[renderStage]._shaderRef = CreateResource<ShaderProgram>(shaderDescriptor);
        _shaderInfo[renderStage]._shaderCompStage = ShaderInfo::SHADER_STAGE_COMPUTED;
        REGISTER_TRACKED_DEPENDENCY(_shaderInfo[renderStage]._shaderRef); 
        if (shaderCompileCallback){
            shaderCompileCallback();
        }
    }else{
        _shaderComputeQueue.push(std::make_tuple(renderStage, shaderDescriptor, shaderCompileCallback));
        _shaderInfo[renderStage]._shaderCompStage = ShaderInfo::SHADER_STAGE_QUEUED;
    }
}

void Material::clean() {
    if(_dirty && _dumpToFile){
        isTranslucent();
        XML::dumpMaterial(*this);
       _dirty = false;
    }
}

void Material::recomputeShaders() {
	for (shaderInfoMap::value_type& it : _shaderInfo) {
        if ( !it.second._isCustomShader ) {
            it.second._shaderCompStage = ShaderInfo::SHADER_STAGE_REQUESTED;
            computeShader( it.first, false, DELEGATE_CBK<>() );
        }
    }
}

///If the current material doesn't have a shader associated with it, then add the default ones.
///Manually setting a shader, overrides this function by setting _computedShaders to "true"
bool Material::computeShader(const RenderStage& renderStage, 
                             const bool computeOnAdd, 
                             const DELEGATE_CBK<>& shaderCompileCallback) {
    if ( _shaderInfo[renderStage]._shaderCompStage == ShaderInfo::SHADER_STAGE_COMPUTED ) {
        return true;
    }

    if ( ( _textures[ShaderProgram::TEXTURE_UNIT0] && _textures[ShaderProgram::TEXTURE_UNIT0]->getState() != RES_LOADED ) ||
        ( _textures[ShaderProgram::TEXTURE_OPACITY] && _textures[ShaderProgram::TEXTURE_OPACITY]->getState() != RES_LOADED ) ) {
        return false;
    }

    DIVIDE_ASSERT(_shadingMode != ShadingMode_PLACEHOLDER, "Material computeShader error: Invalid shading mode specified!");

    bool deferredPassShader = GFX_DEVICE.getRenderer()->getType() != RENDERER_FORWARD_PLUS;
    bool depthPassShader = renderStage == SHADOW_STAGE || renderStage == Z_PRE_PASS_STAGE;

    //the base shader is either for a Deferred Renderer or a Forward  one ...
    stringImpl shader = (deferredPassShader ? "DeferredShadingPass1" : (depthPassShader ? "depthPass" : "lighting"));

    if ( Config::Profile::DISABLE_SHADING ) {
        shader = "passThrough";
    }
    if ( depthPassShader ) {
        renderStage == Z_PRE_PASS_STAGE ? shader += ".PrePass" : shader += ".Shadow";
    }
    //What kind of effects do we need?
    if (_textures[ShaderProgram::TEXTURE_UNIT0]){
        //Bump mapping?
        if (_textures[ShaderProgram::TEXTURE_NORMALMAP] && _bumpMethod != BUMP_NONE){
            addShaderDefines(renderStage, "COMPUTE_TBN");
            shader += ".Bump"; //Normal Mapping
            if (_bumpMethod == BUMP_PARALLAX){
                shader += ".Parallax";
                addShaderDefines(renderStage, "USE_PARALLAX_MAPPING");
            }else if (_bumpMethod == BUMP_RELIEF){
                shader += ".Relief";
                addShaderDefines(renderStage, "USE_RELIEF_MAPPING");
            }
        }else{
            // Or simple texture mapping?
            shader += ".Texture";
        }
    }else{
        addShaderDefines(renderStage, "SKIP_TEXTURES");
        shader += ".NoTexture";
    }

    if (_textures[ShaderProgram::TEXTURE_SPECULAR]){
        shader += ".Specular";
        addShaderDefines(renderStage, "USE_SPECULAR_MAP");
    }

    if (isTranslucent()){
        for (Material::TranslucencySource source : _translucencySource){
            if(source == TRANSLUCENT_DIFFUSE ){
                shader += ".DiffuseAlpha";
                addShaderDefines(renderStage, "USE_OPACITY_DIFFUSE");
            }
            if (source == TRANSLUCENT_OPACITY_MAP){
                shader += ".OpacityMap";
                addShaderDefines(renderStage, "USE_OPACITY_MAP");
            }
            if (source == TRANSLUCENT_DIFFUSE_MAP){
                shader += ".TextureAlpha";
                addShaderDefines(renderStage, "USE_OPACITY_DIFFUSE_MAP");
            }
        }
    }
	if (_doubleSided){
		shader += ".DoubleSided";
		addShaderDefines(renderStage, "USE_DOUBLE_SIDED");
	}
    //Add the GPU skinning module to the vertex shader?
    if (_hardwareSkinning){
        addShaderDefines(renderStage, "USE_GPU_SKINNING");
        shader += ",Skinned"; //<Use "," instead of "." will add a Vertex only property
    }

    switch (_shadingMode) {
        default:
        case SHADING_FLAT: {
            addShaderDefines(renderStage, "USE_SHADING_FLAT");
            shader += ".Flat";
        }break;
        case SHADING_PHONG: {
            addShaderDefines(renderStage, "USE_SHADING_PHONG");
            shader += ".Phong";
        }break;
        case SHADING_BLINN_PHONG: {
            addShaderDefines(renderStage, "USE_SHADING_BLINN_PHONG");
            shader += ".BlinnPhong";
        }break;
        case SHADING_TOON: {
            addShaderDefines(renderStage, "USE_SHADING_TOON");
            shader += ".Toon";
        }break;
        case SHADING_OREN_NAYAR: {
            addShaderDefines(renderStage, "USE_SHADING_OREN_NAYAR");
            shader += ".OrenNayar";
        }break;
        case SHADING_COOK_TORRANCE: {
            addShaderDefines(renderStage, "USE_SHADING_COOK_TORRANCE");
            shader += ".CookTorrance";
        }break;
    }
    //Add any modifiers you wish
    if (!_shaderModifier.empty()){
        shader += ".";
        shader += _shaderModifier;
    }

    setShaderProgramInternal(shader, renderStage, computeOnAdd, shaderCompileCallback);

    return true;
}

void Material::computeShaderInternal(){
    if ( _shaderComputeQueue.empty()/* || Material::isShaderQueueLocked()*/ ) {
        return;
    }
    //Material::lockShaderQueue();

    const std::tuple<RenderStage, ResourceDescriptor, DELEGATE_CBK<>>& currentItem = _shaderComputeQueue.front();
    const RenderStage& renderStage = std::get<0>(currentItem);
    const ResourceDescriptor& descriptor = std::get<1>(currentItem);
    const DELEGATE_CBK<>& callback = std::get<2>(currentItem);
    _dirty = true;
    
    _shaderInfo[renderStage]._shaderRef = CreateResource<ShaderProgram>(descriptor);
    _shaderInfo[renderStage]._shaderCompStage = ShaderInfo::SHADER_STAGE_COMPUTED;
    if (callback){
        callback();
    }
    REGISTER_TRACKED_DEPENDENCY(_shaderInfo[renderStage]._shaderRef);
    _shaderComputeQueue.pop();
}

void Material::bindTextures(){
    if (_textures[ShaderProgram::TEXTURE_OPACITY]) {
        _textures[ShaderProgram::TEXTURE_OPACITY]->Bind(ShaderProgram::TEXTURE_OPACITY);
    }

    if (_textures[ShaderProgram::TEXTURE_UNIT0]) {
        _textures[ShaderProgram::TEXTURE_UNIT0]->Bind(ShaderProgram::TEXTURE_UNIT0);
    }

    if (!GFX_DEVICE.isCurrentRenderStage(DEPTH_STAGE)) {
        if (_textures[ShaderProgram::TEXTURE_NORMALMAP]) {
            _textures[ShaderProgram::TEXTURE_NORMALMAP]->Bind(ShaderProgram::TEXTURE_NORMALMAP);
        }

        if (_textures[ShaderProgram::TEXTURE_SPECULAR]) {
            _textures[ShaderProgram::TEXTURE_SPECULAR]->Bind(ShaderProgram::TEXTURE_SPECULAR);
        }

        if (_textures[ShaderProgram::TEXTURE_UNIT1]) {
            _textures[ShaderProgram::TEXTURE_UNIT1]->Bind(ShaderProgram::TEXTURE_UNIT1);
        }

        for (std::pair<Texture*, U32>& tex : _customTextures) {
            tex.first->Bind(tex.second);
        }
    }
}

ShaderProgram* const Material::ShaderInfo::getProgram() const {
    return _shaderRef == nullptr ? ShaderManager::getInstance().getDefaultShader() : _shaderRef;
}

Material::ShaderInfo& Material::getShaderInfo(RenderStage renderStage) {
    shaderInfoMap::iterator it = _shaderInfo.find(renderStage);

    return (it == _shaderInfo.end() ? _shaderInfo[FINAL_STAGE] : it->second);
}

void Material::setBumpMethod(const BumpMethod& newBumpMethod){
    _bumpMethod = newBumpMethod;
    recomputeShaders();
}

bool Material::unload(){
    for(Texture*& tex : _textures){
        if(tex != nullptr){
            UNREGISTER_TRACKED_DEPENDENCY(tex);
            RemoveResource(tex);
        }
    }
    _customTextures.clear();
	for (shaderInfoMap::value_type& it : _shaderInfo) {
        ShaderProgram* shader = FindResourceImpl<ShaderProgram>( it.second._shader );
        if ( shader != nullptr ) {
            UNREGISTER_TRACKED_DEPENDENCY( shader );
            RemoveResource( shader );
        }
    }
    _shaderInfo.clear();
    return true;
}

void Material::setDoubleSided(bool state, const bool useAlphaTest) {
    if ( _doubleSided == state && _useAlphaTest == useAlphaTest ) {
        return;
    }
    _doubleSided = state;
    _useAlphaTest = useAlphaTest;
    // Update all render states for this item
    if ( _doubleSided ) {
		for (renderStateBlockMap::value_type& it : _defaultRenderStates) {
            RenderStateBlockDescriptor descriptor( GFX_DEVICE.getStateBlockDescriptor( it.second ) );
            descriptor.setCullMode( CULL_MODE_NONE );
            if ( !_translucencySource.empty() ) {
                descriptor.setBlend( true );
            }
            setRenderStateBlock( descriptor, it.first );
        }
    }

    _dirty = true;
	recomputeShaders();
}

bool Material::isTranslucent() {
    if (!_translucencyCheck){
        _translucencySource.clear();
        bool useAlphaTest = false;
        // In order of importance (less to more)!
        // diffuse channel alpha
        if(_shaderData._diffuse.a < 0.95f) {
            _translucencySource.push_back(TRANSLUCENT_DIFFUSE);
            useAlphaTest = (_shaderData._diffuse.a < 0.15f);
        }

        // base texture is translucent
        if (_textures[ShaderProgram::TEXTURE_UNIT0] && _textures[ShaderProgram::TEXTURE_UNIT0]->hasTransparency()){
            _translucencySource.push_back(TRANSLUCENT_DIFFUSE_MAP);
            useAlphaTest = true;
        }

        // opacity map
        if(_textures[ShaderProgram::TEXTURE_OPACITY]){
            _translucencySource.push_back(TRANSLUCENT_OPACITY_MAP);
            useAlphaTest = false;
        }

         // Disable culling for translucent items
        if (!_translucencySource.empty()){
            setDoubleSided(true, useAlphaTest);
        }
        _translucencyCheck = true;
        recomputeShaders();
    }

    return !_translucencySource.empty();
}

void Material::getSortKeys(I32& shaderKey, I32& textureKey) const {
    shaderInfoMap::const_iterator it = _shaderInfo.find(FINAL_STAGE);

    shaderKey  = (it != _shaderInfo.end() && it->second._shaderRef) ? it->second._shaderRef->getId() :
                                                                      -std::numeric_limits<I8>::max();
	textureKey = _textures[ShaderProgram::TEXTURE_UNIT0] ? _textures[ShaderProgram::TEXTURE_UNIT0]->getHandle() : 
                                                           -std::numeric_limits<I8>::max();
}

};

Commits for Divide-Framework/trunk/Source Code/Geometry/Material/Material.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)

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

327 Diff Diff IonutCava picture IonutCava Thu 02 Oct, 2014 12:32:15 +0000

[Ionut]
- Removed specular color from lights (specular color should be identical to light’s diffuse color anyway)
- Doublesided materials use their own shader defines now
- Fixed a bug in the particle shader related to screen dimensions never being passed
- Disabled material loading from XML for Primitive type geometry

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)

323 Diff Diff IonutCava picture IonutCava Thu 11 Sep, 2014 20:58:50 +0000

[Ionut]
- Reworked GFXDevice API initialization system
- Added a separate map for boolean values in ParamHandler
- More cleanups in GFXDevice class
- Fixed an infinite loop issue in Task class

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

321 Diff Diff IonutCava picture IonutCava Wed 03 Sep, 2014 22:05:15 +0000

[Ionut]
- Added support (and enabled by default) for the EASTL library (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html / https://github.com/paulhodge/EASTL)
— Strings, vectors and hash_maps can be combined from EASTL, STL and Boost (not all combinations work. e.g. EASTL strings with STL/Boost containers due to the lack of a proper hash function)

319 IonutCava picture IonutCava Sat 30 Aug, 2014 21:37:57 +0000

[Ionut]
- Performance tweaks based on profiling data