Horde3D

Next-Generation Graphics Engine
It is currently 28.04.2024, 08:26

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: 16.04.2008, 05:13 
Offline

Joined: 16.04.2008, 04:44
Posts: 2
Location: Taiwan
Sources excerpted from terrain.cpp:

Code:
            Vec3f corner0( minU + u * stepU, 0, minV + v * stepV);
            Vec3f corner1( minU + u * stepU, 0, minV + (v + 1) * stepV);
            Vec3f corner2( minU + (u + 1) * stepU, 0, minV + v * stepV);
            Vec3f corner3( minU + (u + 1) * stepU, 0, minV + (v + 1) * stepV);


            ......
            
            Plane tri0( corner0, corner1, corner2 );
            Plane tri1( corner1, corner2, corner3 );

            for( float vv = 0; vv <= stepV; vv += pixelStep )
            {
               for( float uu = 0; uu <= stepU; uu += pixelStep )
               {
                  Plane &curTri = uu <= vv ? tri0 : tri1;



Assume (0,0) to be the left-top corner (or any), as follows:

V0 -------V2
| Tri0 / |
| / |
| / Tri1|
V1--------V3

IMHO for statement curTri = tri0 iff uu <= vv to be true, the tri0 should be (V0, V1, V3) and tri1 (V0, V2, V3). Otherwise different rule for deciding curTri needed.


Top
 Profile  
Reply with quote  
PostPosted: 16.04.2008, 11:39 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I've not checked it in detail, but it seems to me that it does not make any difference. But I've found another problem in the terrain rendering.
I can't remember why we had the following statement in the drawTerrainBlock method in terrain.cpp

Code:
float newU = (s * scale + minU) * (terrain->_hmapSize - 1) + 0.4f;
float newV = (t * scale + minV) * (terrain->_hmapSize - 1) + 0.4f;


With this code, the rendering seems not to match with the blockInfo used for the frustum culling (You can check this setting the camera position to x = 278.97134, y = 62.080597, and z = 425.14410 and by adding the following line
to drawTerrainBlock method after the glDrawElements call)
Code:
   
Modules::renderer().drawDebugAABB(bb.getMinCoords(), bb.getMaxCoords(), true);


If you change it to...
Code:
float newU = (s * scale + minU) * (terrain->_hmapSize - 1) + 0.5f;
float newV = (t * scale + minV) * (terrain->_hmapSize - 1) + 0.5f;

...everything seems to be fine in the terrain example. Maybe someone else can check this. During a quick check it solves the still existing frustum culling problems also mentioned in this thread

Edit: To use the drawDebugAABB method correctly you should insert the following line after the if( saveStates ) statement:
Code:
glUseProgram( shader );


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group