2 * liquidity/bloom-filter.vala
4 * Copyright (c) 2008 Patrick Walton <pcwalton@uchicago.edu>
5 * GLSL filter code by Romain Guy <http://www.curious-creature.org/
6 * 2007/02/20/fast-image-processing-with-jogl/>
13 public class BloomFilter
: Filter
{
14 protected override string# glsl_source {
17 "uniform sampler2DRect rectTexture; " +
18 "uniform float brightPassThreshold;" +
20 " vec3 luminanceVector = vec3(0.2125, 0.7154, 0.0721);" +
21 " vec4 sample = texture2DRect(rectTexture, gl_TexCoord[0].st);" +
22 " float luminance = dot(luminanceVector, sample.rgb);" +
23 " luminance = max(0.0, luminance - brightPassThreshold);" +
24 " sample.rgb *= sign(luminance);" +
26 " gl_FragColor = sample;" +
31 private HashMap
<string, weak Float
> _glsl_params
= null;
32 protected override HashMap
<string, weak Float
> glsl_params
{
34 if (_glsl_params
== null) {
35 _glsl_params
= new HashMap
<string, weak Float
>(str_hash
,
39 * Ugh... awful hack. When will Gee support real hash maps
40 * that manage memory properly? :(
43 Float
*fp
= new
Float(0.75F
);
44 _glsl_params
.set("brightPassThreshold", fp
);