OpenGL and Dynamic Shadows

Share your own game ideas, inform the community about your own works in progress, or appraise of other yet-to-be released games.

Moderator: Staff

Sylon
Artist
Posts: 760
Joined: Wed Apr 27, 2005 1:03 pm
Location: Cheyenne, WY

OpenGL and Dynamic Shadows

Postby Sylon » Thu Mar 23, 2006 10:55 pm

I read on gamedev that OpenGL is a "3d API", and then I learned that to make an isometric 2d game with a 3d API you need to..."position your UVs correctly," and also do something right using "textured quads".

I was thinking. Does this mean the 2d art, the objects and sprites in Allacrost are all gonna be wrapped onto invisible 3d surfaces/objects in such a way that it looks 2d but the collisions are in 3d? Or is it all gonna be coded as if it was not a 3d API? Of course HoA won't be isometric, so I can see if it will just be coded in 2d.

Because also I was wondering if Roos could learn how to do "dynamic lighting" like the guy I was telling everyone about who coded Head over Heels. If there is any use in HoA for dynamic shadows, it would look pretty cool. I read that gamedev coders said dynamic shadows could be made with a 3d API or not, but I think with a 3d API it's easier.
-[Sylon Shanings]-, A Servant of Allacrost.
I owe my allegiance to Roots and only Roots! Hail to the dictator!

"DAD GUMMIT I NEEDA GET MY TORUS DOWN." - Sylon's art jabber
User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Re: OpenGL and Dynamic Shadows

Postby Roots » Fri Mar 24, 2006 12:24 am

Sylon wrote:I was thinking. Does this mean the 2d art, the objects and sprites in Allacrost are all gonna be wrapped onto invisible 3d surfaces/objects in such a way that it looks 2d but the collisions are in 3d? Or is it all gonna be coded as if it was not a 3d API? Of course HoA won't be isometric, so I can see if it will just be coded in 2d.


Collision detection is not 3D. That would be pointless. AFAIK, images are not wrapped onto 3D surfaces, but I didn't code the video engine and my knowledge of graphics programming is minimal at best. There is no concept of 3D when using our video engine API.

But roos is the person who can answer your questions with confidence. I can only state what I know, or what I "think" I know. ;)
Image
Sylon
Artist
Posts: 760
Joined: Wed Apr 27, 2005 1:03 pm
Location: Cheyenne, WY

Postby Sylon » Fri Mar 24, 2006 5:42 pm

3d collision detection is pointless in a 2d game you mean? Hmmm maybe I'll come back to this one. That confuses me because of what the other gamedev people said.
-[Sylon Shanings]-, A Servant of Allacrost.
I owe my allegiance to Roots and only Roots! Hail to the dictator!

"DAD GUMMIT I NEEDA GET MY TORUS DOWN." - Sylon's art jabber
User avatar
visage
Former Staff
Posts: 711
Joined: Sat Sep 03, 2005 9:19 pm
Location: USA
Contact:

Postby visage » Sat Mar 25, 2006 4:36 pm

Basically, as far as I know, most 2d engines that use a 3d API simply draw the texture over a "quad". So for example, the Claudius sprite is a texture drawn over a quad. The only difference between a 2d engine and a 3d engine is the Z axis, which we simply ignore in our axis (well, we simulate 3d, but everything is draw using only 2 coordinates)
Sylon
Artist
Posts: 760
Joined: Wed Apr 27, 2005 1:03 pm
Location: Cheyenne, WY

Postby Sylon » Sun Mar 26, 2006 1:35 am

But if you wanted to, you could add the z axis and still use 2d sprites and tiles...right?
-[Sylon Shanings]-, A Servant of Allacrost.
I owe my allegiance to Roots and only Roots! Hail to the dictator!

"DAD GUMMIT I NEEDA GET MY TORUS DOWN." - Sylon's art jabber
User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Postby Roots » Sun Mar 26, 2006 1:41 am

Sylon wrote:But if you wanted to, you could add the z axis and still use 2d sprites and tiles...right?


Yeah, we could.
Image
User avatar
Jetryl
Artist
Posts: 1485
Joined: Fri Aug 26, 2005 7:35 am
Location: Southern Minnesota, USA

Postby Jetryl » Sun Mar 26, 2006 9:44 am

Sylon; to make a long story short, the biggest reason that they use OpenGL here is SPEED. (Correct me if I'm wrong, gentlemen).

3D graphics cards are designed to do special operations really fast - one of these is taking two images; one with partial transparency, and "compositing" them, aka superimposing one on another. In other words, basically every image in the game. Not only that, graphics cards can store images that are commonly used (textures) inside themselves, instead of reloading them from the main memory of the computer, which is slower. There are other reasons, but these are two big ones.

They're basically faking the graphics card into speeding up 2d graphics, which it was never expressly designed to do. It was only designed to do these special caching operations and such on 3d stuff. However, based on the simple fact that 2D is a subset of 3D, it's fairly straightforward.

If they didn't pull this trick, instead of the graphics card doing the work, the central processor would have to do it, on top of everything else it already has to do. This is a waste of a perfectly good graphics card.



That there isn't direct support for doing this kind of thing is really a stupid move on the part of the card/driver/OS makers. In order to really take advantage of a video card, you have to jump through these hoops. This is beyond the built-in 2d "acceleration" of the card. Apple, in typical fashion, already did on OS X - all 2d operations have this same thing happen to them, and it makes stuff scary fast. They call it "Quartz Extreme" (Quartz is the Mac OS X imaging API, which is years ahead of everything else in existence, especially SDL and DirectX 2D).

Anyways, using openGL also makes it much easier to do some other fun stuff, like special magic effects. This is a big "added bonus".
Zorbfish

Postby Zorbfish » Sun Mar 26, 2006 6:17 pm

Yep just about everything Jetryl said is correct. Another reason to do 2D with 3D is you can treat a 2D picture like a 3D object. You can trick the video card to perform transformations on that picture. The common example is rotating a sprite which is very expensive on a CPU (you manually reposition each pixel) as opposed to on the GPU which does that automatically as part of its rendering process.

I agree that the IHVs removing 2D operations was a poor choice. They justified it because you could do the above tricks to accomplish the same thing without them having to design it into the hardware. :(
User avatar
Roots
Dictator
Posts: 8666
Joined: Wed Jun 16, 2004 6:07 pm
Location: Austin TX
Contact:

Postby Roots » Sun Mar 26, 2006 7:03 pm

Yup, right on. Jetryl, does Wesnoth use OpenGL, or does it just use SDL + SDL_image? I always thought it just used SDL, but I never dived deep enough into the code/documentation to confirm that.
Image
User avatar
Jetryl
Artist
Posts: 1485
Joined: Fri Aug 26, 2005 7:35 am
Location: Southern Minnesota, USA

Postby Jetryl » Mon Mar 27, 2006 3:39 am

Roots wrote:Yup, right on. Jetryl, does Wesnoth use OpenGL, or does it just use SDL + SDL_image? I always thought it just used SDL, but I never dived deep enough into the code/documentation to confirm that.


It doesn't use OpenGL at all. I think it uses SDL_image, but I'm not sure. It was really poky before, but prior to 1.0, they did some heavy optimization that really sped things up.

:eyebrow: Still twerks me that the map scrolling is so granular, though - AmbrosiaSW games on my 25mhz quadra scrolled more prettily. That's not the fault of the blitting/image engine so much as the fault of quite how they do scrolling; the fault of the fact that there is only one scrolling velocity - moving the mouse to the edges of the screen should act more like a gas pedal, and less like an on/off switch.

If you want to have good scrolling in Allacrost's map mode, find a mac and download a copy of "Harry the Handsome Executive" from http://www.ambrosiasw.com/games/harry/ and then imitate what that very old game is capable of. It has a camera that, instead of being fixed over the player, either follows the player and "catches up", or anticipates where he is going. It makes everything much more smooth. This would be a good add-on to make after the prologue gets finished.
Sylon
Artist
Posts: 760
Joined: Wed Apr 27, 2005 1:03 pm
Location: Cheyenne, WY

Postby Sylon » Mon Mar 27, 2006 4:41 am

Wow you guys really know your stuff. I'm just glad we can "trick" the program into treating 2d sprites as 3d given the right coordinates.
-[Sylon Shanings]-, A Servant of Allacrost.
I owe my allegiance to Roots and only Roots! Hail to the dictator!

"DAD GUMMIT I NEEDA GET MY TORUS DOWN." - Sylon's art jabber
User avatar
Jetryl
Artist
Posts: 1485
Joined: Fri Aug 26, 2005 7:35 am
Location: Southern Minnesota, USA

Postby Jetryl » Mon Mar 27, 2006 6:18 am

Sylon wrote:Wow you guys really know your stuff. I'm just glad we can "trick" the program into treating 2d sprites as 3d given the right coordinates.


It's actually really simple (the complex part is knowing all the 3d commands).

All you do is take a rectangular plane, and have it/the camera sized right to fit the screen perfectly. You also have it parallel to the screen (meaning it and the screen are like papers in a stack, or floors in a house). Then you just draw on it till you're blue in the face.

(That's really not technically accurate, but that's a good visual to put in your head.)

Return to “Other Game Development”

Who is online

Users browsing this forum: No registered users and 1 guest