Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / FragmentEffectContrast.java @ a0d5e302

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.Data1D;
23
import org.distorted.library.type.Data4D;
24
import org.distorted.library.type.Static4D;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27

    
28
public class FragmentEffectContrast extends FragmentEffect
29
  {
30
  private Data1D mContrast;
31
  private Data4D mRegion;
32

    
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
/**
35
 * Makes a certain sub-region of the Object smoothly change its contrast level.
36
 *
37
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
38
 *                 at any given moment. Valid range: <0,infinity)
39
 * @param region   Region this Effect is limited to.
40
 * @param smooth   If true, the level of 'contrast' will smoothly fade out towards the edges of the region.
41
 */
42
  public FragmentEffectContrast(Data1D contrast, Data4D region, boolean smooth)
43
    {
44
    super(smooth?EffectName.SMOOTH_CONTRAST:EffectName.CONTRAST);
45

    
46
    mContrast = contrast;
47
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
48
    }
49

    
50
///////////////////////////////////////////////////////////////////////////////////////////////////
51
/**
52
 * Makes the whole Object smoothly change its contrast level.
53
 *
54
 * @param contrast 1-dimensional Data that returns the level of contrast we want to have
55
 *                 at any given moment. Valid range: <0,infinity)
56
 */
57
  public FragmentEffectContrast(Data1D contrast)
58
    {
59
    super(EffectName.CONTRAST);
60

    
61
    mContrast = contrast;
62
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
63
    }
64

    
65
///////////////////////////////////////////////////////////////////////////////////////////////////
66

    
67
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
68
    {
69
    mRegion.get(uniforms,index+4,currentDuration,step);
70
    return mContrast.get(uniforms,index,currentDuration,step);
71
    }
72
  }
(8-8/25)