Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / PostprocessEffect.java @ 310e14fb

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 BLUR       =0;
32
  public static final int GLOW       =1;
33
  public static final int NUM_EFFECTS=2;
34

    
35
  static final int MAX = 5;
36
  private static final int MAX_UNITY_DIM = 1;
37

    
38
  Dynamic mDynamic0, mDynamic1;
39
  Static mStatic0, mStatic1;
40

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

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

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

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

    
55
    mUnityDim[name] = unity.length;
56
    }
57

    
58
///////////////////////////////////////////////////////////////////////////////////////////////////
59

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

    
77
    return false;
78
    }
79
  }
(20-20/29)