Project

General

Profile

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

library / src / main / java / org / distorted / library / effect / FragmentEffectSaturation.java @ a1d92a36

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.Dynamic1D;
25
import org.distorted.library.type.Dynamic4D;
26
import org.distorted.library.type.Static1D;
27
import org.distorted.library.type.Static4D;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class FragmentEffectSaturation extends FragmentEffect
32
  {
33
  private Data1D mSaturation;
34
  private Data4D mRegion;
35

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

    
49
    mSaturation = saturation;
50
    mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region);
51
    }
52

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

    
64
    mSaturation = saturation;
65
    mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE);
66
    }
67

    
68
///////////////////////////////////////////////////////////////////////////////////////////////////
69

    
70
  public boolean compute(float[] uniforms, int index, long currentDuration, long step )
71
    {
72
    mRegion.get(uniforms,index+4,currentDuration,step);
73
    return mSaturation.get(uniforms,index,currentDuration,step);
74
    }
75
  }
(9-9/25)