PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl

https://bitbucket.org/lindenlab/viewer-beta/
text | 89 lines | 68 code | 21 blank | 0 comment | 0 complexity | ab745093c46ed703fbcb5545bff03e92 MD5 | raw file
 1/** 
 2 * @file postgiF.glsl
 3 *
 4 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 5 * Second Life Viewer Source Code
 6 * Copyright (C) 2007, Linden Research, Inc.
 7 * 
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation;
11 * version 2.1 of the License only.
12 * 
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Lesser General Public License for more details.
17 * 
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 * 
22 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23 * $/LicenseInfo$
24 */
25 
26
27
28#extension GL_ARB_texture_rectangle : enable
29
30uniform sampler2DRect depthMap;
31uniform sampler2DRect normalMap;
32uniform sampler2DRect giLightMap;
33uniform sampler2D	noiseMap;
34uniform sampler2D	giMip;
35uniform sampler2DRect edgeMap;
36
37
38uniform vec2 delta;
39uniform float kern_scale;
40uniform float gi_edge_weight;
41uniform float gi_blur_brightness;
42
43varying vec2 vary_fragcoord;
44
45void main() 
46{
47	vec2 dlt = kern_scale*delta;
48	float defined_weight = 0.0; 
49	vec3 col = vec3(0.0); 
50	
51	float e = 1.0;
52	
53	for (int i = 1; i < 8; i++)
54	{
55		vec2 tc = vary_fragcoord.xy + float(i) * dlt;
56		
57		e = max(e, 0.0);
58		float wght = e;
59		
60	   	col += texture2DRect(giLightMap, tc).rgb*wght;
61		defined_weight += wght;
62				
63		e *= e;
64		e -=(texture2DRect(edgeMap, tc.xy-dlt*0.25).a+
65			texture2DRect(edgeMap, tc.xy+dlt*0.25).a)*gi_edge_weight;
66	}
67
68	e = 1.0;
69	
70	for (int i = 1; i < 8; i++)
71	{
72		vec2 tc = vary_fragcoord.xy - float(i) * dlt;
73		
74		e = max(e,0.0);
75		float wght = e;
76		
77	   	col += texture2DRect(giLightMap, tc).rgb*wght;
78		defined_weight += wght;
79	
80		e *= e;
81		e -= (texture2DRect(edgeMap, tc.xy-dlt*0.25).a+
82			texture2DRect(edgeMap, tc.xy+dlt*0.25).a)*gi_edge_weight;
83		
84	}
85	
86	col /= max(defined_weight, 0.01);
87
88	gl_FragColor.rgb = col * gi_blur_brightness;
89}