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

void main(void)
{
}

-- Geometry

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

out vec4 _posPos;

uniform float dvd_fxaaSubpixShift = 1.0 / 4.0;

void main() {
    vec2 offset = dvd_invScreenDimensions() * (0.5 + dvd_fxaaSubpixShift);

    gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
    _out._texCoord = vec2(1.0, 1.0);
    _posPos = vec4(_out._texCoord, _out._texCoord - offset);
    EmitVertex();

    gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
    _out._texCoord = vec2(0.0, 1.0);
    _posPos = vec4(_out._texCoord, _out._texCoord - offset);
    EmitVertex();

    gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
    _out._texCoord = vec2(1.0, 0.0);
    _posPos = vec4(_out._texCoord, _out._texCoord - offset);
    EmitVertex();

    gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
    _out._texCoord = vec2(0.0, 0.0);
    _posPos = vec4(_out._texCoord, _out._texCoord - offset);
    EmitVertex();

    EndPrimitive();
}

-- Fragment

#define FxaaTexLod0(t, p) textureLod(t, p, 0.0)
#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)

in  vec4 _posPos;
out vec4 _colourOut;

layout(binding = TEXTURE_UNIT0) uniform sampler2D texScreen;
uniform float dvd_fxaaSpanMax = 8.0;
uniform float dvd_fxaaReduceMul = 1.0 / 8.0;
uniform float dvd_fxaaReduceMin = 1.0 / 128.0;

void main(){

/*---------------------------------------------------------*/
    const vec3 luma = vec3(0.299, 0.587, 0.114);
    vec2 invDim = dvd_invScreenDimensions();
    float lumaNW = dot(FxaaTexLod0(texScreen, _posPos.zw).xyz ,luma);
    float lumaNE = dot(FxaaTexOff(texScreen, _posPos.zw, ivec2(1,0), invDim).xyz ,luma);
    float lumaSW = dot(FxaaTexOff(texScreen, _posPos.zw, ivec2(0,1), invDim).xyz ,luma);
    float lumaSE = dot(FxaaTexOff(texScreen, _posPos.zw, ivec2(1,1), invDim).xyz ,luma);
    float lumaM  = dot(FxaaTexLod0(texScreen, _posPos.xy).xyz, luma);
/*---------------------------------------------------------*/
    float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
    float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
/*---------------------------------------------------------*/
    vec2 dir;
    dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
    dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));
/*---------------------------------------------------------*/
    float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * dvd_fxaaReduceMul), dvd_fxaaReduceMin);
    float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);
    dir = min(vec2( dvd_fxaaSpanMax,  dvd_fxaaSpanMax), max(vec2(-dvd_fxaaSpanMax, -dvd_fxaaSpanMax),  dir * rcpDirMin)) * invDim;
/*--------------------------------------------------------*/
    vec3 rgbA = (1.0/2.0) * ( FxaaTexLod0(texScreen, _posPos.xy + dir * (1.0/3.0 - 0.5)).xyz +
                              FxaaTexLod0(texScreen, _posPos.xy + dir * (2.0/3.0 - 0.5)).xyz);
    vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( FxaaTexLod0(texScreen, _posPos.xy + dir * (0.0/3.0 - 0.5)).xyz +
                                                 FxaaTexLod0(texScreen, _posPos.xy + dir * (3.0/3.0 - 0.5)).xyz);
    float lumaB = dot(rgbB, luma);

    
    if((lumaB < lumaMin) || (lumaB > lumaMax)) _colourOut.rgb = rgbA;
    else _colourOut.rgb = rgbB; 

    _colourOut.a = 1.0;
}

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

Diff revisions: vs.
Revision Author Commited Message
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

809 Diff Diff IonutCava picture IonutCava Tue 10 Jan, 2017 17:16:26 +0000

[IonutCava]
- Move velocity calc to the normal colour pass.
- Optimise glFramebuffer and cleanup RTAttachment class

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

604 IonutCava picture IonutCava Sun 13 Dec, 2015 19:04:57 +0000

[IonutCava]
- New post processing system:
— Simplified operators
— PostFX is always enabled. Individual operators are toggles on or off
— Fixed Bloom and adaptive exposure
- Reworked texture creation and resizing
— Saved TextureDescriptor as part of the texture state