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
#ifndef _MATERIAL_DATA_FRAG_
#define _MATERIAL_DATA_FRAG_

#if defined(USE_OPACITY_DIFFUSE) || defined(USE_OPACITY_MAP) || defined(USE_OPACITY_DIFFUSE_MAP)
    #define HAS_TRANSPARENCY
#endif

#if !defined(SKIP_TEXTURES)
layout(binding = TEXTURE_UNIT0) uniform sampler2D texDiffuse0;
layout(binding = TEXTURE_UNIT1) uniform sampler2D texDiffuse1;
#endif
//Normal or BumpMap
#if defined(COMPUTE_TBN)
layout(binding = TEXTURE_NORMALMAP) uniform sampler2D texNormalMap;
#endif

//Specular and opacity maps are available even for non-textured geometry
#if defined(USE_OPACITY_MAP)
layout(binding = TEXTURE_OPACITY) uniform sampler2D texOpacityMap;
#endif

#if defined(USE_SPECULAR_MAP)
layout(binding = TEXTURE_SPECULAR) uniform sampler2D texSpecularMap;
#endif

struct MaterialProperties {
    vec3 ambient;
    vec3 diffuse;
    vec3 specular;
    vec3 specularColor;
};

float Gloss(in vec3 bump, in vec2 texCoord)
{
    #if defined(USE_TOKSVIG)
        // Compute the "Toksvig Factor"
        float rlen = 1.0/saturate(length(bump));
        return 1.0/(1.0 + power*(rlen - 1.0));
    #elif defined(USE_TOKSVIG_MAP)
        float baked_power = 100.0;
        // Fetch pre-computed "Toksvig Factor"
        // and adjust for specified power
        float gloss = texture2D(texSpecularMap, texCoord).r;
        gloss /= mix(power/baked_power, 1.0, gloss);
        return gloss;
    #else
        return 1.0;
    #endif
}

#if !defined(SKIP_TEXTURES)
vec4 getTextureColor(in vec2 uv) {
    #define TEX_MODULATE 0
    #define TEX_ADD  1
    #define TEX_SUBSTRACT  2
    #define TEX_DIVIDE  3
    #define TEX_SMOOTH_ADD  4
    #define TEX_SIGNED_ADD  5
    #define TEX_DECAL  6
    #define TEX_REPLACE  7

    vec4 color = texture(texDiffuse0, uv);

    if (dvd_textureCount == 1) {
        return color;
    }

    vec4 color2 = texture(texDiffuse1, uv);

    // Read from the texture
    switch (dvd_texOperation) {
        default             : color = vec4(0.7743, 0.3188, 0.5465, 1.0);   break; // <hot pink to easily spot it in a crowd
        case TEX_MODULATE   : color *= color2;       break;
        case TEX_REPLACE    : color  = color2;       break;
        case TEX_SIGNED_ADD : color += color2 - 0.5; break;
        case TEX_DIVIDE     : color /= color2;          break;
        case TEX_SUBSTRACT  : color -= color2;          break;
        case TEX_DECAL      : color = vec4(mix(color.rgb, color2.rgb, color2.a), color.a); break;
        case TEX_ADD        : {
            color.rgb += color2.rgb;
            color.a   *= color2.a;
        }break;
        case TEX_SMOOTH_ADD : {
            color = (color + color2) - (color * color2);
        }break;
    }
    

    return saturate(color);
}
#endif
#endif

Commits for Divide-Framework/trunk/assets/shaders/GLSL/fragmentAtoms/materialData.frag

Diff revisions: vs.
Revision Author Commited Message
337 Diff Diff IonutCava picture IonutCava Wed 17 Dec, 2014 17:25:16 +0000

[Ionut]
- Replaced all tabs with 4 spaces (some spacing may be off now. no way to check all the files.)
- Moved implementation details for ParamHandler, BoundingBox, BoundingSphere and ProfileTimer to proper .inl and .cpp files. (more to follow)
- Update all forward declared enums with the required storage type (as requested by the C++11 standard)

329 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)