Project

General

Profile

« Previous | Next » 

Revision 3273dce2

Added by Leszek Koltunski 8 months ago

fix the 'holes in textures' problem.

View differences:

src/main/java/org/distorted/library/effect/VertexEffectDeform.java
133 133
      + "float denomV = 1.0 / (aForce.y + Aw.x);                             \n"
134 134
      + "float denomH = 1.0 / (aForce.x + Aw.y);                             \n"
135 135

  
136
      + "vec3 vertCorr= ONE - aPS / ( aForce+C*aPS + (ONE-sign(aForce)) );   \n"  // avoid division by 0 when force and PS both are 0
136
      + "vec3 one_over_aforce = aForce - 0.001*(sign(aForce)-ONE);           \n"  // avoid division by 0 when force and PS both are 0
137
      + "vec3 vertCorr= ONE - aPS/(C*aPS + one_over_aforce);                 \n"  // avoid division by 0 when force and PS both are 0
137 138

  
138 139
      + "float mvXvert = -B * ps.x * aForce.y * (1.0-quot.y) * denomV;       \n"  // impact the vertical   component of the force vector has on horizontal movement
139 140
      + "float mvYhorz = -B * ps.y * aForce.x * (1.0-quot.x) * denomH;       \n"  // impact the horizontal component of the force vector has on vertical   movement
src/main/java/org/distorted/library/mesh/MeshBase.java
633 633
 *
634 634
 * @y.exclude
635 635
 */
636
   public void debug()
636
   public void debugJobs()
637 637
     {
638 638
     if( mJobNode[0]!=null )
639 639
       {
......
670 670
         sb.append(") ");
671 671
         }
672 672

  
673
       DistortedLibrary.logMessage("MeshBase: "+sb.toString() );
673
       DistortedLibrary.logMessage("MeshBase: "+sb);
674 674
       }
675 675
     }
676 676

  
......
692 692
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+1]);
693 693
       sb.append(',');
694 694
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+POS_ATTRIB+2]);
695
       sb.append(") ");
695
       sb.append(")\n");
696 696
       }
697
     DistortedLibrary.logMessage("MeshBase: "+sb.toString());
697
     DistortedLibrary.logMessage("MeshBase: vertices: \n"+sb);
698
     }
699

  
700
///////////////////////////////////////////////////////////////////////////////////////////////////
701
   /**
702
    * Not part of public API, do not document (public only because has to be used from the main package)
703
    *
704
    * @y.exclude
705
    */
706
   public void printNor()
707
     {
708
     StringBuilder sb = new StringBuilder();
709

  
710
     for(int i=0; i<mNumVertices; i++)
711
       {
712
       sb.append('(');
713
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+NOR_ATTRIB  ]);
714
       sb.append(',');
715
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+NOR_ATTRIB+1]);
716
       sb.append(',');
717
       sb.append(mVertAttribs1[VERT1_ATTRIBS*i+NOR_ATTRIB+2]);
718
       sb.append(")\n");
719
       }
720
     DistortedLibrary.logMessage("MeshBase: normals:\n"+sb);
698 721
     }
699 722

  
700 723
///////////////////////////////////////////////////////////////////////////////////////////////////
......
713 736
       sb.append(' ');
714 737
       }
715 738

  
716
     DistortedLibrary.logMessage("MeshBase: "+sb.toString());
739
     DistortedLibrary.logMessage("MeshBase: "+sb);
717 740
     }
718 741

  
719 742
///////////////////////////////////////////////////////////////////////////////////////////////////
......
745 768
         }
746 769
       }
747 770

  
748
     DistortedLibrary.logMessage("MeshBase: "+sb.toString());
771
     DistortedLibrary.logMessage("MeshBase: "+sb);
749 772
     }
750 773

  
751 774
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1210 1233
 * <p>
1211 1234
 * This is a static, permanent modification of the vertices contained in this Mesh. If the effects
1212 1235
 * contain any Dynamics, the Dynamics will be evaluated at 0.
1213
 *
1214 1236
 * We would call this several times building up a list of Effects to do. This list of effects gets
1215 1237
 * lazily executed only when the Mesh is used for rendering for the first time.
1216 1238
 *
......
1238 1260
 * maps[1] = the map for the 2nd component
1239 1261
 * maps[2] = null
1240 1262
 * maps[3] = the map for the 4th component
1241
 *
1242 1263
 * A map's width and height have to be non-zero (but can be negative!)
1243 1264
 *
1244 1265
 * @param maps            List of texture maps to apply to the texture's components.
......
1270 1291
///////////////////////////////////////////////////////////////////////////////////////////////////
1271 1292
/**
1272 1293
 * Set Effect association.
1273
 *
1274 1294
 * This creates an association between a Component of this Mesh and a Vertex Effect.
1275 1295
 * One can set two types of associations - an 'logical and' and a 'equal' associations and the Effect
1276 1296
 * will only be active on vertices of Components such that
1277
 *
1278 1297
 * (effect andAssoc) & (component andAssoc) != 0 || (effect equAssoc) == (mesh equAssoc)
1279
 *
1280 1298
 * (see main_vertex_shader)
1281
 *
1282 1299
 * The point: this way we can configure the system so that each Vertex Effect acts only on a certain
1283 1300
 * subset of a Mesh, thus potentially significantly reducing the number of render calls.
1284 1301
 */
......
1300 1317
///////////////////////////////////////////////////////////////////////////////////////////////////
1301 1318
/**
1302 1319
 * Set center of a Component.
1303
 *
1304 1320
 * A 'center' of a (effect) component is a 3D point in space. The array of centers gets sent to
1305 1321
 * the vertex shader as a Uniform Buffer Object; in the vertex shader we can then use it to compute
1306 1322
 * the 'Inflation' of the whole Mesh per-component. 'Inflation' is needed by postprocess effects to
1307 1323
 * add the 'halo' around an object.
1308
 *
1309 1324
 * This is all 'per-component' so that a user has a chance to make the halo look right in case of
1310 1325
 * non-convex meshes: then we need to ensure that each component of such a mesh is a convex
1311 1326
 * sub-mesh with its center being more-or-less the center of gravity of the sub-mesh.
......
1344 1359
///////////////////////////////////////////////////////////////////////////////////////////////////
1345 1360
/**
1346 1361
 * Adds an empty (no vertices) texture component to the end of the text component list.
1347
 *
1348 1362
 * Sometimes we want to do this to have several Meshes with equal number of tex components each.
1349 1363
 */
1350 1364
   public void addEmptyTexComponent()

Also available in: Unified diff