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
-- 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;
out vec4 _colorOut;

layout(binding = TEX_BIND_POINT_SCREEN)     uniform sampler2D texScreen;
layout(binding = TEX_BIND_POINT_BLOOM)      uniform sampler2D texBloom;
layout(binding = TEX_BIND_POINT_SSAO)       uniform sampler2D texSSAO;
layout(binding = TEX_BIND_POINT_NOISE)      uniform sampler2D texNoise;
layout(binding = TEX_BIND_POINT_BORDER)     uniform sampler2D texVignette;
layout(binding = TEX_BIND_POINT_UNDERWATER) uniform sampler2D texWaterNoiseNM;

uniform float _noiseTile;
uniform float _noiseFactor;
uniform float dvd_time;
uniform float bloomFactor;

uniform float randomCoeffNoise;
uniform float randomCoeffFlash;

subroutine vec4 VignetteRoutineType(in vec4 colorIn);
subroutine vec4 NoiseRoutineType(in vec4 colorIn);
subroutine vec4 BloomRoutineType(in vec4 colorIn);
subroutine vec4 SSAORoutineType(in vec4 colorIn);
subroutine vec4 ScreenRoutineType();
subroutine void OutputRoutineType();

layout(location = 0) subroutine uniform VignetteRoutineType VignetteRoutine;
layout(location = 1) subroutine uniform NoiseRoutineType NoiseRoutine;
layout(location = 2) subroutine uniform BloomRoutineType BloomRoutine;
layout(location = 3) subroutine uniform SSAORoutineType SSAORoutine;
layout(location = 4) subroutine uniform ScreenRoutineType ScreenRoutine;
layout(location = 5) subroutine uniform OutputRoutineType OutputRoutine;

vec4 LevelOfGrey(in vec4 colorIn) {
    return vec4(colorIn.r * 0.299, colorIn.g * 0.587, colorIn.b * 0.114, colorIn.a);
}


subroutine(VignetteRoutineType)
vec4 Vignette(in vec4 colorIn){
    vec4 colorOut = colorIn - (vec4(1,1,1,2) - texture(texVignette, _texCoord));
    return vec4(clamp(colorOut.rgb,0.0,1.0), colorOut.a);
}


subroutine(NoiseRoutineType)
vec4 Noise(in vec4 colorIn){
    return mix(texture(texNoise, _texCoord + vec2(randomCoeffNoise, randomCoeffNoise)), 
               vec4(1.0), randomCoeffFlash) / 3.0 + 2.0 * LevelOfGrey(colorIn) / 3.0;
}


subroutine(BloomRoutineType)
vec4 Bloom(in vec4 colorIn){
    return colorIn + bloomFactor * texture(texBloom, _texCoord);
}


subroutine(SSAORoutineType)
vec4 SSAO(in vec4 colorIn){
    float ssaoFilter = texture(texSSAO, _texCoord).r;
    if(ssaoFilter > 0){
        colorIn.rgb = colorIn.rgb * ssaoFilter;
    }
    return colorIn;
}

subroutine(ScreenRoutineType)
vec4 screenUnderwater(){
    float time2 = dvd_time*0.0001;
    vec2 noiseUV = _texCoord * _noiseTile;
    vec2 uvNormal0 = noiseUV + time2;
    vec2 uvNormal1 = noiseUV;
    uvNormal1.s -= time2;
    uvNormal1.t += time2;
        
    vec3 normal0 = texture(texWaterNoiseNM, uvNormal0).rgb;
    vec3 normal1 = texture(texWaterNoiseNM, uvNormal1).rgb;
    vec3 normal = normalize(2.0 * ((normal0 + normal1) * 0.5) - 1.0);
    
    return clamp(texture(texScreen, _texCoord + _noiseFactor * normal.st), vec4(0.0), vec4(1.0));
}

subroutine(ScreenRoutineType)
vec4 screenNormal(){
    return texture(texScreen, _texCoord);
}

subroutine(SSAORoutineType, BloomRoutineType, NoiseRoutineType, VignetteRoutineType)
vec4 ColorPassThrough(in vec4 colorIn){
    return colorIn;
}

subroutine(OutputRoutineType)
void outputScreen(){
    _colorOut = VignetteRoutine(NoiseRoutine(BloomRoutine(SSAORoutine(ScreenRoutine()))));
}

subroutine(OutputRoutineType)
void outputDepth(){
    float near = dvd_ZPlanesCombined.z;
    float far  = dvd_ZPlanesCombined.w;
    _colorOut = vec4(vec3((2 * near) / (far + near - texture(texScreen, _texCoord).r * (far - near))), 1.0);
}

void main(void){
    OutputRoutine();
}

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

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

298 Diff Diff k1ngp1n picture k1ngp1n Sun 03 Aug, 2014 17:46:29 +0000

[Ionut]
- Final nVidia compatibility commit

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

277 Diff Diff IonutCava picture IonutCava Tue 17 Jun, 2014 19:27:29 +0000

[Ionut] [[BR]]
- Change PostFX shader to be subroutine-based (instead of using if-else statements) [[BR]]

265 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 19:47:56 +0000

[Ionut] [[BR]]
- reworked uniform buffer binding [[BR]]
- modified framebuffer mipmap update [[BR]]

264 Diff Diff k1ngp1n picture k1ngp1n Tue 27 May, 2014 13:04:38 +0000

[Ionut] [[BR]]
- New camera system: [[BR]]
— Stack based (push/pop active camera) [[BR]]
— Per camera frustum [[BR]]
— Per camera projection [[BR]]
— Shadow mapping now uses the new camera system (each light has a shadow camera) [[BR]]
[[BR]]
- New terrain, water and vegetation system: [[BR]]
— Direct import of terrain from L3DT both as 8-bit grayscale and 16-bit raw formats [[BR]]
— Multiple alpha maps for texture splatting support [[BR]]
— Per texture detail map support [[BR]]
— Transform feedback based visibility culling for vegetation [[BR]]
— Alpha-map based vegetation placing on terrain [[BR]]
— Water now uses a refraction map instead of alpha blending for better refraction effects [[BR]]
[[BR]]
- SceneGraph improvements: [[BR]]
— Better bounding box updates from child to parent [[BR]]
— Better onDraw / postDraw implementation [[BR]]
[[BR]]
- Performance improvements: [[BR]]
— Batch 2D rendering tasks together as much as possible[[BR]]
— Improve renderStateBlock hash generation for better sorting [[BR]]
— Move most state related gfx changes from API implementation to the GFXDevice class [[BR]]
— Move viewport stack to the GFXDevice class [[BR]]
— Added various performance counters (frame duration with round-robin query system, draw call count, etc) [[BR]]
— Fixed and improved clip plane management [[BR]]
— Delete client-side texture data after GPU upload [[BR]]
[[BR]]
- New features: [[BR]]
— Added callback support to the Task class so that a specific task may call a function in the main thread upon completion [[BR]]
— Added mouse-wheel zoom support to Orbit/ThirdPerson cameras [[BR]]
— Added 2D Texture Array support (e.g. used for terrain textures) [[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]]

221 Diff Diff k1ngp1n picture k1ngp1n Wed 08 Jan, 2014 18:50:02 +0000

[Ionut] [[BR]]
- Merged branch “Shadows And Animations” back into trunk [[BR]]
- Added DoxygenGUI project file [[BR]]

  • Buggy *
170 k1ngp1n picture k1ngp1n Sun 03 Nov, 2013 17:24:57 +0000

-Moved hardware related code to a separate project [[BR]]
-More work on post-processing: [[BR]]
— HDR rendering is working, but final tonemapping needs more work [[BR]]
-Important changes in BloomPreRenderOperator.cpp, PostFX.cpp and glFrameBufferObject.cpp [[BR]]
-Trailing and leading whitespace cleanups [[BR]]