Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / PostprocessEffect.java @ 15aa7d94

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.Dynamic;
23
import org.distorted.library.type.Static;
24

    
25
///////////////////////////////////////////////////////////////////////////////////////////////////
26
// POSTPROCESSING EFFECTS.
27
// 5 Uniforms: 5 per-effect interpolated values.
28

    
29
public abstract class PostprocessEffect extends Effect
30
  {
31
  public static final int NUM_UNIFORMS = 5;
32

    
33
  public static final int BLUR       =0;
34
  public static final int GLOW       =1;
35
  public static final int NUM_EFFECTS=2;
36

    
37
  static final int MAX = 5;
38
  private static final int MAX_UNITY_DIM = 1;
39

    
40
  Dynamic mDynamic0, mDynamic1;
41
  Static mStatic0, mStatic1;
42

    
43
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
44
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
45

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  public PostprocessEffect(int name, float[] unity, int dimension, boolean center, boolean region)
49
    {
50
    super(POSTPROCESS,name,dimension,center,region);
51

    
52
    for(int i=0; i<unity.length; i++)
53
      {
54
      mUnity[name*MAX_UNITY_DIM+i] = unity[i];
55
      }
56

    
57
    mUnityDim[name] = unity.length;
58
    }
59

    
60
///////////////////////////////////////////////////////////////////////////////////////////////////
61

    
62
  public static boolean isUnity(int name, float[] buffer, int index)
63
    {
64
    switch(mUnityDim[name])
65
      {
66
      case 0: return true;
67
      case 1: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ];
68
      case 2: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
69
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1];
70
      case 3: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
71
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
72
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2];
73
      case 4: return buffer[index  ]==mUnity[MAX_UNITY_DIM*name  ] &&
74
                     buffer[index+1]==mUnity[MAX_UNITY_DIM*name+1] &&
75
                     buffer[index+2]==mUnity[MAX_UNITY_DIM*name+2] &&
76
                     buffer[index+3]==mUnity[MAX_UNITY_DIM*name+3];
77
      }
78

    
79
    return false;
80
    }
81
  }
(14-14/23)