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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
--Vertex

#include "vbInputData.vert"

struct TerrainNodeData {
    vec4 _positionAndTileScale;
    vec4 _tScale;
};

layout(binding = BUFFER_TERRAIN_DATA, std430) coherent readonly buffer dvd_TerrainBlock
{
    TerrainNodeData dvd_TerrainData[];
};

vec2 calcTerrainTexCoord(in vec4 pos)
{
    vec2 TerrainOrigin = vec2(-(TERRAIN_WIDTH * 0.5), -(TERRAIN_LENGTH * 0.5));
    return vec2(abs(pos.x - TerrainOrigin.x) / TERRAIN_WIDTH, abs(pos.z - TerrainOrigin.y) / TERRAIN_LENGTH);
}

void main(void)
{
    computeData();

    vec4 posAndScale = dvd_TerrainData[VAR.dvd_drawID]._positionAndTileScale;

    vec4 patchPosition = vec4(dvd_Vertex.xyz * posAndScale.w, 1.0);
    
    VAR._vertexW = /*dvd_WorldMatrix(VAR.dvd_instanceID) * */vec4(patchPosition + vec4(posAndScale.xyz, 0.0));

    // Calcuate texture coordantes (u,v) relative to entire terrain
    VAR._texCoord = calcTerrainTexCoord(VAR._vertexW);

    // Send vertex position along
    gl_Position = patchPosition;
}

--TessellationC

#include "nodeBufferedInput.cmn"

layout(binding = TEXTURE_OPACITY)   uniform sampler2D TexTerrainHeight;

struct TerrainNodeData {
    vec4 _positionAndTileScale;
    vec4 _tScale;
};

layout(binding = BUFFER_TERRAIN_DATA, std430) coherent readonly buffer dvd_TerrainBlock
{
    TerrainNodeData dvd_TerrainData[];
};

//
// Outputs
//
layout(vertices = 4) out;

patch out float gl_TessLevelOuter[4];
patch out float gl_TessLevelInner[2];

out float tcs_tessLevel[];

mat4 mvMatrix;

/**
* Dynamic level of detail using camera distance algorithm.
*/
float dlodCameraDistance(vec4 p0, vec4 p1, vec2 t0, vec2 t1)
{
    float sampleHeight = texture(TexTerrainHeight, t0).r;
    p0.y = TERRAIN_MIN_HEIGHT + TERRAIN_HEIGHT_RANGE * sampleHeight;
    sampleHeight = texture(TexTerrainHeight, t1).r;
    p1.y = TERRAIN_MIN_HEIGHT + TERRAIN_HEIGHT_RANGE * sampleHeight;

    vec3 offset = dvd_TerrainData[VAR.dvd_drawID]._positionAndTileScale.xyz;
    vec4 view0 = mvMatrix * vec4(p0.xyz + offset, p0.w);
    vec4 view1 = mvMatrix * vec4(p1.xyz + offset, p1.w);

    float MinDepth = 5.0;
    float MaxDepth = 150.0;

    float d0 = clamp((abs(p0.z) - MinDepth) / (MaxDepth - MinDepth), 0.0, 1.0);
    float d1 = clamp((abs(p1.z) - MinDepth) / (MaxDepth - MinDepth), 0.0, 1.0);

    float t = mix(64, 2, (d0 + d1) * 0.5);

    if (t <= 2.0)
    {
        return 2.0;
    }
    if (t <= 4.0)
    {
        return 4.0;
    }
    if (t <= 8.0)
    {
        return 8.0;
    }
    if (t <= 16.0)
    {
        return 16.0;
    }
    if (t <= 32.0)
    {
        return 32.0;
    }

    return 64.0;
}

/**
* Dynamic level of detail using sphere algorithm.
* Source adapated from the DirectX 11 Terrain Tessellation example.
*/
float dlodSphere(vec4 p0, vec4 p1, vec2 t0, vec2 t1)
{
    float g_tessellatedTriWidth = 10.0;

    float sampleHeight = texture(TexTerrainHeight, t0).r;
    p0.y = TERRAIN_MIN_HEIGHT + TERRAIN_HEIGHT_RANGE * sampleHeight;
    sampleHeight = texture(TexTerrainHeight, t1).r;
    p1.y = TERRAIN_MIN_HEIGHT + TERRAIN_HEIGHT_RANGE * sampleHeight;


    vec3 offset = dvd_TerrainData[_in[0].dvd_drawID]._positionAndTileScale.xyz;

    vec4 center = 0.5 * (p0 + p1);
    vec4 view0 = mvMatrix * vec4(center.xyz + offset, center.w);
    vec4 view1 = view0;
    view1.x += distance(p0, p1);

    vec4 clip0 = dvd_ProjectionMatrix * view0;
    vec4 clip1 = dvd_ProjectionMatrix * view1;

    clip0 /= clip0.w;
    clip1 /= clip1.w;

    //clip0.xy *= dvd_ViewPort.zw;
    //clip1.xy *= dvd_ViewPort.zw;

    vec2 screen0 = ((clip0.xy + 1.0) / 2.0) * dvd_ViewPort.zw;
    vec2 screen1 = ((clip1.xy + 1.0) / 2.0) * dvd_ViewPort.zw;
    float d = distance(screen0, screen1);

    // g_tessellatedTriWidth is desired pixels per tri edge
    float t = clamp(d / g_tessellatedTriWidth, 0, 64);

    if (t <= 2.0)
    {
        return 2.0;
    }
    if (t <= 4.0)
    {
        return 4.0;
    }
    if (t <= 8.0)
    {
        return 8.0;
    }
    if (t <= 16.0)
    {
        return 16.0;
    }
    if (t <= 32.0)
    {
        return 32.0;
    }

    return 64.0;
}

void main(void)
{
    PassData(gl_InvocationID);

    mat4 mvMatrix = dvd_WorldViewMatrix(VAR.dvd_instanceID);

    // Outer tessellation level
    gl_TessLevelOuter[0] = dlodCameraDistance(gl_in[3].gl_Position, gl_in[0].gl_Position, _in[3]._texCoord, _in[0]._texCoord);
    gl_TessLevelOuter[1] = dlodCameraDistance(gl_in[0].gl_Position, gl_in[1].gl_Position, _in[0]._texCoord, _in[1]._texCoord);
    gl_TessLevelOuter[2] = dlodCameraDistance(gl_in[1].gl_Position, gl_in[2].gl_Position, _in[1]._texCoord, _in[2]._texCoord);
    gl_TessLevelOuter[3] = dlodCameraDistance(gl_in[2].gl_Position, gl_in[3].gl_Position, _in[2]._texCoord, _in[3]._texCoord);

    /*gl_TessLevelOuter[0] = dlodSphere(gl_in[3].gl_Position, gl_in[0].gl_Position, _in[3]._texCoord, _in[0]._texCoord);
    gl_TessLevelOuter[1] = dlodSphere(gl_in[0].gl_Position, gl_in[1].gl_Position, _in[0]._texCoord, _in[1]._texCoord);
    gl_TessLevelOuter[2] = dlodSphere(gl_in[1].gl_Position, gl_in[2].gl_Position, _in[1]._texCoord, _in[2]._texCoord);
    gl_TessLevelOuter[3] = dlodSphere(gl_in[2].gl_Position, gl_in[3].gl_Position, _in[2]._texCoord, _in[3]._texCoord);*/
    
    float tscale_negx = dvd_TerrainData[VAR.dvd_drawID]._tScale.x;
    float tscale_negz = dvd_TerrainData[VAR.dvd_drawID]._tScale.y;
    float tscale_posx = dvd_TerrainData[VAR.dvd_drawID]._tScale.z;
    float tscale_posz = dvd_TerrainData[VAR.dvd_drawID]._tScale.w;

    if (tscale_negx == 2.0) {
        gl_TessLevelOuter[0] = max(2.0, gl_TessLevelOuter[0] * 0.5);
    }

    if (tscale_negz == 2.0) {
        gl_TessLevelOuter[1] = max(2.0, gl_TessLevelOuter[1] * 0.5);
    }

    if (tscale_posx == 2.0) {
        gl_TessLevelOuter[2] = max(2.0, gl_TessLevelOuter[2] * 0.5);
    }

    if (tscale_posz == 2.0) {
        gl_TessLevelOuter[3] = max(2.0, gl_TessLevelOuter[3] * 0.5);
    }

    // Inner tessellation level
    gl_TessLevelInner[0] = 0.5 * (gl_TessLevelOuter[0] + gl_TessLevelOuter[3]);
    gl_TessLevelInner[1] = 0.5 * (gl_TessLevelOuter[2] + gl_TessLevelOuter[1]);

    // Pass the patch verts along
    gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;

    // Output tessellation level (used for wireframe coloring)
    tcs_tessLevel[gl_InvocationID] = gl_TessLevelOuter[0];
}

--TessellationE

#include "nodeBufferedInput.cmn"

layout(binding = TEXTURE_OPACITY)   uniform sampler2D TexTerrainHeight;

struct TerrainNodeData {
    vec4 _positionAndTileScale;
    vec4 _tScale;
};

layout(binding = BUFFER_TERRAIN_DATA, std430) coherent readonly buffer dvd_TerrainBlock
{
    TerrainNodeData dvd_TerrainData[];
};

layout(quads, fractional_even_spacing) in;

patch in float gl_TessLevelOuter[4];
patch in float gl_TessLevelInner[2];

in float tcs_tessLevel[];

out float tes_tessLevel;

vec4 interpolate(in vec4 v0, in vec4 v1, in vec4 v2, in vec4 v3)
{
    vec4 a = mix(v0, v1, gl_TessCoord.x);
    vec4 b = mix(v3, v2, gl_TessCoord.x);
    return mix(a, b, gl_TessCoord.y);
}

vec2 interpolate2(in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3)
{
    vec2 a = mix(v0, v1, gl_TessCoord.x);
    vec2 b = mix(v3, v2, gl_TessCoord.x);
    return mix(a, b, gl_TessCoord.y);
}

vec4 getHeightOffsets(in vec2 tex_coord) {
    const ivec3 off = ivec3(-1, 0, 1);

    float s01 = textureOffset(TexTerrainHeight, tex_coord, off.xy).r;
    float s21 = textureOffset(TexTerrainHeight, tex_coord, off.zy).r;
    float s10 = textureOffset(TexTerrainHeight, tex_coord, off.yx).r;
    float s12 = textureOffset(TexTerrainHeight, tex_coord, off.yz).r;

    return vec4(s01, s21, s10, s12);
}

float getHeight(in vec4 heightOffsets) {
    
    float s01 = heightOffsets.r;
    float s21 = heightOffsets.g;
    float s10 = heightOffsets.b;
    float s12 = heightOffsets.a;

    return (s01 + s21 + s10 + s12) * 0.25;
}

vec3 getNormal(in float sampleHeight, in vec4 heightOffsets) {
    const vec2 size = vec2(2.0, 0.0);

    float s11 = sampleHeight;
    float s01 = heightOffsets.r;
    float s21 = heightOffsets.g;
    float s10 = heightOffsets.b;
    float s12 = heightOffsets.a;

    vec3 va = normalize(vec3(size.xy, s21 - s01));
    vec3 vb = normalize(vec3(size.yx, s12 - s10));

    return cross(va, vb);
}

vec3 getTangent(in vec3 normal) {
    vec3 temp_tangent = vec3(0.0, 0.0, 1.0);
    vec3 bitangent = cross(temp_tangent, normal);
    vec3 tangent = cross(normal, bitangent);
    return tangent;
}

void main()
{
    PassData(0);

    // Calculate the vertex position using the four original points and interpolate depending on the tessellation coordinates.	
    gl_Position = interpolate(gl_in[0].gl_Position, gl_in[1].gl_Position, gl_in[2].gl_Position, gl_in[3].gl_Position);

    // Terrain heightmap coords
    vec2 terrainTexCoord = interpolate2(VAR[0]._texCoord, VAR[1]._texCoord, VAR[2]._texCoord, VAR[3]._texCoord);


    vec4 heightOffsets = getHeightOffsets(terrainTexCoord);

    // Sample the heightmap and offset y position of vertex
    float sampleHeight = getHeight(heightOffsets);
    gl_Position.y = TERRAIN_MIN_HEIGHT + TERRAIN_HEIGHT_RANGE * sampleHeight;

    // Project the vertex to clip space and send it along
    vec3 offset = dvd_TerrainData[VAR[0].dvd_drawID]._positionAndTileScale.xyz;
    _out._vertexW = vec4(gl_Position.xyz + offset, gl_Position.w);

#if !defined(SHADOW_PASS)
    _out._vertexW = dvd_WorldMatrix(VAR[0].dvd_instanceID) * _out._vertexW;
    mat3 normalMatrix = dvd_NormalMatrixWV(VAR[0].dvd_instanceID);
    vec3 normal = getNormal(sampleHeight, heightOffsets);
    _out._normalWV = normalize(normalMatrix * normal);
    _out._tangentWV = normalize(normalMatrix * getTangent(normal));
    _out._bitangentWV = normalize(cross(_out._normalWV, _out._tangentWV));
#endif

    gl_Position = _out._vertexW;

    _out._texCoord = terrainTexCoord;
    _out._vertexWV = dvd_ViewMatrix * _out._vertexW;

    tes_tessLevel = tcs_tessLevel[0];
}

--Geometry

#include "nodeBufferedInput.cmn"

uniform float ToggleWireframe = 0.0;

layout(triangles) in;

in float tes_tessLevel[];

layout(triangle_strip, max_vertices = 4) out;

out vec4 _scrollingUV;

// x = distance, y = depth
smooth out vec2 _waterDetails;

#if defined(_DEBUG)
out vec4 gs_wireColor;
noperspective out vec3 gs_edgeDist;
#endif

#if defined(SHADOW_PASS)
out vec4 geom_vertexWVP;
#endif

void waterDetails(in int index, in mat4 worldMat) {
    vec3 vertexW = VAR[index]._vertexW.xyz;

    float maxDistance = 0.0;
    float minDepth = 1.0;

    float minHeight = (worldMat * vec4(0.0, TERRAIN_MIN_HEIGHT, 0.0, 1.0)).y;

    //for (int i = 0; i < MAX_WATER_BODIES; ++i) {
        float waterWidth = dvd_waterDetails/*[i]*/.x + dvd_waterPositionsW/*[i]*/.x;
        float waterLength = dvd_waterDetails/*[i]*/.y + dvd_waterPositionsW/*[i]*/.z;
        float halfWidth = waterWidth * 0.5;
        float halfLength = waterLength * 0.5;
        if (vertexW.x >= -halfWidth && vertexW.x <= halfWidth &&
            vertexW.z >= -halfLength && vertexW.z <= halfLength) {

            // Distance
            maxDistance = max(maxDistance, 1.0 - clamp(gl_ClipDistance[0], 0.0, 1.0));

            // Current water depth in relation to the minimum possible depth
            minDepth = min(minDepth, clamp(1.0 - (dvd_waterPositionsW.y - vertexW.y) / (dvd_waterPositionsW.y - minHeight), 0.0, 1.0));
        }
    //}
        
    _waterDetails = vec2(maxDistance, minDepth);
}

void scrollingUV(int index) {
    float time2 = float(dvd_time) * 0.0001;
    vec2 noiseUV = VAR[index]._texCoord * UNDERWATER_DIFFUSE_SCALE;
    
    _scrollingUV.st = noiseUV;
    _scrollingUV.pq = noiseUV + time2;
    _scrollingUV.s -= time2;
}

vec4 wireframeColor()
{
    if (tes_tessLevel[0] == 64.0) {
        return vec4(0.0, 0.0, 1.0, 1.0);
    } else if (tes_tessLevel[0] >= 32.0) {
        return vec4(0.0, 1.0, 1.0, 1.0);
    } else if (tes_tessLevel[0] >= 16.0) {
        return vec4(1.0, 1.0, 0.0, 1.0);
    } else if (tes_tessLevel[0] >= 8.0) {
        return vec4(1.0, 1.0, 1.0, 1.0);
    } else {
        return vec4(1.0, 0.0, 0.0, 1.0);
    }
}

vec4 getWVPPositon(int index) {
    return dvd_ViewProjectionMatrix * gl_in[index].gl_Position;
}

void PerVertex(in int i, in vec3 edge_dist, in vec4 wireColor, in mat4 worldMat) {
    PassData(i);
#if defined(SHADOW_PASS)
    geom_vertexWVP = gl_in[i].gl_Position;
#endif

    gl_Position = getWVPPositon(i);

#if !defined(SHADOW_PASS)
    setClipPlanes(gl_in[i].gl_Position);


    waterDetails(i, worldMat);
    scrollingUV(i);

#   if defined(_DEBUG)
    gs_wireColor = wireColor;

    if (i == 0) {
        gs_edgeDist = vec3(edge_dist.x, 0, 0);
    } else if (i == 1) {
        gs_edgeDist = vec3(0, edge_dist.y, 0);
    } else {
        gs_edgeDist = vec3(0, 0, edge_dist.z);
    }
#   endif
#endif
}

void main(void)
{
    vec4 wireColor = wireframeColor();
    mat4 worldMat = dvd_WorldMatrix(VAR[0].dvd_instanceID);

    // Calculate edge distances for wireframe
    vec3 edge_dist = vec3(0.0);
#if defined(_DEBUG)
    if (ToggleWireframe == 1.0)
    {
        vec4 pos0 = getWVPPositon(0);
        vec4 pos1 = getWVPPositon(1);
        vec4 pos2 = getWVPPositon(2);

        vec2 p0 = vec2(dvd_ViewPort.zw * (pos0.xy / pos0.w));
        vec2 p1 = vec2(dvd_ViewPort.zw * (pos1.xy / pos1.w));
        vec2 p2 = vec2(dvd_ViewPort.zw * (pos2.xy / pos2.w));

        float a = length(p1 - p2);
        float b = length(p2 - p0);
        float c = length(p1 - p0);
        float alpha = acos((b*b + c*c - a*a) / (2.0*b*c));
        float beta = acos((a*a + c*c - b*b) / (2.0*a*c));
        edge_dist.x = abs(c * sin(beta));
        edge_dist.y = abs(c * sin(alpha));
        edge_dist.z = abs(b * sin(alpha));
    }
#endif

    // Output verts
    for (int i = 0; i < gl_in.length(); ++i)
    {
        PerVertex(i, edge_dist, wireColor, worldMat);
        EmitVertex();
    }

    // This closes the triangle
    PerVertex(0, edge_dist, wireColor, worldMat);
    EmitVertex();

    EndPrimitive();
}

--Fragment.Depth

layout(early_fragment_tests) in;

void main()
{
}

--Fragment.Shadow

out vec2 _colourOut;
in vec4 geom_vertexWVP;

#include "nodeBufferedInput.cmn"

vec2 computeMoments(in float depth) {
    // Compute partial derivatives of depth.  
    float dx = dFdx(depth);
    float dy = dFdy(depth);
    // Compute second moment over the pixel extents.  
    return vec2(depth, depth*depth + 0.25*(dx*dx + dy*dy));
}

void main()
{
    // Adjusting moments (this is sort of bias per pixel) using partial derivative
    float depth = geom_vertexWVP.z / geom_vertexWVP.w;
    depth = depth * 0.5 + 0.5;
    //_colourOut = computeMoments(exp(DEPTH_EXP_WARP * depth));
    _colourOut = computeMoments(depth);
}

--Fragment

#define CUSTOM_MATERIAL_DATA

#include "BRDF.frag"
#include "terrainSplatting.frag"
#include "velocityCalc.frag"

uniform float ToggleWireframe = 0.0;

in vec4 _scrollingUV;
// x = distance, y = depth
smooth in vec2 _waterDetails;

#if defined(_DEBUG)
in vec4 gs_wireColor;
noperspective in vec3 gs_edgeDist;
#endif

layout(location = 0) out vec4 _colourOut;
layout(location = 1) out vec2 _normalOut;
layout(location = 2) out vec2 _velocityOut;

float getOpacity() {
    return 1.0;
}

vec4 private_albedo = vec4(1.0);
void setAlbedo(in vec4 albedo) {
    private_albedo = albedo;
}

vec4 getAlbedo() {
    return private_albedo;
}

vec3 getEmissive() {
    return private_getEmissive();
}

vec3 getSpecular() {
    return private_getSpecular();
}

float getShininess() {
    return private_getShininess();
}

vec4 CausticsColour() {
    setAlbedo((texture(texWaterCaustics, _scrollingUV.st) +
               texture(texWaterCaustics, _scrollingUV.pq)) * 0.5);

    return getAlbedo(); //getPixelColour(VAR._texCoord);
}

vec4 UnderwaterColour() {

    vec2 coords = VAR._texCoord * UNDERWATER_DIFFUSE_SCALE;
    setAlbedo(texture(texUnderwaterAlbedo, coords));

    vec3 tbn = normalize(2.0 * texture(texUnderwaterDetail, coords).rgb - 1.0);
    setProcessedNormal(getTBNMatrix() * tbn);

    return getAlbedo(); //getPixelColour(VAR._texCoord);
}

vec4 UnderwaterMappingRoutine() {
    return mix(CausticsColour(), UnderwaterColour(), _waterDetails.y);
}

vec4 TerrainMappingRoutine() {
    setAlbedo(getTerrainAlbedo());

    return getAlbedo();//getPixelColour(VAR._texCoord);
}

void main(void)
{
    bumpInit();

    setProcessedNormal(getTerrainNormal());

    vec4 colour = ToSRGB(applyFog(mix(TerrainMappingRoutine(), UnderwaterMappingRoutine(), _waterDetails.x)));
    
#if defined(_DEBUG)
    float d = min(gs_edgeDist.x, gs_edgeDist.y);
    d = min(d, gs_edgeDist.z);

    float LineWidth = 0.75;
    float mixVal = smoothstep(LineWidth - 1, LineWidth + 1, d);

    if (ToggleWireframe == 1.0) {
        _colourOut = mix(gs_wireColor, colour, mixVal);
    } else {
        _colourOut = colour;
    }
#else
    _colourOut = colour;
#endif
    _normalOut = packNormal(getProcessedNormal());
    _velocityOut = velocityCalc(dvd_InvProjectionMatrix, getScreenPositionNormalised());
}

Commits for Divide-Framework/trunk/assets/shaders/GLSL/terrainTess.glsl

Diff revisions: vs.
Revision Author Commited Message
888 Diff Diff IonutCava picture IonutCava Mon 03 Apr, 2017 20:04:19 +0000

[IonutCava]
- Terrain <-> Water body collision checking for caustics

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

886 Diff Diff IonutCava picture IonutCava Wed 29 Mar, 2017 23:36:51 +0000

[Ionut]
- Initial code for multiple water block support (position + length/width/depth)

885 Diff Diff IonutCava picture IonutCava Mon 27 Mar, 2017 21:16:49 +0000

[Ionut]
- Match terrain collision mesh with rendered mesh

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

[Ionut]
- More terrain work

883 Diff Diff IonutCava picture IonutCava Fri 24 Mar, 2017 17:15:58 +0000

[IonutCava]
- More terrain work
- Removed GS-based multi pass for shadows. Replaced with a regular multi-draw submit system (ease-of-use reasons)

882 Diff Diff IonutCava picture IonutCava Thu 23 Mar, 2017 16:49:48 +0000

[IonutCava]
- More work on tessellated terrain rendering: got the mesh to render properly and match the collision mesh’s layout.
- Fixed a bug with GenericDrawCommand RenderOptions
- Added a “query number of generated primitives” option to GenericDrawCommand

881 Diff Diff IonutCava picture IonutCava Tue 21 Mar, 2017 22:07:37 +0000

[IonutCava]
- Multi draw command bug fix: drawCount > 1 should properly register all commands in the command buffer
- More tessellated terrain updates and fixes (still Work In Progress)

880 IonutCava picture IonutCava Mon 20 Mar, 2017 17:27:13 +0000

[IonutCava]
- New tessellated terrain system based on this: http://victorbush.com/2015/01/tessellated-terrain/
— Work in progress: hardcoded values, new code is in Test namespace
- Split terrain geometry in two:
— tessellated rendering data
— physics verts + indices (used for collisions, vegetation, etc)
- Old Chunk system is used only for culling objects and speeding up collision detection