Project

General

Profile

« Previous | Next » 

Revision 247d8225

Added by Leszek Koltunski almost 6 years ago

More progress with a more generic 'preprocess' stage of Postprocessing Effects.

View differences:

src/main/java/org/distorted/library/main/EffectQueuePostprocess.java
41 41

  
42 42
  private int mHalo;
43 43

  
44
  static DistortedProgram mPreProgram;
45
  static int mPreColorH;
44
  private static DistortedProgram mPreProgram;
45
  private static int mPreColorH;
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
48 48

  
......
88 88
    }
89 89

  
90 90
///////////////////////////////////////////////////////////////////////////////////////////////////
91
  /**
92
   * Only for use by the library itself.
93
   *
94
   * @y.exclude
95
   */
96
  public static void createPrograms(Resources resources)
91

  
92
  static void createPrograms(Resources resources)
97 93
    {
98 94
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
99 95
    final InputStream mainFragStream = resources.openRawResource(R.raw.preprocess_fragment_shader);
......
125 121
///////////////////////////////////////////////////////////////////////////////////////////////////
126 122
// TODO
127 123

  
128
  private boolean getWriteColor()
124
  private int getWriteColor()
129 125
    {
130
    return false;
126
    return mNumEffects>0 ? ((PostprocessEffect)mEffects[0]).getWriteColor() : 0;
131 127
    }
132 128

  
133 129
///////////////////////////////////////////////////////////////////////////////////////////////////
......
165 161

  
166 162
    if( input.setAsInput() )
167 163
      {
168
      MeshObject    mesh = node.getMesh();
169
      boolean writeColor = getWriteColor();
170
      float       margin = getHalo()*surface.mMipmap;
164
      MeshObject mesh = node.getMesh();
165
      int  writeColor = getWriteColor();
166
      float    margin = getHalo()*surface.mMipmap;
171 167

  
172 168
      float halfW = input.getWidth() / 2.0f;
173 169
      float halfH = input.getHeight()/ 2.0f;
174 170
      float halfZ = halfW*mesh.zFactor;
175 171

  
176
      DistortedRenderState.setUpStencilMark(writeColor);
172
      DistortedRenderState.setUpStencilMark(writeColor!=0);
177 173

  
178 174
      GLES31.glViewport(0, 0, surface.mWidth, surface.mHeight );
179 175

  
......
187 183

  
188 184
      node.getEffects().send(halfW, halfH, halfZ, margin, surface, 2);
189 185

  
186
      float a = (writeColor&255);
187

  
188
      if( a!=0.0f )
189
        {
190
        writeColor = (writeColor>>8);
191
        float b = writeColor&255;
192
        writeColor = (writeColor>>8);
193
        float g = writeColor&255;
194
        writeColor = (writeColor>>8);
195
        float r = writeColor&255;
196

  
197
        GLES31.glUniform4f(mPreColorH, r, g, b, a);
198
        }
199

  
190 200
      GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, mesh.numVertices);
191 201

  
192 202
      DistortedRenderState.unsetUpStencilMark();

Also available in: Unified diff