Project

General

Profile

« Previous | Next » 

Revision 29aba2d1

Added by Leszek Koltunski almost 6 years ago

Transparency App: try to postprocess and not-postprocess the Transparent Surfaces.

View differences:

src/main/java/org/distorted/examples/transparency/TransparencyRenderer.java
61 61
    private Static1D[]  mAlphaVector;
62 62
    private DistortedScreen mScreen;
63 63
    private Static3D mMove, mScale, mCenter;
64
    private PostprocessEffectBlur[] mBlur;
65
    private boolean[] mBlurApplied;
66
    private DistortedEffects[] mEffects;
64 67

  
65 68
    Static4D mQuat1, mQuat2;
66 69
    int mScreenMin;
......
83 86
      mAlphaVector  = new Static1D[NUM_OBJECTS];
84 87
      mNode         = new DistortedNode[NUM_OBJECTS];
85 88
      mTex          = new DistortedTexture[NUM_OBJECTS];
89
      mBlur         = new PostprocessEffectBlur[NUM_OBJECTS];
90
      mEffects      = new DistortedEffects[NUM_OBJECTS];
91
      mBlurApplied  = new boolean[NUM_OBJECTS];
86 92

  
87 93
      FragmentEffectAlpha[] alpha  = new FragmentEffectAlpha[NUM_OBJECTS];
88
      DistortedEffects[] effects   = new DistortedEffects[NUM_OBJECTS];
89
      PostprocessEffectBlur[] blur = new PostprocessEffectBlur[NUM_OBJECTS];
90 94

  
91 95
      mMove  = new Static3D(0,0,0);
92 96
      mScale = new Static3D(1.0f,1.0f,1.0f);
......
103 107
        mTex[i]          = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
104 108
        mMoveVector[i]   = new Static3D(0,0,0);
105 109
        mAlphaVector[i]  = new Static1D(0.5f);
110
        mBlur[i]         = new PostprocessEffectBlur(new Static1D(0));
111
        mBlurApplied[i]  = true;
106 112
        alpha[i]         = new FragmentEffectAlpha(mAlphaVector[i]);
107
        blur[i]          = new PostprocessEffectBlur(new Static1D(0));
108
        effects[i]       = new DistortedEffects();
109

  
110
        effects[i].apply(blur[i]);
111
        effects[i].apply(alpha[i]);
112
        effects[i].apply(moveEffect);
113
        effects[i].apply(scaleEffect);
114
        effects[i].apply(quatEffect1);
115
        effects[i].apply(quatEffect2);
116
        effects[i].apply(new MatrixEffectMove(mMoveVector[i]));
117

  
118
        mNode[i] = new DistortedNode(mTex[i], effects[i], mesh );
113
        mEffects[i]      = new DistortedEffects();
114

  
115
        mEffects[i].apply(mBlur[i]);
116
        mEffects[i].apply(alpha[i]);
117
        mEffects[i].apply(moveEffect);
118
        mEffects[i].apply(scaleEffect);
119
        mEffects[i].apply(quatEffect1);
120
        mEffects[i].apply(quatEffect2);
121
        mEffects[i].apply(new MatrixEffectMove(mMoveVector[i]));
122

  
123
        mNode[i] = new DistortedNode(mTex[i], mEffects[i], mesh );
119 124
        mScreen.attach(mNode[i]);
120 125
        }
121 126
      }
122 127

  
128

  
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130

  
131
    void setPostprocess(int object, boolean doIt)
132
      {
133
      if( object>=0 && object<NUM_OBJECTS)
134
        {
135
        if( doIt && !mBlurApplied[object] )
136
          {
137
          mBlurApplied[object] = true;
138
          mEffects[object].apply(mBlur[object]);
139
          }
140
        if( !doIt && mBlurApplied[object] )
141
          {
142
          mBlurApplied[object] = false;
143
          mEffects[object].abortEffect(mBlur[object]);
144
          }
145
        }
146
      }
147

  
123 148
///////////////////////////////////////////////////////////////////////////////////////////////////
124 149

  
125 150
    void setTransparency(int object, float level)

Also available in: Unified diff