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
-- Vertex

void main(void)
{
}

-- Geometry

layout(points) in;
layout(triangle_strip, max_vertices = 4) out;

out vec2 _texCoord;

void main() {
    gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
    _texCoord = vec2(1.0, 1.0);
    EmitVertex();

    gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
    _texCoord = vec2(0.0, 1.0);
    EmitVertex();

    gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
    _texCoord = vec2(1.0, 0.0);
    EmitVertex();

    gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
    _texCoord = vec2(0.0, 0.0);
    EmitVertex();

    EndPrimitive();
}

-- Fragment

in vec2 _texCoord;

uniform sampler2D texDepth;
uniform sampler2D texScreen;
 
out vec4 _colorOut;

const float maxz = 0.00035;
const float div_factor = 3.0 ;
const float maxz2 =  maxz * div_factor;
 
float LinearizeDepth(in float z) {
    return (2.0 * dvd_ZPlanesCombined.x ) / 
           (dvd_ZPlanesCombined.y + 
            dvd_ZPlanesCombined.x - 
            z * 
            (dvd_ZPlanesCombined.y - 
             dvd_ZPlanesCombined.x));
}
 
float CompareDepth(in float crtDepth, in vec2 uv1) {
    float dif1 = crtDepth - LinearizeDepth(texture( texDepth, uv1 ).x);
    return clamp(dif1, -maxz, maxz) -  clamp(dif1/div_factor,0.0,maxz2) ;
}
 
void main(void) {
    vec2 UV = _texCoord + vec2(0.0011); 
    float original_pix = LinearizeDepth(texture(texDepth, UV).x);
    float crtRealDepth = original_pix * dvd_ZPlanesCombined.y + dvd_ZPlanesCombined.x;
    
    float increment = 0.013 - clamp(original_pix * 0.4, 0.001, 0.009);  
 
    float dif1 = 0.0; 
    float dif2 = 0.0;
    float dif3 = 0.0;
    float dif4 = 0.0;
    float dif5 = 0.0;
    float dif6 = 0.0;
    float dif7 = 0.0;
    float dif8 = 0.0;
    float dif =  0.0;  

    float increment2 = increment * 0.75;
    vec2 inc1 = vec2(increment2,        0.0);
    vec2 inc2 = vec2(increment2 * 0.7, -increment2 * 0.9);
    vec2 inc3 = vec2(increment2  *0.7,  increment2 * 0.9);
 
    dif1 = CompareDepth(original_pix, UV - inc1);
    dif2 = CompareDepth(original_pix, UV + inc1);
    dif3 = CompareDepth(original_pix, UV + inc2);
    dif4 = CompareDepth(original_pix, UV - inc2);
    dif5 = CompareDepth(original_pix, UV - inc3);
    dif6 = CompareDepth(original_pix, UV + inc3);  
    dif1 += dif2;  
    dif3 += dif4;
    dif5 += dif6;
    dif  = max(dif1, 0.0) + max(dif3, 0.0) + max(dif5, 0.0);

    increment2 += increment;
    inc1 = vec2(increment2,        0.0);
    inc2 = vec2(increment2 * 0.7, -increment2 * 0.9);
    inc3 = vec2(increment2 * 0.7,  increment2 * 0.9);
    dif1 = CompareDepth(original_pix, UV - inc1);
    dif2 = CompareDepth(original_pix, UV + inc1);
    dif3 = CompareDepth(original_pix, UV + inc2);
    dif4 = CompareDepth(original_pix, UV - inc2);
    dif5 = CompareDepth(original_pix, UV - inc3);
    dif6 = CompareDepth(original_pix, UV + inc3);
    dif1 += dif2;  
    dif3 += dif4;
    dif5 += dif6;
    dif  += (max(dif1, 0.0) + max(dif3, 0.0) + max(dif5, 0.0)) * 0.7;
 
    increment2 += increment * 1.25;
    inc1 = vec2(increment2,        0.0);
    inc2 = vec2(increment2 * 0.7, -increment2 * 0.9);
    inc3 = vec2(increment2 * 0.7,  increment2 * 0.9);
    dif1 = CompareDepth(original_pix, UV - inc1);
    dif2 = CompareDepth(original_pix, UV + inc1);
    dif3 = CompareDepth(original_pix, UV + inc2);
    dif4 = CompareDepth(original_pix, UV - inc2);
    dif5 = CompareDepth(original_pix, UV - inc3);
    dif6 = CompareDepth(original_pix, UV + inc3);  
    dif1 += dif2;
    dif3 += dif4;
    dif5 += dif6 ;
    dif  += (max(dif1, 0.0) + max(dif3, 0.0) + max(dif5, 0.0)) * 0.5;

    _colorOut = (vec3(1.0 - dif * (dvd_ZPlanesCombined.y + dvd_ZPlanesCombined.x) * 255), 1.0);
}

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

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)

283 Diff Diff IonutCava picture IonutCava Tue 01 Jul, 2014 18:16:16 +0000

[Ionut][[BR]]
- Upload Viewport, camera position and zPlanes data to the gpu using the _matricesBuffer instead of ShaderProgram’s “uploadNodeMatrices” method [[BR]]
- Removed most matrices constructed with the worldMatrix (worldView, worldViewProjection, etc) to allow better batching of transforms. [[BR]]
— Both changes will allow the elimination of the “uploadNodeMatrices” and “setLoD” methods [[BR]]

263 Diff Diff k1ngp1n picture k1ngp1n Fri 09 May, 2014 16:43:53 +0000

[Ionut] [[BR]]
- Fullscreen quads are now rendered via Geometry Shaders [[BR]]
- Implemented shader subroutines [[BR]]
- Improved CVSM’s quality [[BR]]
- Separated shadow only light properties from general light properties in separate UBOs to improve update performance [[BR]]
- Removed shader mask and instead try to load all available shaders from a given file [[BR]]
- Added a method (hackish) of changing projection properties at runtime (e.g. z planes) [[BR]]
- Fixed a comparison bug in RenderStateBlock class (forgot to clean it at last commit) [[BR]]
- Fixed clipping plane upload to shader programs [[BR]]

188 Diff Diff k1ngp1n picture k1ngp1n Wed 27 Nov, 2013 13:05:09 +0000

[Ionut][[BR]]
- Small lighting optimization (found it thanks to Adrian-Marian Iusca) [[BR]]
— Since only enabled lights are parsed for every node on every draw call, "dvd_lightEnabled[i]" isn’t needed anymore in the shaders [[BR]]

171 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 18:15:06 +0000

-Replaced all tabs with spaces [[BR]]

169 k1ngp1n picture k1ngp1n Tue 29 Oct, 2013 21:17:29 +0000

Ionut: [[BR]]
- Code cleanups and optimizations [[BR]]
- Better memory allocation and deallocation tracking and logging [[BR]]
- Added vertex color support for VBOs [[BR]]
-Improved PostProcessing: [[BR]]
— A lot of code cleanups and scalability was increased [[BR]]
-— HDR lighting with automatic exposure, God Rays and working SSAO will be added in the next commit [[BR]]
— Added single pass SSAO by Aurel Manea [[BR]]
-— Not finished – a lot of artifacts [[BR]]
— Reduced the VRAM requirements for most render targets by using smaller data types [[BR]]