Revision 5f7e4f2c
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
---|---|---|
145 | 145 |
* |
146 | 146 |
* @y.exclude |
147 | 147 |
*/ |
148 |
public int apply(float[] uniforms, int index, DistortedOutputSurface[] buffers, int fbo)
|
|
148 |
public int apply(float[] uniforms, int index, DistortedOutputSurface[] buffers) |
|
149 | 149 |
{ |
150 | 150 |
if( mProgram1 ==null) |
151 | 151 |
{ |
... | ... | |
181 | 181 |
int offset = radius + radius*radius/4; |
182 | 182 |
radius = (radius+1)/2; |
183 | 183 |
|
184 |
outBuffer.setAsOutputFBO(fbo); |
|
185 | 184 |
GLES31.glViewport(0, 0, (int)w, (int)h); |
186 | 185 |
|
187 | 186 |
// horizontal glow |
188 | 187 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]*offsetCorrW; |
189 | 188 |
|
190 | 189 |
mProgram1.useProgram(); |
191 |
outBuffer.bindForOutput(2*fbo+1); |
|
192 |
inBuffer.setAsInput(2*fbo); |
|
190 |
outBuffer.setAsOutput(); |
|
191 |
outBuffer.bindForOutput(1); |
|
192 |
inBuffer.setAsInput(0); |
|
193 | 193 |
|
194 | 194 |
GLES31.glColorMask(true,true,true,true); |
195 | 195 |
GLES31.glClearColor(1.0f,1.0f,1.0f,0.0f); |
... | ... | |
210 | 210 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]*offsetCorrH; |
211 | 211 |
|
212 | 212 |
mProgram2.useProgram(); |
213 |
outBuffer.bindForOutput(2*fbo); |
|
214 |
outBuffer.setAsInput(2*fbo+1); |
|
213 |
outBuffer.bindForOutput(0); |
|
214 |
outBuffer.setAsInput(1); |
|
215 |
|
|
216 |
if( mQualityLevel==0 ) |
|
217 |
{ |
|
218 |
GLES31.glEnable(GLES31.GL_BLEND); |
|
219 |
} |
|
215 | 220 |
|
216 | 221 |
GLES31.glUniform1f ( mProgram2.mUniform[0] , n ); |
217 | 222 |
GLES31.glUniform2f ( mProgram2.mUniform[1] , corrW, corrH ); |
... | ... | |
224 | 229 |
GLES31.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES31.GL_FLOAT, false, 0, mQuadTexture); |
225 | 230 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4); |
226 | 231 |
|
232 |
if( mQualityLevel==0 ) |
|
233 |
{ |
|
234 |
GLES31.glDisable(GLES31.GL_BLEND); |
|
235 |
} |
|
236 |
|
|
227 | 237 |
DistortedRenderState.unuseStencilMark(); |
228 | 238 |
|
229 | 239 |
// blit back to inBuffer if we have to |
230 | 240 |
if( mQualityLevel>0 ) |
231 | 241 |
{ |
232 |
inBuffer.setAsOutputFBO(fbo);
|
|
233 |
inBuffer.bindForOutput(2*fbo);
|
|
234 |
outBuffer.setAsInput(2*fbo);
|
|
242 |
inBuffer.setAsOutput();
|
|
243 |
inBuffer.bindForOutput(0);
|
|
244 |
outBuffer.setAsInput(0);
|
|
235 | 245 |
GLES31.glEnable(GLES31.GL_BLEND); |
236 | 246 |
DistortedEffects.blitPriv(inBuffer); |
237 | 247 |
GLES31.glDisable(GLES31.GL_BLEND); |
Also available in: Unified diff
Hide the FBO_QUEUE thing inside the library. The queue is running internally now, without public setAsOutputFBO() thing (simplifies writing postprocess effects)