Revision c207da02
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/DistortedFramebuffer.java | ||
---|---|---|
197 | 197 |
super(width,height,NOT_CREATED_YET,numcolors,depthStencil,NOT_CREATED_YET,TYPE_USER); |
198 | 198 |
} |
199 | 199 |
|
200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
201 |
|
|
202 |
/** |
|
203 |
* Create new offscreen Framebuffer with COLOR0 attachment only. |
|
204 |
* |
|
205 |
* @param width Width of the COLOR0 attachment. |
|
206 |
* @param height Height of the COLOR0 attachment. |
|
207 |
*/ |
|
208 |
@SuppressWarnings("unused") |
|
209 |
public DistortedFramebuffer(int width, int height) |
|
210 |
{ |
|
211 |
super(width,height,NOT_CREATED_YET, 1, NO_DEPTH_NO_STENCIL,NOT_CREATED_YET,TYPE_USER); |
|
212 |
} |
|
213 |
|
|
214 | 200 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
215 | 201 |
/** |
216 | 202 |
* Bind the underlying rectangle of pixels as a OpenGL Texture. |
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
293 | 293 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
294 | 294 |
// two phases: 1. collapse the SSBO 2. blend the ssbo's color |
295 | 295 |
|
296 |
private int oitRender(long currTime, DistortedOutputSurface buffer)
|
|
296 |
private int oitRender(long currTime) |
|
297 | 297 |
{ |
298 |
float corrW = buffer.getWidthCorrection();
|
|
299 |
float corrH = buffer.getHeightCorrection();
|
|
298 |
float corrW = getWidthCorrection(); |
|
299 |
float corrH = getHeightCorrection(); |
|
300 | 300 |
|
301 | 301 |
GLES31.glViewport(0, 0, mWidth, mHeight); |
302 |
setAsOutput(currTime);
|
|
302 |
GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, 0);
|
|
303 | 303 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
304 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, buffer.mDepthStencilH[0]);
|
|
304 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, mDepthStencilH[0]); |
|
305 | 305 |
|
306 | 306 |
DistortedRenderState.switchOffColorDepthStencil(); |
307 | 307 |
DistortedEffects.oitCollapse(this, corrW, corrH ); |
308 | 308 |
|
309 |
GLES31.glActiveTexture(GLES31.GL_TEXTURE1); |
|
310 | 309 |
GLES31.glBindTexture(GLES31.GL_TEXTURE_2D, 0); |
311 | 310 |
|
311 |
setAsOutput(currTime); |
|
312 | 312 |
DistortedRenderState.switchColorDepthOnStencilOff(); |
313 | 313 |
DistortedEffects.oitRender(this, corrW, corrH); |
314 | 314 |
DistortedRenderState.restoreColorDepthStencil(); |
... | ... | |
420 | 420 |
numRenders += currQueue.postprocess(mBuffer); |
421 | 421 |
numRenders += oitBuild(mBuffer[quality]); |
422 | 422 |
GLES31.glMemoryBarrier(GLES31.GL_SHADER_STORAGE_BARRIER_BIT); |
423 |
numRenders += oitRender(time,this); // merge the OIT linked list
|
|
423 |
numRenders += oitRender(time); // merge the OIT linked list |
|
424 | 424 |
clearBuffer(mBuffer[quality]); |
425 | 425 |
} |
426 | 426 |
} // end else (postprocessed child) |
src/main/res/raw/oit_collapse_fragment_shader.glsl | ||
---|---|---|
50 | 50 |
const float S= 2147483647.0; |
51 | 51 |
float depth = texture(u_DepthTexture, v_TexCoordinate).r; |
52 | 52 |
uint texdepth = uint(S*(1.0-depth)/2.0); |
53 |
uint linkedlistdepth = u_Records[curr+1u]; |
|
54 | 53 |
|
55 |
while( curr != 0u && linkedlistdepth > texdepth )
|
|
54 |
while( curr != 0u ) |
|
56 | 55 |
{ |
56 |
if( u_Records[curr+1u] <= texdepth ) |
|
57 |
{ |
|
58 |
u_Records[prev] = 0u; |
|
59 |
break; |
|
60 |
} |
|
61 |
|
|
57 | 62 |
prev = curr; |
58 | 63 |
curr = u_Records[curr]; |
59 |
linkedlistdepth = u_Records[curr+1u]; |
|
60 |
} |
|
61 |
|
|
62 |
if( curr != 0u ) |
|
63 |
{ |
|
64 |
u_Records[prev] = 0u; |
|
65 | 64 |
} |
66 | 65 |
} |
67 | 66 |
else discard; |
Also available in: Unified diff
OIT: fixes. Everything looks correct now except for the curious return of the 'dancing lower-left corner' small glitch in the 'Transparency' app.