Project

General

Profile

« Previous | Next » 

Revision e71dd7fb

Added by Leszek Koltunski about 6 years ago

Improve computation of the thickness of the postprocessing halo - should be independent of the size of underlying object now.
Still it is not completely ok, it appears to depend on the ModelView matrix (use the Effects3D app to rotate the object around Z-axis to see this)

View differences:

src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
171 171
    float offsetCorrW = corrW/w;
172 172
    float offsetCorrH = corrH/h;
173 173

  
174
    // try tracking the bug when sometimes the size of the GLOW overlay is wrong
175
    android.util.Log.e("glow", "w="+w+" h="+h+" corrW="+corrW+" corrH="+corrH);
176

  
177 174
    int radius = (int)(uniforms[index]*mQualityScale);
178 175
    if( radius>=MAX_HALO ) radius = MAX_HALO-1;
179 176
    computeGaussianKernel(radius);
src/main/java/org/distorted/library/mesh/MeshCubes.java
57 57
   private int mCols, mRows, mSlices;
58 58
   private int[][] mCubes;
59 59
   private byte[][] mInflateX, mInflateY;
60
   private float mInfCorr;
61 60
   private ArrayList<Edge> mEdges = new ArrayList<>();
62 61

  
63 62
   private int currVert;
......
191 190
       mCols = cols;
192 191
       mRows = desc.length()/cols;
193 192

  
194
       mInfCorr = mRows>mCols ? mRows:mCols;
195
       mInfCorr = mSlices>mInfCorr ? mSlices : mInfCorr;
196

  
197 193
       mCubes    = new int[mRows][mCols];
198 194
       mInflateX = new byte[mRows+1][mCols+1];
199 195
       mInflateY = new byte[mRows+1][mCols+1];
......
230 226
       mInflateX = new byte[mRows+1][mCols+1];
231 227
       mInflateY = new byte[mRows+1][mCols+1];
232 228

  
233
       mInfCorr = mRows>mCols ? mRows:mCols;
234
       mInfCorr = mSlices>mInfCorr ? mSlices : mInfCorr;
235

  
236 229
       for(int col=0; col<mCols; col++)
237 230
         for(int row=0; row<mRows; row++)
238 231
           mCubes[row][col] = 1;
......
663 656
     attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = mNormalY[index];
664 657
     attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = mNormalZ[index];
665 658

  
666
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInfCorr*mInflateX[row][col]/2.0f;
667
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
668
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*vectZ;
659
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
660
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
661
     attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = vectZ;
669 662

  
670 663
     attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB  ] = x;
671 664
     attribs[VERT_ATTRIBS*currVert + TEX_ATTRIB+1] = 1.0f-y;
......
697 690
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = 1.0f;
698 691
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
699 692

  
700
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInfCorr*mInflateX[row][col]/2.0f;
701
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
702
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
693
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
694
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
695
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
703 696

  
704 697
                   texY = (mRows-row+slice)%(2*mRows);
705 698
                   if( texY>mRows ) texY = 2*mRows-texY;
......
722 715
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] =-1.0f;
723 716
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
724 717

  
725
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInfCorr*mInflateX[row][col]/2.0f;
726
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
727
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
718
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
719
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
720
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
728 721

  
729 722
                   texY = (mRows-row+slice)%(2*mRows);
730 723
                   if( texY>mRows ) texY = 2*mRows-texY;
......
747 740
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==WEST ? 0.0f : (side==NORTH?-R:R);
748 741
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
749 742

  
750
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInfCorr*mInflateX[row][col]/2.0f;
751
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
752
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
743
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
744
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
745
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
753 746

  
754 747
                   texX = (col+slice)%(2*mCols);
755 748
                   if( texX>mCols ) texX = 2*mCols-texX;
......
772 765
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+1] = side==EAST ? 0.0f : (side==SOUTH?-R:R);
773 766
                   attribs[VERT_ATTRIBS*currVert + NOR_ATTRIB+2] = (slice==0 ? R : (slice==mSlices ? -R:0) );
774 767

  
775
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInfCorr*mInflateX[row][col]/2.0f;
776
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInfCorr*mInflateY[row][col]/2.0f;
777
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = mInfCorr*z;
768
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB  ] = mInflateX[row][col]/2.0f;
769
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+1] = mInflateY[row][col]/2.0f;
770
                   attribs[VERT_ATTRIBS*currVert + INF_ATTRIB+2] = z;
778 771

  
779 772
                   texX = (col+slice)%(2*mCols);
780 773
                   if( texX>mCols ) texX = 2*mCols-texX;
src/main/java/org/distorted/library/mesh/MeshFlat.java
31 31
  private int mCols, mRows;
32 32
  private int remainingVert;
33 33
  private int numVertices;
34
  private float mInfCorr;
35 34

  
36 35
///////////////////////////////////////////////////////////////////////////////////////////////////
37 36
// Create a flat, full grid.
......
41 40
     mRows=rows;
42 41
     mCols=cols;
43 42

  
44
     mInfCorr = mRows>mCols ? mRows:mCols;
45

  
46 43
     if( cols==1 && rows==1 )
47 44
       {
48 45
       numVertices = 4;
......
72 69
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 0.0f;
73 70
     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = 1.0f;
74 71

  
75
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = (x-0.5f)*mInfCorr;
76
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = (0.5f-y)*mInfCorr;
77
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.01f   *mInfCorr;  // Inflated surface needs to be slightly in front
72
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = (x-0.5f);
73
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = (0.5f-y);
74
     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.01f   ;  // Inflated surface needs to be slightly in front
78 75

  
79 76
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
80 77
     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y;
src/main/res/raw/main_vertex_shader.glsl
145 145

  
146 146
void main()
147 147
  {
148
  vec3 v = 2.0*u_objD*a_Position + u_Inflate*a_Inflate;
148
  vec3 v = 2.0*u_objD*a_Position;
149 149
  vec3 n = a_Normal;
150 150

  
151
  v += (u_objD.x+u_objD.y)*u_Inflate*a_Inflate;
152

  
151 153
#if NUM_VERTEX>0
152 154
  int effect=0;
153 155

  

Also available in: Unified diff