Revision a22c6628
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedEffects.java | ||
---|---|---|
52 | 52 |
*/ |
53 | 53 |
public class DistortedEffects |
54 | 54 |
{ |
55 |
/// MAIN PROGRAM /// |
|
56 |
private static DistortedProgram mMainProgram; |
|
57 |
private static int mMainTextureH; |
|
55 |
static final int MAIN_PROGRAM = 0; |
|
56 |
static final int FEED_PROGRAM = 1; |
|
57 |
static final int NUM_PROGRAMS = 2; |
|
58 |
|
|
59 |
// THIS IS FOR MAIN AND FEEDBACK PROGRAMS /// |
|
58 | 60 |
private static boolean[] mEffectEnabled = new boolean[EffectNames.size()]; |
59 | 61 |
|
60 | 62 |
static |
... | ... | |
67 | 69 |
} |
68 | 70 |
} |
69 | 71 |
|
72 |
/// MAIN PROGRAM /// |
|
73 |
private static DistortedProgram mMainProgram; |
|
74 |
private static int mMainTextureH; |
|
75 |
|
|
70 | 76 |
/// BLIT PROGRAM /// |
71 | 77 |
private static DistortedProgram mBlitProgram; |
72 | 78 |
private static int mBlitTextureH; |
... | ... | |
80 | 86 |
mQuadPositions.put(positionData).position(0); |
81 | 87 |
} |
82 | 88 |
|
83 |
/// DEBUG ONLY /////
|
|
89 |
/// DEBUG PROGRAM /////
|
|
84 | 90 |
private static DistortedProgram mDebugProgram; |
85 | 91 |
|
86 | 92 |
private static int mDebugObjDH; |
87 | 93 |
private static int mDebugMVPMatrixH; |
88 |
/// END DEBUG ////// |
|
94 |
|
|
95 |
/// FEEDBACK PROGRAM // |
|
96 |
private static DistortedProgram mFeedbackProgram; |
|
97 |
|
|
89 | 98 |
|
90 | 99 |
private static float[] mMVPMatrix = new float[16]; |
91 | 100 |
private static float[] mTmpMatrix = new float[16]; |
... | ... | |
104 | 113 |
static void createProgram(Resources resources) |
105 | 114 |
throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException |
106 | 115 |
{ |
107 |
final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader); |
|
108 |
final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader); |
|
109 |
|
|
116 |
//// BOTH MAIN AND FEEDBACK PROGRAMS /////// |
|
110 | 117 |
String mainVertHeader= Distorted.GLSL_VERSION; |
111 | 118 |
String mainFragHeader= Distorted.GLSL_VERSION; |
112 | 119 |
|
... | ... | |
141 | 148 |
//android.util.Log.e("Effects", "vertHeader= "+mainVertHeader); |
142 | 149 |
//android.util.Log.e("Effects", "fragHeader= "+mainFragHeader); |
143 | 150 |
|
144 |
String[] feedback = { "v_Position" }; |
|
151 |
////////////////////////////////////////////////////////////////////////////////////// |
|
152 |
////////// MAIN PROGRAM ////////////////////////////////////////////////////////////// |
|
153 |
////////////////////////////////////////////////////////////////////////////////////// |
|
154 |
final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader); |
|
155 |
final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader); |
|
145 | 156 |
|
146 |
mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL, feedback);
|
|
157 |
mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL); |
|
147 | 158 |
|
148 | 159 |
int mainProgramH = mMainProgram.getProgramHandle(); |
149 | 160 |
EffectQueueFragment.getUniforms(mainProgramH); |
150 |
EffectQueueVertex.getUniforms(mainProgramH); |
|
151 |
EffectQueueMatrix.getUniforms(mainProgramH); |
|
161 |
EffectQueueVertex.getUniforms(MAIN_PROGRAM,mainProgramH);
|
|
162 |
EffectQueueMatrix.getUniforms(MAIN_PROGRAM,mainProgramH);
|
|
152 | 163 |
mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture"); |
153 | 164 |
|
154 |
// BLIT PROGRAM //////////////////////////////////// |
|
165 |
////////////////////////////////////////////////////////////////////////////////////// |
|
166 |
////////// FEEDBACK PROGRAM ////////////////////////////////////////////////////////// |
|
167 |
////////////////////////////////////////////////////////////////////////////////////// |
|
168 |
final InputStream feedVertStream = resources.openRawResource(R.raw.main_vertex_shader); |
|
169 |
final InputStream feedFragStream = resources.openRawResource(R.raw.feedback_fragment_shader); |
|
170 |
|
|
171 |
String[] feedback = { "v_Position" }; |
|
172 |
|
|
173 |
mFeedbackProgram = new DistortedProgram(feedVertStream,feedFragStream, mainVertHeader, Distorted.GLSL_VERSION, Distorted.GLSL, feedback); |
|
174 |
|
|
175 |
int feedProgramH = mFeedbackProgram.getProgramHandle(); |
|
176 |
EffectQueueFragment.getUniforms(feedProgramH); |
|
177 |
EffectQueueVertex.getUniforms(FEED_PROGRAM,feedProgramH); |
|
178 |
EffectQueueMatrix.getUniforms(FEED_PROGRAM,feedProgramH); |
|
179 |
|
|
180 |
////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
////////// BLIT PROGRAM ////////////////////////////////////////////////////////////// |
|
182 |
////////////////////////////////////////////////////////////////////////////////////// |
|
155 | 183 |
final InputStream blitVertStream = resources.openRawResource(R.raw.blit_vertex_shader); |
156 | 184 |
final InputStream blitFragStream = resources.openRawResource(R.raw.blit_fragment_shader); |
157 | 185 |
|
... | ... | |
172 | 200 |
mBlitTextureH = GLES30.glGetUniformLocation( blitProgramH, "u_Texture"); |
173 | 201 |
mBlitDepthH = GLES30.glGetUniformLocation( blitProgramH, "u_Depth"); |
174 | 202 |
|
175 |
// DEBUG ONLY ////////////////////////////////////// |
|
203 |
////////////////////////////////////////////////////////////////////////////////////// |
|
204 |
////////// DEBUG PROGRAM ///////////////////////////////////////////////////////////// |
|
205 |
////////////////////////////////////////////////////////////////////////////////////// |
|
176 | 206 |
final InputStream debugVertexStream = resources.openRawResource(R.raw.test_vertex_shader); |
177 | 207 |
final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader); |
178 | 208 |
|
... | ... | |
189 | 219 |
int debugProgramH = mDebugProgram.getProgramHandle(); |
190 | 220 |
mDebugObjDH = GLES30.glGetUniformLocation( debugProgramH, "u_objD"); |
191 | 221 |
mDebugMVPMatrixH = GLES30.glGetUniformLocation( debugProgramH, "u_MVPMatrix"); |
192 |
// END DEBUG ////////////////////////////////////// |
|
193 | 222 |
} |
194 | 223 |
|
195 | 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
282 | 311 |
GLES30.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
283 | 312 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
284 | 313 |
} |
285 |
|
|
286 | 314 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
287 | 315 |
|
288 | 316 |
void drawPriv(float halfW, float halfH, MeshObject mesh, DistortedOutputSurface surface, long currTime) |
289 | 317 |
{ |
290 |
int error; |
|
291 |
|
|
292 | 318 |
mM.compute(currTime); |
293 | 319 |
mV.compute(currTime); |
294 | 320 |
mF.compute(currTime); |
... | ... | |
300 | 326 |
mMainProgram.useProgram(); |
301 | 327 |
GLES30.glUniform1i(mMainTextureH, 0); |
302 | 328 |
surface.setAsOutput(currTime); |
303 |
mM.send(surface,halfW,halfH,halfZ); |
|
304 |
mM.send(surface,halfW,halfH,halfZ); |
|
305 |
mV.send(halfW,halfH,halfZ); |
|
329 |
mM.send(MAIN_PROGRAM,surface,halfW,halfH,halfZ); |
|
330 |
mV.send(MAIN_PROGRAM,halfW,halfH,halfZ); |
|
306 | 331 |
mF.send(halfW,halfH); |
307 | 332 |
|
308 | 333 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]); |
... | ... | |
312 | 337 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]); |
313 | 338 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
314 | 339 |
|
315 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]); |
|
340 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength); |
|
341 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 ); |
|
342 |
} |
|
316 | 343 |
|
317 |
GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
|
|
344 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
318 | 345 |
|
319 |
error = GLES30.glGetError();
|
|
320 |
if (error != GLES30.GL_NO_ERROR)
|
|
321 |
{
|
|
322 |
throw new RuntimeException("1 glError 0x" + Integer.toHexString(error));
|
|
323 |
}
|
|
346 |
void drawPrivFeedback(float halfW, float halfH, MeshObject mesh, DistortedOutputSurface surface, long currTime)
|
|
347 |
{
|
|
348 |
mM.compute(currTime);
|
|
349 |
mV.compute(currTime);
|
|
350 |
mF.compute(currTime);
|
|
324 | 351 |
|
325 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength); |
|
352 |
float halfZ = halfW*mesh.zFactor; |
|
353 |
|
|
354 |
GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight ); |
|
326 | 355 |
|
327 |
error = GLES30.glGetError(); |
|
356 |
mFeedbackProgram.useProgram(); |
|
357 |
surface.setAsOutput(currTime); |
|
358 |
mM.send(FEED_PROGRAM,surface,halfW,halfH,halfZ); |
|
359 |
mV.send(FEED_PROGRAM,halfW,halfH,halfZ); |
|
360 |
|
|
361 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]); |
|
362 |
GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0); |
|
363 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]); |
|
364 |
GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
|
365 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]); |
|
366 |
GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
|
367 |
|
|
368 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]); |
|
369 |
GLES30.glEnable(GLES30.GL_RASTERIZER_DISCARD); |
|
370 |
GLES30.glBeginTransformFeedback(GLES30.GL_POINTS); |
|
371 |
GLES30.glDrawArrays(GLES30.GL_POINTS, 0, mesh.dataLength); |
|
372 |
|
|
373 |
int error = GLES30.glGetError(); |
|
328 | 374 |
if (error != GLES30.GL_NO_ERROR) |
329 | 375 |
{ |
330 | 376 |
throw new RuntimeException("2 glError 0x" + Integer.toHexString(error)); |
331 | 377 |
} |
332 | 378 |
|
333 | 379 |
GLES30.glEndTransformFeedback(); |
334 |
GLES30.glFlush(); |
|
335 |
|
|
380 |
GLES30.glDisable(GLES30.GL_RASTERIZER_DISCARD); |
|
336 | 381 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 ); |
337 |
|
|
338 |
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
|
|
382 |
/* |
|
383 |
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
|
|
339 | 384 |
|
340 | 385 |
Buffer mappedBuffer = GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT); |
341 | 386 |
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
... | ... | |
349 | 394 |
android.util.Log.d( "Feedback", msgB); |
350 | 395 |
|
351 | 396 |
String msgA = ""; |
352 |
for(int d=0; d<3*(mesh.dataLength-2); d++)
|
|
397 |
for(int d=0; d<mesh.dataLength; d++)
|
|
353 | 398 |
{ |
354 |
if( d==0 || d==1 || ((d-2)%3)==0) |
|
355 |
msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")"; |
|
399 |
msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")"; |
|
356 | 400 |
} |
357 | 401 |
android.util.Log.d( "Feedback", msgA); |
358 | 402 |
|
359 | 403 |
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical"); |
360 | 404 |
|
405 |
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER); |
|
406 |
*/ |
|
361 | 407 |
|
362 | 408 |
/// DEBUG ONLY ////// |
363 | 409 |
// displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime ); |
364 | 410 |
/// END DEBUG /////// |
365 | 411 |
|
366 |
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER); |
|
412 |
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0); |
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
mMainProgram.useProgram(); |
|
418 |
GLES30.glUniform1i(mMainTextureH, 0); |
|
419 |
mM.sendFeedback(MAIN_PROGRAM,surface,halfW,halfH,halfZ); |
|
420 |
mV.sendZero(MAIN_PROGRAM); |
|
421 |
mF.send(halfW,halfH); |
|
367 | 422 |
|
423 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosTBO[0]); |
|
424 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0); |
|
425 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]); |
|
426 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
|
427 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]); |
|
428 |
GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE , GLES30.GL_FLOAT, false, 0, 0); |
|
429 |
|
|
430 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength); |
|
431 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 ); |
|
368 | 432 |
} |
369 | 433 |
|
370 | 434 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/DistortedNode.java | ||
---|---|---|
264 | 264 |
if( input.setAsInput() ) |
265 | 265 |
{ |
266 | 266 |
mState.apply(); |
267 |
mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime); |
|
267 |
mEffects.drawPrivFeedback(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
|
|
268 | 268 |
return 1; |
269 | 269 |
} |
270 | 270 |
|
src/main/java/org/distorted/library/EffectQueueMatrix.java | ||
---|---|---|
46 | 46 |
private static float[] mTmpMatrix = new float[16]; |
47 | 47 |
private static float[] mViewMatrix= new float[16]; |
48 | 48 |
|
49 |
private static int mObjDH; // This is a handle to half a Object dimensions
|
|
50 |
private static int mMVPMatrixH; // pass in the transformation matrix
|
|
51 |
private static int mMVMatrixH; // pass in the modelview matrix.
|
|
49 |
private static int[] mObjDH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
50 |
private static int[] mMVPMatrixH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
51 |
private static int[] mMVMatrixH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
52 | 52 |
|
53 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
54 | 54 |
|
... | ... | |
191 | 191 |
|
192 | 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
193 | 193 |
|
194 |
static void getUniforms(int mProgramH) |
|
194 |
static void getUniforms(int index,int mProgramH)
|
|
195 | 195 |
{ |
196 |
mObjDH = GLES30.glGetUniformLocation(mProgramH, "u_objD"); |
|
197 |
mMVPMatrixH= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix"); |
|
198 |
mMVMatrixH = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
196 |
mObjDH[index] = GLES30.glGetUniformLocation(mProgramH, "u_objD");
|
|
197 |
mMVPMatrixH[index]= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
|
198 |
mMVMatrixH[index] = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
199 | 199 |
} |
200 | 200 |
|
201 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
259 | 259 |
|
260 | 260 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
261 | 261 |
|
262 |
synchronized void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ) |
|
262 |
synchronized void send(int index,DistortedOutputSurface projection, float halfX, float halfY, float halfZ)
|
|
263 | 263 |
{ |
264 | 264 |
constructMatrices(projection,halfX,halfY,halfZ); |
265 | 265 |
|
266 |
GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ); |
|
267 |
GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0); |
|
268 |
GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0); |
|
266 |
GLES30.glUniform3f( mObjDH[index] , halfX, halfY, halfZ); |
|
267 |
GLES30.glUniformMatrix4fv(mMVMatrixH[index] , 1, false, mViewMatrix, 0); |
|
268 |
GLES30.glUniformMatrix4fv(mMVPMatrixH[index], 1, false, mMVPMatrix , 0); |
|
269 |
} |
|
270 |
|
|
271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
272 |
|
|
273 |
synchronized void sendFeedback(int index,DistortedOutputSurface projection, float halfX, float halfY, float halfZ) |
|
274 |
{ |
|
275 |
constructMatrices(projection,halfX,halfY,halfZ); |
|
276 |
|
|
277 |
GLES30.glUniform3f( mObjDH[index] , 0.5f, 0.5f, 0.5f); |
|
278 |
GLES30.glUniformMatrix4fv(mMVMatrixH[index] , 1, false, mViewMatrix, 0); |
|
279 |
GLES30.glUniformMatrix4fv(mMVPMatrixH[index], 1, false, mMVPMatrix , 0); |
|
269 | 280 |
} |
270 | 281 |
|
271 | 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/library/EffectQueueVertex.java | ||
---|---|---|
45 | 45 |
private static final int NUM_UNIFORMS = 12; |
46 | 46 |
private static final int NUM_CACHE = 3; |
47 | 47 |
private static final int INDEX = EffectTypes.VERTEX.ordinal(); |
48 |
private static int mNumEffectsH;
|
|
49 |
private static int mTypeH;
|
|
50 |
private static int mUniformsH;
|
|
48 |
private static int[] mNumEffectsH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
49 |
private static int[] mTypeH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
50 |
private static int[] mUniformsH = new int[DistortedEffects.NUM_PROGRAMS];
|
|
51 | 51 |
|
52 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
53 | 53 |
|
... | ... | |
58 | 58 |
|
59 | 59 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
60 | 60 |
|
61 |
static void getUniforms(int mProgramH) |
|
61 |
static void getUniforms(int index, int mProgramH)
|
|
62 | 62 |
{ |
63 |
mNumEffectsH= GLES30.glGetUniformLocation( mProgramH, "vNumEffects"); |
|
64 |
mTypeH = GLES30.glGetUniformLocation( mProgramH, "vType"); |
|
65 |
mUniformsH = GLES30.glGetUniformLocation( mProgramH, "vUniforms"); |
|
63 |
mNumEffectsH[index]= GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
|
|
64 |
mTypeH[index] = GLES30.glGetUniformLocation( mProgramH, "vType");
|
|
65 |
mUniformsH[index] = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
133 | 133 |
|
134 | 134 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
135 | 135 |
|
136 |
synchronized void send(float halfX, float halfY, float halfZ) |
|
136 |
synchronized void send(int index, float halfX, float halfY, float halfZ)
|
|
137 | 137 |
{ |
138 |
GLES30.glUniform1i( mNumEffectsH, mNumEffects); |
|
138 |
GLES30.glUniform1i( mNumEffectsH[index], mNumEffects);
|
|
139 | 139 |
|
140 | 140 |
if( mNumEffects>0 ) |
141 | 141 |
{ |
... | ... | |
146 | 146 |
mUniforms[NUM_UNIFORMS*i+7] = mCache[NUM_CACHE*i+2]-halfZ; |
147 | 147 |
} |
148 | 148 |
|
149 |
GLES30.glUniform1iv( mTypeH , mNumEffects, mName ,0); |
|
150 |
GLES30.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0); |
|
149 |
GLES30.glUniform1iv( mTypeH[index] , mNumEffects, mName ,0);
|
|
150 |
GLES30.glUniform4fv( mUniformsH[index],(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
|
|
151 | 151 |
} |
152 | 152 |
} |
153 | 153 |
|
154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
155 |
|
|
156 |
synchronized void sendZero(int index) |
|
157 |
{ |
|
158 |
GLES30.glUniform1i( mNumEffectsH[index], 0); |
|
159 |
} |
|
160 |
|
|
154 | 161 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
155 | 162 |
// Do various post-processing on already computed effects. |
156 | 163 |
// 1) here unlike in the fragment queue, we don't have to multiply the points by ModelView matrix because that gets done in the shader. |
src/main/java/org/distorted/library/MeshObject.java | ||
---|---|---|
71 | 71 |
{ |
72 | 72 |
GLES30.glGenBuffers(1, mPosVBO, 0); |
73 | 73 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mPosVBO[0]); |
74 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, mMeshPositions, GLES30.GL_STATIC_READ);
|
|
74 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, mMeshPositions, GLES30.GL_STATIC_DRAW);
|
|
75 | 75 |
} |
76 | 76 |
if( mNorVBO[0]<0 ) |
77 | 77 |
{ |
78 | 78 |
GLES30.glGenBuffers(1, mNorVBO, 0); |
79 | 79 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mNorVBO[0]); |
80 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength* NORMAL_DATA_SIZE*BYTES_PER_FLOAT, mMeshNormals , GLES30.GL_STATIC_READ);
|
|
80 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength* NORMAL_DATA_SIZE*BYTES_PER_FLOAT, mMeshNormals , GLES30.GL_STATIC_DRAW);
|
|
81 | 81 |
} |
82 | 82 |
if( mTexVBO[0]<0 ) |
83 | 83 |
{ |
84 | 84 |
GLES30.glGenBuffers(1, mTexVBO, 0); |
85 | 85 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mTexVBO[0]); |
86 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength* TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture , GLES30.GL_STATIC_READ);
|
|
86 |
GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength* TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture , GLES30.GL_STATIC_DRAW);
|
|
87 | 87 |
} |
88 | 88 |
|
89 |
if( mPosTBO[0]<0 ) // Buffer for Transform Feedback. Since we are rendering with GL_TRIANGLE_STRIP, after passing N vertices |
|
90 |
// we will get (N-2) triangles back, each 3 vertices of 12 bytes. |
|
89 |
if( mPosTBO[0]<0 ) |
|
91 | 90 |
{ |
92 | 91 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mPosTBO[0]); |
93 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(dataLength-2)*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
|
|
92 |
GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
|
|
94 | 93 |
GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0); |
95 | 94 |
} |
96 | 95 |
|
Also available in: Unified diff
Beginnings of support for DistortedEffects.drawPrivFeedback()