Project

General

Profile

Download (4.38 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / effect / PostprocessEffectBlur.java @ d58407a8

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2017 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library.effect;
21

    
22
import org.distorted.library.type.Data2D;
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25
/**
26
 * Blur the Framebuffer.
27
 */
28
public class PostprocessEffectBlur extends PostprocessEffectBlurred
29
  {
30
  private final Data2D mHaloAndRadius;
31

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33
/**
34
 * Only for use by the library itself.
35
 *
36
 * @y.exclude
37
 */
38
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
39
    {
40
    return mHaloAndRadius.get(uniforms,index,currentDuration,step);
41
    }
42

    
43
///////////////////////////////////////////////////////////////////////////////////////////////////
44
/**
45
 * Only for use by the library itself.
46
 *
47
 * @y.exclude
48
 */
49
  public boolean getRenderDirectly()
50
    {
51
    return false;
52
    }
53

    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
// PUBLIC API
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57
/**
58
 * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
59
 */
60
  public static void enable()
61
    {
62
    PostprocessEffectBlurred.enable("BLUR1","BLUR2");
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66
// Clean up of static variables on exit. Called by reflection from super class.
67

    
68
  @SuppressWarnings("unused")
69
  static void destroyStatics()
70
    {
71
    PostprocessEffectBlurred.destroyStatics();
72
    }
73

    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
/**
76
 * Blur the Framebuffer.
77
 *
78
 * @param haloAndRadius First float: the halo.
79
 *                      How far beyond the object does the effect stretch to? Unit: Percentage
80
 *                      of the size of the original object, i.e. Halo=0 --> no halo around, this
81
 *                      would mean sharp edges around the object; Halo=100 --> halo of the size
82
 *                      of the object itself around (in case of blur, this would be - in vast
83
 *                      majority of cases except an object rendered very closely to the near plane-
84
 *                      an overkill).
85
 *                      Second float: the radius.
86
 *                      The 'strength' if the blur of the edges, in pixels. 0 = no blur, 10 =
87
 *                      blur of roughly 10 pixels around the whole halo.
88

    
89
 */
90
  public PostprocessEffectBlur(Data2D haloAndRadius)
91
    {
92
    super(EffectName.BLUR);
93
    mHaloAndRadius = haloAndRadius;
94
    }
95
  }
(18-18/34)