Revision 8a57da61
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
274 | 274 |
{ |
275 | 275 |
float halfZ = halfW*mesh.zFactor; |
276 | 276 |
|
277 |
android.util.Log.d("surface", "SurfaceID "+ surface.getID()+" transparent fragments: "+ surface.returnOldCounter() ); |
|
278 |
|
|
279 | 277 |
mM.compute(currTime); |
280 | 278 |
mV.compute(currTime,halfW,halfH,halfZ); |
281 | 279 |
mF.compute(currTime,halfW,halfH); |
... | ... | |
285 | 283 |
|
286 | 284 |
mMainProgram.useProgram(); |
287 | 285 |
GLES31.glUniform1i(mMainTextureH, 0); |
288 |
GLES31.glUniform1i(mCountIndexH, surface.resetNewCounter() );
|
|
286 |
GLES31.glUniform1i(mCountIndexH, surface.getNewCounter() );
|
|
289 | 287 |
|
290 | 288 |
if( Distorted.GLSL >= 300 ) |
291 | 289 |
{ |
src/main/java/org/distorted/library/main/DistortedOutputSurface.java | ||
---|---|---|
114 | 114 |
|
115 | 115 |
private int mSurfaceID; |
116 | 116 |
private int mLastIndex; |
117 |
private int mLastValue =-1; |
|
117 | 118 |
// end section |
118 | 119 |
//////////////////////////////////////////////////////////////////////////////// |
119 | 120 |
|
... | ... | |
209 | 210 |
|
210 | 211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
211 | 212 |
|
212 |
void debugSSBO()
|
|
213 |
int getNewCounter()
|
|
213 | 214 |
{ |
214 |
android.util.Log.d("SSBO", mIntBuffer.get(0)+" "+mIntBuffer.get(1)+" " |
|
215 |
+mIntBuffer.get(2)+" "+mIntBuffer.get(3) ); |
|
216 |
} |
|
217 |
|
|
218 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
219 |
|
|
220 |
int resetNewCounter() |
|
221 |
{ |
|
222 |
mIntBuffer.put(BUFFERING*mSurfaceID+mLastIndex,0); |
|
223 |
return BUFFERING*mSurfaceID + mLastIndex; |
|
224 |
} |
|
215 |
int value = mIntBuffer.get(BUFFERING*mSurfaceID+mLastIndex); |
|
225 | 216 |
|
226 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
227 |
|
|
228 |
int returnOldCounter()
|
|
229 |
{
|
|
230 |
int ret = mIntBuffer.get(BUFFERING*mSurfaceID+mLastIndex);
|
|
217 |
if( value!=mLastValue )
|
|
218 |
{ |
|
219 |
mLastValue = value;
|
|
220 |
android.util.Log.d("surface", "surface id: "+mSurfaceID+" value now: "+mLastValue);
|
|
221 |
}
|
|
231 | 222 |
|
232 | 223 |
mLastIndex++; |
233 | 224 |
if( mLastIndex>=BUFFERING ) mLastIndex-=BUFFERING; |
234 | 225 |
|
235 |
return ret; |
|
226 |
mIntBuffer.put(BUFFERING*mSurfaceID+mLastIndex,0); |
|
227 |
return BUFFERING*mSurfaceID + mLastIndex; |
|
236 | 228 |
} |
237 | 229 |
|
238 | 230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/raw/main_fragment_shader.glsl | ||
---|---|---|
73 | 73 |
} |
74 | 74 |
#endif |
75 | 75 |
|
76 |
ssbocount[u_currentIndex]= 27 + u_currentIndex;
|
|
76 |
if( color.a < 1.0 ) ssbocount[u_currentIndex]++;
|
|
77 | 77 |
|
78 | 78 |
FRAG_COLOR = vec4(color.rgb * (1.0 + 7.0*v_Normal.z) * 0.125, color.a); |
79 | 79 |
} |
Also available in: Unified diff
SSBO: counting of transparent fragments more or less works now. Still the counters are zeroed out in the wrong place - every time we start rendering something to a given Surface, rather than once per frame.