Archived

This topic is now archived and is closed to further replies.

browny

When your textures flash

Recommended Posts

browny    139
Everything is running perfectly except the damn textures . The problem is , when i look at some far away objects, say a far away wall, and move forward or backward the textures suddenly disappears and reveals whatever is behind the wall and again reappears as i move a little further. As a result , it seems some sorta wave is going along the wall as i continuously move forward or backward. Does it have anything to do with mipmaps ? Well.... i used gluBuild2DMipmaps() and everything but dint work . I even used GL_LINEAR_MIPMAP_NEAREST for the minification filter and GL_LINEAR for the magnification filter, still dint work.... Then i thought it had something to do with the perspective correction and used GL_NICEST for the perspecive correction hint..... STILL DINT WORK what do i do now ??

Share this post


Link to post
Share on other sites
Waverider    169
Try the scene without the textures and see if you get the same visual result. If you do, it's probably Z buffer effects. That can be solved by increasing the bit depth of your Z buffer to 24 or 32. OR, if you upgrade to a way of storing your world such that you can render from back to front without depending on th Z buffer, that would also fix the problem.

If it isn't a Z buffer problem, then I have no idea what's going on


[edited by - Waverider on June 8, 2002 10:21:51 AM]

Share this post


Link to post
Share on other sites
Mathematix    259
Sounds like a rendering problem with your graphics card.

1) What card do you have?
2) Do you have the latest drivers?
3) Which release of OpenGL are you using?

If you using multitextures, have you checked that this is supported by your implementation?

Regards,
Mathematix.

Share this post


Link to post
Share on other sites
browny    139
i dont think it has anything to do with Z-buffer or my card...
lemme explain why:

i am working on this game engine and i arealdy have a nice BSP loader, with a cool particle engine and other blah blah. I downloaded a tut on BSP loading and PVS from Gametutorial.com, which comes with a pre-comiled exe. All I did was; I read the tut and implemented almost the same thing in my engine. But my engine is giving this wierd texturing problem while the tut''s exe is running perfectly which eliminates the possibility of any problem with my 3D card. Moreover , the tut''s exe uses the same 16 bit Z buffer !

I know, its me whos making the mistake ( "somewhere" ). Now, all i need to know is , at what circumstances does this type of texturing problem arise ? This will help me to narrow down my ultimate quest for finding the problem. I''m calling it a quest because i have to dig this problem out from say 2000-3000 lines of codes.

someone with better idea ?

Share this post


Link to post
Share on other sites
Mathematix    259
Well, when I run into OGL problems, I just comment out each line of code until the problem is found.

It''s hard to say what is the problem without seeing your code.

Regards,
Mathematix.

Share this post


Link to post
Share on other sites
Geocyte    196
er... why don''t you try not using mipmaps at all - just a regular, aliasing-prone texture. Then at least you will know if it''s that which is your problem.


Geocyte Has Committed Suicide.

Share this post


Link to post
Share on other sites
browny    139
Maybe u guys are right. I think i''m having problem with my Z-buffer. I turned off all my textures ( let alone mipmaps ) and rendered the scene . But still no improvement. The geometry itself starts flashing as i go further back.

So, last night, i made a small trivial program using glut library just to see how Z-buffer actually works. All i did was, i drew two sphere, one inside another ( inscribed ).

// this is the blue sphere
glutSolidSphere(150,100,100);
// this is the red sphere
glutSolidSphere(100,100,100);

and then i moved my camera straight along the positive Z-Axis, with 10 units every frame. Interestingly, at around 500 units, i mean, when my camera is somewhere around ( 0,0,500) the the red sphere, which is supposed to be inside the blue one, showhow becomes visible and then again disappears as i go a lil further. As i go even further, the red one now becomes completely visible !

Now, 500 is definitely not a very big number that a 16-bit Z-buffer cannot hold. Plus, my near plane was 0.1 and the far plane was 10000. Which means, i used:

gluPerspective(70.0,(float)ScreenWidth/(float)ScreenHeight,0.1,10000);

Now tell me where i''m making the mistake ? I''ve almost written the whole code for you ( since it was so small ).

Share this post


Link to post
Share on other sites
playworker    122
Those values you have used for the near and far clipping planes are far too big. Even using a 24/32 bit Z-Buffer you would have problems.

Try to keep the values around 1 and 100 for the near and far planes...

Incidentally what are the values used in the demo tha you say works perfectly?

Share this post


Link to post
Share on other sites
Waverider    169
16-bit Z buffers have the problem of accuracy at the far end.

Can you try rendering with a 24-bit or 32-bit Z buffer, and see if it improves?

It's kind of like a truncation problem, and making the Z buffer 24 or 32 bit is like adding a few more decimal places for greater accuracy.

EDIT: playworker beat me to it. I could be wrong!

[edited by - Waverider on June 10, 2002 11:08:02 AM]

Share this post


Link to post
Share on other sites
browny    139
"Those values you have used for the near and far clipping planes are far too big "

is 10000 really too big ?? I thought 65535 could easily fit into a 16-bit memory space. Anywayz, maybe itz my complete ignorance on near/far plane and the technologies behind Z-buffer which has led me into this.

i''m still in my skool so didn''t get the chance to test all your theories but i will definitely test all ur theories as soon as i get back home.

But i''m still worried about one thing. Just as playmaker said "try to keep it around 100, " if i really keep the far plane around 100 then how the hell i''m gonna render a big quake level.

Seems like i really have to run back home and check the demo again .

Share this post


Link to post
Share on other sites
davidsporn    126
quote:
Original post by browny
is 10000 really too big ?? I thought 65535 could easily fit into a 16-bit memory space. Anywayz, maybe itz my complete ignorance on near/far plane and the technologies behind Z-buffer which has led me into this.


You''re right for integer value. But I thing that Z-buffering use non-integer value (floating point or fixed point, I don''t remember). Thus 10000 might become too much



----
David Sporn AKA Sporniket

Share this post


Link to post
Share on other sites
yakuza    134
Perhaps this will help you understand the zbuffer better:

From the OpenGL faq:
http://www.frii.com/~martz/oglfaq/depthbuffer.htm


quote:

Now let''s plug in some numbers, for example, n = 0.01, f = 1000 and s = 65535 (i.e., a 16-bit depth buffer)

zw = 1 => ze / we = -0.01000015

zw = s-1 => ze / we = -395.90054

Think about this last line. Everything at eye coordinate depths from -395.9 to -1000 has to map into either 65534 or 65535 in the z buffer. Almost two thirds of the distance between the zNear and zFar clipping planes will have one of two z-buffer values!



---------------------------

I hate have to split some cost of something between three people when you are out to buy something and not being able to do the split correctly due to our inferior base-10 system. -- felonius

Share this post


Link to post
Share on other sites
playworker    122
See above

It''s not a problem with the number fitting into 16 bits, it''s a problem with the way the precision degrades as the depth value increases.

Share this post


Link to post
Share on other sites
browny    139
Hey guys, it WORKED !!!!, Coool
I really didn''t have an idea that a simple Z-buffer could have some so much maths ( or whatever u call it ) in it.

Even when i changed my far plane to some small value, like 500 , the damn program wouldn''t still work. I was just about to pull all my hair off and then i dont why i suddenly decided to change my near plane from 0.1 to 10 ( maybe outta frustation ), and BOOM !, it worked. So not only the far plane, but also the near plane which is an important issue. So , now i feel that the values that are actually written on the Z-buffer are actually some sorta scaled value between the near and far plane. Whatever, i might be wrong...

Wow, i''m quite amazed at the evolution of thoughts and doubts that went all along this discussion, which actually started with a bizarre texturing problem and ended with solving a Z-buffer problem. Cool isn''t ? We almost had some sorta research paper done on Z-buffer. Now i feel that the topic of this discussion should actually be "when Z-buffer plays prank" . But i guess, itz too late. Time to call this discussion off.

CASE CLOSED !

I love you gamedev
Zahid























Share this post


Link to post
Share on other sites
yakuza    134
If you haven''t read the link I posted above, I recommend that you do, it details exactly the behavior that you just described discovering on your own.

The zbuffer is not linear from the near to far plane, it works much like human vision, giving finer granularity to objects closer to the viewer. That''s why changing your near plane helped when changing the far plane didn''t.

The link I posted above to the FAQ has tons of other good info, and is a great read for those of us learning OpenGL.

Glad you got it working.

---------------------------

I hate have to split some cost of something between three people when you are out to buy something and not being able to do the split correctly due to our inferior base-10 system. -- felonius

Share this post


Link to post
Share on other sites
Derilect101    122
Just like everyone said all you have to do is change your near plane on the gluperspective instead of 0.1 change it to 1 or 10 even I had the same problem you did and that fixed it for me

Share this post


Link to post
Share on other sites