Revision 1d6d261e
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/DistortedOutputSurface.java | ||
---|---|---|
156 | 156 |
} |
157 | 157 |
} |
158 | 158 |
|
159 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
160 |
|
|
161 |
void createBuffers() |
|
162 |
{ |
|
163 |
float mipmap=1.0f; |
|
164 |
|
|
165 |
for(int j=0; j<EffectQuality.LENGTH; j++) |
|
166 |
{ |
|
167 |
mBuffer1[j] = new DistortedFramebuffer(1,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(mWidth*mipmap), (int)(mHeight*mipmap) ); |
|
168 |
mBuffer2[j] = new DistortedFramebuffer(1,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(mWidth*mipmap), (int)(mHeight*mipmap) ); |
|
169 |
mBuffer1[j].mMipmap = mipmap; |
|
170 |
mBuffer2[j].mMipmap = mipmap; |
|
171 |
mipmap *= EffectQuality.MULTIPLIER; |
|
172 |
} |
|
173 |
|
|
174 |
DistortedObject.toDo(); // create the FBOs immediately. This is safe as we must be holding the OpenGL context now. |
|
175 |
|
|
176 |
GLES30.glStencilMask(0xff); |
|
177 |
GLES30.glDepthMask(true); |
|
178 |
GLES30.glColorMask(true,true,true,true); |
|
179 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f); |
|
180 |
GLES30.glClearDepthf(1.0f); |
|
181 |
GLES30.glClearStencil(0); |
|
182 |
|
|
183 |
for(int j=0; j<EffectQuality.LENGTH; j++) |
|
184 |
{ |
|
185 |
mBuffer1[j].setAsOutput(); |
|
186 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT); |
|
187 |
mBuffer2[j].setAsOutput(); |
|
188 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT|GLES30.GL_DEPTH_BUFFER_BIT|GLES30.GL_STENCIL_BUFFER_BIT); |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
159 | 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
160 | 193 |
// Render all children, one by one. If there are no postprocessing effects, just render to THIS. |
161 | 194 |
// Otherwise, render to a buffer and on each change of Postprocessing Bucket, apply the postprocessing |
... | ... | |
174 | 207 |
currP = child.getEffectsPostprocess(); |
175 | 208 |
currB = currP==null ? 0 : currP.getBucket(); |
176 | 209 |
|
177 |
if( lastB!=currB && lastB!=0 ) |
|
178 |
{ |
|
179 |
numRenders += lastP.postprocess(time,this); |
|
180 |
} |
|
210 |
if( lastB!=currB && lastB!=0 ) numRenders += lastP.postprocess(time,this); |
|
181 | 211 |
|
182 |
if( currB==0 ) |
|
183 |
{ |
|
184 |
numRenders += child.draw(time,this); |
|
185 |
} |
|
212 |
if( currB==0 ) numRenders += child.draw(time,this); |
|
186 | 213 |
else |
187 | 214 |
{ |
188 |
if( mBuffer1[0]==null ) |
|
189 |
{ |
|
190 |
float mipmap=1.0f; |
|
191 |
|
|
192 |
for(int j=0; j<EffectQuality.LENGTH; j++) |
|
193 |
{ |
|
194 |
mBuffer1[j] = new DistortedFramebuffer(1,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(mWidth*mipmap), (int)(mHeight*mipmap) ); |
|
195 |
mBuffer2[j] = new DistortedFramebuffer(1,BOTH_DEPTH_STENCIL,TYPE_SYST, (int)(mWidth*mipmap), (int)(mHeight*mipmap) ); |
|
196 |
mBuffer1[j].mMipmap = mipmap; |
|
197 |
mBuffer2[j].mMipmap = mipmap; |
|
198 |
mipmap *= EffectQuality.MULTIPLIER; |
|
199 |
} |
|
200 |
DistortedObject.toDo(); // create the FBOs immediately. This is safe as we must be holding the OpenGL context now. |
|
201 |
} |
|
202 |
|
|
215 |
if( mBuffer1[0]==null ) createBuffers(); |
|
203 | 216 |
numRenders += child.markStencilAndDraw(time,this,currP); |
204 |
|
|
205 |
if( i==num-1 ) |
|
206 |
{ |
|
207 |
numRenders += currP.postprocess(time,this); |
|
208 |
} |
|
217 |
if( i==num-1 ) numRenders += currP.postprocess(time,this); |
|
209 | 218 |
} |
210 | 219 |
|
211 | 220 |
lastP = currP; |
... | ... | |
222 | 231 |
mJobs.add(new Job(t,n,d)); |
223 | 232 |
} |
224 | 233 |
|
234 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
235 |
|
|
236 |
void setAsOutput() |
|
237 |
{ |
|
238 |
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]); |
|
239 |
} |
|
240 |
|
|
225 | 241 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
226 | 242 |
// PUBLIC API |
227 | 243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Move to a new way to detecting depth of postprocessing halos.
This switches off stenciling (hopefully temporarily!)