Project

General

Profile

« Previous | Next » 

Revision 667884b0

Added by Leszek Koltunski over 4 years ago

Speedup for preapply

View differences:

src/main/java/org/distorted/library/main/DistortedLibrary.java
305 305
    String enabledEffectV= VertexEffect.getAllGLSL();
306 306
    String enabledEffectF= "{}";
307 307

  
308
    fullVertHeader += "#define PREAPPLY\n";
309

  
308 310
    String[] feedback = { "v_Position", "v_endPosition" };
309 311

  
310 312
    try
src/main/java/org/distorted/library/mesh/MeshBase.java
290 290
       {
291 291
       for(int vertex=0; vertex<mNumVertices; vertex++)
292 292
         {
293
         posX = feedback.get(6*vertex  );
294
         posY = feedback.get(6*vertex+1);
295
         posZ = feedback.get(6*vertex+2);
296
         norX = feedback.get(6*vertex+3) - posX;
297
         norY = feedback.get(6*vertex+4) - posY;
298
         norZ = feedback.get(6*vertex+5) - posZ;
299

  
300
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB     ] = posX;
301
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB + 1 ] = posY;
302
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB + 2 ] = posZ;
303

  
304
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB     ] = norX;
305
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB + 1 ] = norY;
306
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB + 2 ] = norZ;
293
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB     ] = feedback.get(6*vertex  );
294
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB + 1 ] = feedback.get(6*vertex+1);
295
         mVertAttribs[vertex*VERT_ATTRIBS + POS_ATTRIB + 2 ] = feedback.get(6*vertex+2);
296
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB     ] = feedback.get(6*vertex+3);
297
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB + 1 ] = feedback.get(6*vertex+4);
298
         mVertAttribs[vertex*VERT_ATTRIBS + NOR_ATTRIB + 2 ] = feedback.get(6*vertex+5);
307 299
         }
308 300

  
309 301
       mVBO.update(mVertAttribs);
src/main/res/raw/main_vertex_shader.glsl
107 107
#endif
108 108
   
109 109
  v_Position      = v;
110
  v_endPosition   = v + n;
110

  
111
#ifdef PREAPPLY
112
  v_endPosition   = n;
113
#else
114
  v_endPosition   = v + 0.5*n;
115
#endif
116

  
111 117
  v_TexCoordinate = a_TexCoordinate;
112 118
  v_Normal        = normalize(vec3(u_MVMatrix*vec4(n,0.0)));
113 119
  gl_Position     = u_MVPMatrix*vec4(v,1.0);

Also available in: Unified diff