Project

General

Profile

« Previous | Next » 

Revision 5e96393c

Added by Leszek Koltunski almost 6 years ago

Make the Sink effect fully 3D.

View differences:

src/main/java/org/distorted/library/effect/EffectName.java
49 49
  SCALE            ( EffectType.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} , 3, 0,     0    , MatrixEffectScale.class        ),
50 50
  SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     3    , MatrixEffectShear.class        ),
51 51

  
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4 ,    3    , VertexEffectDistort.class      ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4 ,    3    , VertexEffectDeform.class       ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, 4 ,    3    , VertexEffectSink.class         ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, 4 ,    3    , VertexEffectPinch.class        ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4 ,    3    , VertexEffectSwirl.class        ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4 ,    3    , VertexEffectWave.class         ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectAlpha.class      ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3 ,    3    , FragmentEffectChroma.class     ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectBrightness.class ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectSaturation.class ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectContrast.class   ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3 ,    3    , FragmentEffectContrast.class   ),
52
  DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDistort.class      ),
53
  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDeform.class       ),
54
  SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, 4,     3    , VertexEffectSink.class         ),
55
  PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 2, 4,     3    , VertexEffectPinch.class        ),
56
  SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4,     3    , VertexEffectSwirl.class        ),
57
  WAVE             ( EffectType.VERTEX  ,   new float[] {0.0f}           , 5, 4,     3    , VertexEffectWave.class         ),
58

  
59
  ALPHA            ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
60
  SMOOTH_ALPHA     ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectAlpha.class      ),
61
  CHROMA           ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3,     3    , FragmentEffectChroma.class     ),
62
  SMOOTH_CHROMA    ( EffectType.FRAGMENT,   new float[] {0.0f}           , 4, 3,     3    , FragmentEffectChroma.class     ),
63
  BRIGHTNESS       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectBrightness.class ),
64
  SMOOTH_BRIGHTNESS( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectBrightness.class ),
65
  SATURATION       ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectSaturation.class ),
66
  SMOOTH_SATURATION( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectSaturation.class ),
67
  CONTRAST         ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectContrast.class   ),
68
  SMOOTH_CONTRAST  ( EffectType.FRAGMENT,   new float[] {1.0f}           , 1, 3,     3    , FragmentEffectContrast.class   ),
69 69

  
70 70
  BLUR             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 1, 0,     0    , PostprocessEffectBlur.class    ),
71 71
  GLOW             ( EffectType.POSTPROCESS,new float[] {0.0f}           , 5, 0,     0    , PostprocessEffectGlow.class    );
src/main/java/org/distorted/library/effect/VertexEffectPinch.java
28 28
/**
29 29
 * Pull all points around the center of the Effect towards a line passing through the center
30 30
 * (that's if degree>=1) or push them away from the line (degree<=1).
31
 *
32
 * Note: this is not a fully 3D effect - the pinching is always within the XY plane; z coordinates
33
 * of all vertices remain unaffected. If someone wants a fully 3D Pinch effect, we'd probably need
34
 * to write another VertexEffectPinch3D with 2 more arguments (latitude and longitude angles defining
35
 * the plane the pinching works on).
31 36
 */
32 37
public class VertexEffectPinch extends VertexEffect
33 38
  {
src/main/java/org/distorted/library/effect/VertexEffectSink.java
66 66
    addEffect(EffectName.SINK,
67 67

  
68 68
        "vec3 center = vUniforms[effect+1].yzw; \n"
69
      + "vec3 ps = center-v.xyz; \n"
69
      + "vec3 ps = center-v; \n"
70 70
      + "float h = vUniforms[effect].x; \n"
71 71
      + "float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h); \n"
72 72

  
73
      + "v.xy += t*ps.xy;"
73
      + "v += t*ps;"
74 74
      );
75 75
    }
76 76

  
src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
27 27
///////////////////////////////////////////////////////////////////////////////////////////////////
28 28
/**
29 29
 * 'Swirl' part of the Mesh, i.e rotate part of it around a point.
30
 *
31
 * Note: this is not a fully 3D effect as the swirling happens entirely within the XY plane - z
32
 * coordinates of all vertices remain unaffected. If someone wants a fully 3D swirling, we'd
33
 * probably need to write another VertixEffectSwirl3D with two additional parameters: latitude and
34
 * longitude angles defining the plane swirling is working on.
30 35
 */
31 36
public class VertexEffectSwirl extends VertexEffect
32 37
  {
src/main/java/org/distorted/library/effect/VertexEffectWave.java
27 27
///////////////////////////////////////////////////////////////////////////////////////////////////
28 28
/**
29 29
 * Directional, sinusoidal wave effect.
30
 *
31
 * Not a fully 3D effect. To achieve a fully 3D one we'd need another parameter making the whole thing
32
 * a 6D effect but there's no room in the Vertex Uniforms which assign only 5 floats for interpolated
33
 * effect values. Rethink this. ATM fully enough for 2.5D meshes like the MeshCubes.
30 34
 */
31 35
public class VertexEffectWave extends VertexEffect
32 36
  {

Also available in: Unified diff