|  | @@ -272,6 +272,8 @@ void tnsShaderMakeIndex(tnsShader *tns){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      tns->uViewDir = glGetUniformLocation(program, "uViewDir");
 | 
	
		
			
				|  |  |      tns->uViewPos = glGetUniformLocation(program, "uViewPos");
 | 
	
		
			
				|  |  | +    tns->uNear = glGetUniformLocation(program, "uNear");
 | 
	
		
			
				|  |  | +    tns->uFar = glGetUniformLocation(program, "uFar");
 | 
	
		
			
				|  |  |      tns->uFOV = glGetUniformLocation(program, "uFOV");
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  void tnsShaderApplyProjection(tnsShader *tns, tnsMatrix44d m){
 | 
	
	
		
			
				|  | @@ -4365,27 +4367,35 @@ void tnsMakeFoucsSquare(int L, int R, int U, int B, int W){
 | 
	
		
			
				|  |  |      tnsPackAs(GL_LINE_LOOP);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void tnsDrawFloor(int Size, int Span, int *ShowAxis){
 | 
	
		
			
				|  |  | -    int i = 0;
 | 
	
		
			
				|  |  | -    int Lim = Span * 2 + 1;
 | 
	
		
			
				|  |  | -    int Dist = Size * Span;
 | 
	
		
			
				|  |  | +void tnsDrawFloor(real* CamPosition, real Far, int *ShowAxis){
 | 
	
		
			
				|  |  | +    real OrigFar=Far;
 | 
	
		
			
				|  |  | +    real height=CamPosition[2];
 | 
	
		
			
				|  |  | +    real dist=sqrt(Far*Far-height*height);
 | 
	
		
			
				|  |  | +    real spanstart=Far/10000;
 | 
	
		
			
				|  |  | +    real spanl=1e-3,spanh=1e-3;
 | 
	
		
			
				|  |  | +    while((spanl*10)<spanstart){ spanl*=10; } spanh=spanl;
 | 
	
		
			
				|  |  | +    while((spanh*10)<Far){ spanh*=10; }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      tnsFlush();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1,1); glEnable(GL_BLEND);
 | 
	
		
			
				|  |  | +    glEnable(GL_BLEND); glDepthMask(GL_FALSE); glEnable(GL_DEPTH_TEST);
 | 
	
		
			
				|  |  |      tnsUseShader(T->FloorShader);
 | 
	
		
			
				|  |  |      tnsEnableShaderv(T->FloorShader);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    tnsVertex3d(-10000,10000,0);
 | 
	
		
			
				|  |  | -    tnsVertex3d(10000,10000,0);
 | 
	
		
			
				|  |  | -    tnsVertex3d(10000,-10000,0);
 | 
	
		
			
				|  |  | -    tnsVertex3d(-10000,-10000,0);
 | 
	
		
			
				|  |  | -    tnsPackAs(GL_TRIANGLE_FAN);
 | 
	
		
			
				|  |  | -    tnsFlush();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    tnsUseShader(T->immShader);
 | 
	
		
			
				|  |  | -    tnsEnableShaderv(T->immShader);
 | 
	
		
			
				|  |  | -    glDisable(GL_POLYGON_OFFSET_FILL);
 | 
	
		
			
				|  |  | +    glUniform3f(T->FloorShader->uViewPos,LA_COLOR3(CamPosition));
 | 
	
		
			
				|  |  | +    glUniform1f(T->FloorShader->uFar,Far);
 | 
	
		
			
				|  |  | +    
 | 
	
		
			
				|  |  | +    real sp=spanh;
 | 
	
		
			
				|  |  | +    while(sp>=spanl){
 | 
	
		
			
				|  |  | +        real xmin=((int)((CamPosition[0]-dist-sp)/sp))*sp,xmax=((int)((CamPosition[0]+dist+sp)/sp))*sp;
 | 
	
		
			
				|  |  | +        real ymin=((int)((CamPosition[1]-dist-sp)/sp))*sp,ymax=((int)((CamPosition[1]+dist+sp)/sp))*sp;
 | 
	
		
			
				|  |  | +        real ux=xmin; while(ux<xmax){ tnsVertex2d(ux,ymin),tnsVertex2d(ux,ymax); ux+=sp; }
 | 
	
		
			
				|  |  | +        real uy=ymin; while(uy<ymax){ tnsVertex2d(xmin,uy),tnsVertex2d(xmax,uy); uy+=sp; }
 | 
	
		
			
				|  |  | +        tnsPackAs(GL_LINES);
 | 
	
		
			
				|  |  | +        tnsFlush();
 | 
	
		
			
				|  |  | +        Far/=4; if(Far<height) break;
 | 
	
		
			
				|  |  | +        dist=sqrt(Far*Far-height*height); sp/=10;
 | 
	
		
			
				|  |  | +        glUniform1f(T->FloorShader->uFar,Far);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //for (i; i < Lim; i++){
 | 
	
		
			
				|  |  |      //    if (i == Span && ShowAxis[0]) continue;
 | 
	
	
		
			
				|  | @@ -4401,24 +4411,25 @@ void tnsDrawFloor(int Size, int Span, int *ShowAxis){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //tnsPackAs(GL_LINES);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    if (ShowAxis[0]){
 | 
	
		
			
				|  |  | -        tnsColor4d(1, 0, 0, 1);
 | 
	
		
			
				|  |  | -        tnsVertex3d(-Dist, 0, 0);
 | 
	
		
			
				|  |  | -        tnsVertex3d(Dist, 0, 0);
 | 
	
		
			
				|  |  | +    glUniform1f(T->FloorShader->uFar,OrigFar);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    if (ShowAxis[0]){ tnsColor4d(1, 0, 0, 1);
 | 
	
		
			
				|  |  | +        tnsVertex3d(-OrigFar, 0, 0); tnsVertex3d(OrigFar, 0, 0);
 | 
	
		
			
				|  |  |          tnsPackAs(GL_LINES);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    if (ShowAxis[1]){
 | 
	
		
			
				|  |  | -        tnsColor4d(0, 1, 0, 1);
 | 
	
		
			
				|  |  | -        tnsVertex3d(0, -Dist, 0);
 | 
	
		
			
				|  |  | -        tnsVertex3d(0, Dist, 0);
 | 
	
		
			
				|  |  | +    if (ShowAxis[1]){ tnsColor4d(0, 1, 0, 1);
 | 
	
		
			
				|  |  | +        tnsVertex3d(0, -OrigFar, 0); tnsVertex3d(0, OrigFar, 0);
 | 
	
		
			
				|  |  |          tnsPackAs(GL_LINES);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    if (ShowAxis[2]){
 | 
	
		
			
				|  |  | -        tnsColor4d(0, 0, 1, 1);
 | 
	
		
			
				|  |  | -        tnsVertex3d(0, 0, -Dist);
 | 
	
		
			
				|  |  | -        tnsVertex3d(0, 0, Dist);
 | 
	
		
			
				|  |  | +    if (ShowAxis[2]){ tnsColor4d(0, 0, 1, 1);
 | 
	
		
			
				|  |  | +        tnsVertex3d(0, 0, -OrigFar); tnsVertex3d(0, 0, OrigFar);
 | 
	
		
			
				|  |  |          tnsPackAs(GL_LINES);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +    tnsFlush();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    tnsUseShader(T->immShader);
 | 
	
		
			
				|  |  | +    tnsEnableShaderv(T->immShader);
 | 
	
		
			
				|  |  | +    glDepthMask(GL_TRUE);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void tnsDraw2DGrid10(real L, real R, real U, real B, real xmin, real xmax, real ymin, real ymax, real MostDenseW, real MostDenseH,
 |