Jump to content
  • Advertisement

Archived

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

oeginc

Reflection Help & Slow texture mapping...

This topic is 5920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

-- This is my first OpenGL program, and the code is pretty sloppy, fair warning -- The idea I had was to have 2 playing cards (King & Queen) "Dance" around eachother over some marble flooring that was reflecting their images as they floated around. Problem #1 ========== My scene renders INCREDIBLY slow (15fps) on one of my computers, and viciously fast (60+fps) on another. The problem here is the machine that it renders slow on, I have been able to successfully run numerous other OpenGL programs that have MUCH more complex scene details, and many many more objects at framerates of 40+ fps easily. As a matter of fact, *MY* code appears to be the *ONLY* code I''ve seen that doesn''t run fast! If any optimization experts can take a look at the code and give me some suggestions, it''d be greatly appreciated (I know I''m doing a couple things here-n-there to speed it up slightly by 1 or 2 fps, but the visual impact wasn''t worth it... If you can find something to speed it up 20+ fps I''ll give ya a donut!) NOTE: Comment out the ENVMAPPING_CODE line to test w/o my hosed environment mapping code. Problem #2 ========== I am *TOTALLY* lost when it comes to environment mapping and/or reflections. I''d like the marble flooring to reflect the images from the playing cards, however, but looking at several environment mapping examples out there, the best I have been able to do is to get the cards to reflect an image of themselves on themselves (Yes, it *IS* a wierd effect and not even remotely close to what I wanted, LOL). If an environment mapping specialist could browse thru this code and give me some suggestions (or even fix it so I have an example based on code I''m familiar with) I would be eternally grateful. The idea behind this project was to create a neat looking effect with a cute concept that people could look at and learn from (it appears that I''m the one doing most of the learning). Download the code from: http://www.oeginc.com/downloads/RotateCard4.zip or click here.

Share this post


Link to post
Share on other sites
Advertisement
Real reflections are done using the stencil buffer - you need to search for a tutorial or have a browse through the OpenGL Red Book.

Environment mapping is a way of making something look as if it is reflecting it''s surroundings without the overheads of real reflections. The only way to do what you want with environment mapping is to render the scene to a texture and use that texture as an environment map - it''s probably faster doing the reflections with the stencil buffer

Share this post


Link to post
Share on other sites
Yeah, I have tried stencil buffers as well, even more lost there.. Is it just me, or is there a lack of good information on these subjects? Perhaps I''m just not looking in the right places... Anyone able to solve these problems? =)

Share this post


Link to post
Share on other sites
You can do proper reflections without the stencil buffer, and its not that hard (I coded up a test case pretty quickly).

1) Draw the reflected scene
2) Clear Z
3) Draw the mirror surface polygon(s)
4) Draw the rest of the scene normally

Works a charm, and is supported on all hardware.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack

Share this post


Link to post
Share on other sites
http://developer.nvidia.com

right top..
perfect shadow volumes for every situation

hm..
demo with source
big paper explaining the whole approach

what else do we need?

(they have TONS of papers about any grafical subject..)

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
You frame rate problem can be related to vsync... Turn it off in the Display Properties of your OGL driver or do in code... I dont rember what the extension is...

Share this post


Link to post
Share on other sites
Ok, I am getting significantly closer to realism now.. I finally got *SOMETHING* to appear, although:

1) It doesn''t look quite "right",

-and-

2) Frame rates have dropped to rediculously low levels...
I am now luck if I can get 2fps in 800x600 mode.

I''ve cleaned up the code quite a bit, and I am now doing the reflections by using the stencil buffers as someone has suggested...

If those OpenGL masters that have sent me some feedback on my code already wouldn''t mind downloading the latest version and see if you can spot some ways of making it faster and look a little more realistic, I''d appreciate it greatly!

(1 of the realism things I''m referring to is that you''ll notice when the card that is flipping head over heals flips, you can see the front/back of the card in the reflection before you would be able to in real life (Ie: the card hasn''t crossed the 1/2 way point yet, but you still see the reflection of the surface that would be facing up in RL)).

The new code is here.

Thanks a million for all the help!

Share this post


Link to post
Share on other sites
quote:
Original post by ANSI2000
You frame rate problem can be related to vsync... Turn it off in the Display Properties of your OGL driver or do in code... I dont rember what the extension is...


I've tried that, didn't appear to make any difference... What I don't understand is that I'm able to view other peoples OpenGL demo's with scenes many times more complex than mine at 30+ fps...


quote:
Original post by davepermen
http://developer.nvidia.com

right top..
perfect shadow volumes for every situation

hm..
demo with source
big paper explaining the whole approach

what else do we need?

(they have TONS of papers about any grafical subject..)

"take a look around" - limp bizkit
www.google.com


I'm not a complete NEWB, I've been programming professionally since 1982. I have done quite a bit of extensive research on the subject, and there really aren't to many articles/examples I've been able to find that explains bit-by-bit what each line does, and why you need it (or don't need it as the case may be).

I've learned what I know now by trial and error, and what works in someone else's code, may not work in yours (as I've found out with this code). I've found SOME examples, but when I implemented them, nothing -- nadda... And since those examples didn't explain WHY they were doing something the way they were, it makes it difficult for me to even attempt to make changes to fix it.

P.S. Thanks to all of you who DID help, it's much appreciated!


[edited by - oeginc on May 7, 2002 1:55:26 PM]

Share this post


Link to post
Share on other sites
Your version 5 file is unavailable, version 4 runs 450 fps on my 1 gig athlon w/ geforce2.

zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!