Project

General

Profile

« Previous | Next » 

Revision af662543

Added by Leszek Koltunski about 7 years ago

Fixes for z-fighting.

View differences:

src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
48 48

  
49 49
class Effects3DRenderer implements GLSurfaceView.Renderer
50 50
{
51
    private static final float FOV = 70.0f;
52
    private static final float NEAR = 0.1f;
53

  
51 54
    private GLSurfaceView mView;
52 55
    private DistortedTexture mObjectTexture, mBackgroundTexture, mCenterTexture, mRegionTexture;
53 56
    private DistortedEffects mObjectEffects, mBackgroundEffects, mCenterEffects, mRegionEffects;
......
87 90
      MeshObject meshO   = act.getMesh();
88 91
      MeshFlat quad      = new MeshFlat(1,1);
89 92

  
90

  
91 93
      mObjWidth = mObjectTexture.getWidth();
92 94
      mObjHeight= mObjectTexture.getHeight();
93 95
      mObjDepth = mObjectTexture.getDepth(meshO);
......
117 119
      mRegionNode = new DistortedNode(mRegionTexture, mRegionEffects, quad);
118 120

  
119 121
      mScreen = new DistortedScreen();
122
      mScreen.setProjection(FOV, NEAR);
120 123
      mScreen.attach(mBackgroundTexture, mBackgroundEffects, quad );
121 124
      mScreen.attach(mObjectTexture    , mObjectEffects    , meshO);
122 125
      }
......
230 233
      float factorBackX = ((float)width)/backgroundSize;
231 234
      float factorBackY = ((float)height)/backgroundSize;
232 235

  
233
      mBackgroundEffects.move(new Static3D( -width/2, -height/2,-mFactorObj*(mObjWidth+mObjHeight)/2) );
236
      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
237
      mBackgroundEffects.move(new Static3D( -width/2, -height/2, -height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360))) );
234 238
      mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
235 239

  
236 240
      mScreen.resize(width, height);

Also available in: Unified diff