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

#include "bumpMapping.frag"

uniform sampler2D      texBlend[MAX_TEXTURE_LAYERS];
uniform sampler2DArray texTileMaps[MAX_TEXTURE_LAYERS];
uniform sampler2DArray texNormalMaps[MAX_TEXTURE_LAYERS];

uniform vec4 diffuseScale[MAX_TEXTURE_LAYERS];
uniform vec4 detailScale[MAX_TEXTURE_LAYERS];

layout(binding = TEXTURE_UNIT0)     uniform sampler2D texWaterCaustics;
layout(binding = TEXTURE_UNIT1)     uniform sampler2D texUnderwaterAlbedo;
layout(binding = TEXTURE_NORMALMAP) uniform sampler2D texUnderwaterDetail;
layout(binding = TEXTURE_OPACITY)   uniform sampler2D texHeightMap;

vec4 getFinalColour1(const in vec4 blendMap, const in uint index, const in vec4 diffSize) {
    return texture(texTileMaps[index], vec3(scaledTextureCoords(VAR._texCoord, diffSize.r), 0));
}

vec3 getFinalTBN1(const in vec4 blendMap, const in uint index, const in vec4 normSize){
    return texture(texNormalMaps[index], vec3(scaledTextureCoords(VAR._texCoord, normSize.r), 0)).rgb;
}

vec4 getFinalColour2(const in vec4 blendMap, const in uint index, const in vec4 diffSize){
    return mix(getFinalColour1(blendMap, index, diffSize), 
               texture(texTileMaps[index], vec3(scaledTextureCoords(VAR._texCoord, diffSize.g), 1)),
               blendMap.g);
}

vec3 getFinalTBN2(const in vec4 blendMap, const in uint index, const in vec4 normSize){
    return mix(getFinalTBN1(blendMap, index, normSize), 
               texture(texNormalMaps[index], vec3(scaledTextureCoords(VAR._texCoord, normSize.g), 1)).rgb,
               blendMap.g);
}

vec4 getFinalColour3(const in vec4 blendMap, const in uint index, const in vec4 diffSize){
    return mix(getFinalColour2(blendMap, index, diffSize), 
               texture(texTileMaps[index], vec3(scaledTextureCoords(VAR._texCoord, diffSize.b), 2)),
               blendMap.b);
}

vec3 getFinalTBN3(const in vec4 blendMap, const in uint index, const in vec4 normSize){
    return mix(getFinalTBN2(blendMap, index, normSize), 
               texture(texNormalMaps[index], vec3(scaledTextureCoords(VAR._texCoord, normSize.b), 2)).rgb,
               blendMap.b);
}

vec4 getFinalColour4(const in vec4 blendMap, const in uint index, const in vec4 diffSize){
    return mix(getFinalColour3(blendMap, index, diffSize), 
               texture(texTileMaps[index], vec3(scaledTextureCoords(VAR._texCoord, diffSize.a), 3)),
               blendMap.a);
}

vec3 getFinalTBN4(const in vec4 blendMap, const in uint index, const in vec4 normSize){
    return mix(getFinalTBN3(blendMap, index, normSize), 
               texture(texNormalMaps[index], vec3(scaledTextureCoords(VAR._texCoord, normSize.a), 3)).rgb,
               blendMap.a);
}

vec4 getTerrainAlbedo(){
    vec4 blendMap;
    vec4 colour = vec4(0.0);
    
    for (uint i = 0; i < MAX_TEXTURE_LAYERS; i++) {
        blendMap = texture(texBlend[i], VAR._texCoord);
#if (CURRENT_TEXTURE_COUNT % 4) == 1
        colour += getFinalColour1(blendMap, i, diffuseScale[i]);
#elif (CURRENT_TEXTURE_COUNT % 4) == 2
        colour += getFinalColour2(blendMap, i, diffuseScale[i]);
#elif (CURRENT_TEXTURE_COUNT % 4) == 3
        colour += getFinalColour3(blendMap, i, diffuseScale[i]);
#else//(CURRENT_TEXTURE_COUNT % 4) == 0
        colour += getFinalColour4(blendMap, i, diffuseScale[i]);
#endif
    }

    return colour;
}

vec3 getTerrainNormal() {

    

    vec3 tbn = vec3(0.0);
    vec3 tbnTemp;
    for (uint i = 0; i < MAX_TEXTURE_LAYERS; i++) {
        vec4 blendMap = texture(texBlend[i], VAR._texCoord);
#if (CURRENT_TEXTURE_COUNT % 4) == 1
        tbnTemp = getFinalTBN1(blendMap, 0, detailScale[i]);
#elif (CURRENT_TEXTURE_COUNT % 4) == 2
        tbnTemp = getFinalTBN2(blendMap, 0, detailScale[i]);
#elif (CURRENT_TEXTURE_COUNT % 4) == 3
        tbnTemp = getFinalTBN3(blendMap, 0, detailScale[i]);
#else//(CURRENT_TEXTURE_COUNT % 4) == 0
        tbnTemp = getFinalTBN4(blendMap, 0, detailScale[i]);
#endif
        //tbnTemp = getTBNMatrix() * normalize(2.0 * tbnTemp - 1.0);
        tbnTemp = perturb_normal(tbnTemp, VAR._normalWV, VAR._vertexW.xyz - dvd_cameraPosition.xyz, VAR._texCoord);
        tbn = normalUDNBlend(tbnTemp, tbn);
    }

    return tbn;
}

#endif //_TERRAIN_SPLATTING_FRAG_

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

Diff revisions: vs.
Revision Author Commited Message
887 Diff Diff IonutCava picture IonutCava Mon 03 Apr, 2017 15:42:51 +0000

[IonutCava]
- Attempt to add a new bumpmapping technique to terrain
- Attempt to smooth terrain by averaging nearby heights

884 Diff Diff IonutCava picture IonutCava Mon 27 Mar, 2017 15:32:26 +0000

[Ionut]
- More terrain work

879 Diff Diff IonutCava picture IonutCava Sun 19 Mar, 2017 19:29:46 +0000

[IonutCava]
- GLSL updates:
— Interface block correction to support tessellation shaders automatically
— Fixed line counting issues with the preprocessor

875 Diff Diff IonutCava picture IonutCava Tue 14 Mar, 2017 16:59:38 +0000

[IonutCava]
- Cleanup and optimizations

812 Diff Diff IonutCava picture IonutCava Wed 11 Jan, 2017 21:38:18 +0000

[IonutCava]
- Finish terrain shader fixes (AMD GPU related issues)

811 Diff Diff IonutCava picture IonutCava Wed 11 Jan, 2017 17:26:49 +0000

[IonutCava]
- Fix some threadpool cleanup bugs
- Fix terrain rendering (except underwater caustics)
- Fix terrain loading
- Fix terrain unloading

721 Diff Diff IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better

621 Diff Diff IonutCava picture IonutCava Tue 12 Jan, 2016 16:39:50 +0000

[IonutCava]
- Terrain rendering updates
- Framebuffer optimizations

620 Diff Diff IonutCava picture IonutCava Mon 11 Jan, 2016 17:23:02 +0000

[IonutCava]
- More terrain rendering work and crash fixes

618 IonutCava picture IonutCava Thu 07 Jan, 2016 17:12:22 +0000

[IonutCava]
- Terrain, Water and Vegetation migration to new command based system (incomplete)
— Added terrain geometry caching support