Sign in to follow this  
workaround

Programming fake 3d using sdl?

Recommended Posts

[Solved] this topic is solved to what I wanted as an answer. Is it worth it to make 3d game with out openGL. This game is mostly 2d. It seems it is not worth the time if it potentially may require higher CPU model.

 

I'm interested in using sdl to make a make a ground plane that works like in sonic the hedgehog 3 bonus levels(Link bellow). I'm not interested a 3d environment like opengl on top of sdl.

 

I want to know if it is possible to take a image and distort the image so it looks like it is on the ground. The viewer would always be at the same angle link in the link bellow.

 

https://www.youtube.com/watch?v=_QCmIbYm5Rg

Edited by workaround

Share this post


Link to post
Share on other sites


Do you have a specific reason for not wanting to use OpenGL? A self-imposed limitation to experiment with a technique is just fine, but if you're of the mind that OpenGL isn't worth learning to do this, you might want to reconsider.

 

Raytracing seems to close to what I was looking for. Because I have not done this before I did not know what to search. Now that I have done just a little bit of searching it seems that using raytracing in a video game is not a good choice unless everyone is using a server farm to play the game.

 

Now I'm getting into some opengl questions(yes and no are not what I'm looking for). I would like to know the api calls or a link to tutorial would be nice.

1. Can I map a png to a plain in opengl and still have transparency?

2. Can I map only a portion of a image to a plain?

Share this post


Link to post
Share on other sites

1. Can I map a png to a plain in opengl and still have transparency?
2. Can I map only a portion of a image to a plain?


1. Yes. Translucency is a part of the blending mode in use, the alpha channel generated in the fragment shader (which it will usually acquire from a texture), and whatever you drew first (OpenGL by itself does no sorting or painter's algorithm, so you want to be sure to draw whatever is behind the translucent object first).

2. Yes. It's up to the fragment shader to determine how to sample the texture. A typical pattern to supply texture coordinates (often called the "UV" coordinates) that inform the shader which region of the texture to sample. If you give texture coordinates from [0.5,0.5] to [1.0,1.0] on an otherwise 'standard' sampling fragment shader, you will only sample the bottom-right quarter of the texture instead of the whole thing, for example.

More advanced graphics effects are almost always possible as well, but may require some non-intuitive approaches or advanced math knowledge.

Share this post


Link to post
Share on other sites

I'm fairly sure that in that particular instance, they've basically just rendered one 90° rotation animation and one "walk one tile forward" animation of the checkerboard, de-duplicated it into a tile map to save video memory, and are just playing those two animations with palette swapping to set the colours. And because will only need to have rendered the checkboard animation once, every time the player makes a full step forward, they swap the two colours of the checkboard palette so they can continue to use the same animation frames.

 

Pretty close.

 

For turning, there are seven frames of animation, each frame turning 11.25 degrees (not including the cardinal direction frames).

 

Moving forward/backward also makes use of palette animation.  The individual squares are broken up into 4 bands of color, and there are two frames, one offset by 1/8th of a square.  So by alternating the two frames and adjusting the palette every second frame swap, the result is the appearance of moving in increments of 1/8th of a square.

 

Even after removing redundant tiles, the background images still take up nearly 3/4 of the system's VRAM.

Share this post


Link to post
Share on other sites

 


Do you have a specific reason for not wanting to use OpenGL? A self-imposed limitation to experiment with a technique is just fine, but if you're of the mind that OpenGL isn't worth learning to do this, you might want to reconsider.

 

Raytracing seems to close to what I was looking for. Because I have not done this before I did not know what to search. Now that I have done just a little bit of searching it seems that using raytracing in a video game is not a good choice unless everyone is using a server farm to play the game.

 

Now I'm getting into some opengl questions(yes and no are not what I'm looking for). I would like to know the api calls or a link to tutorial would be nice.

1. Can I map a png to a plain in opengl and still have transparency?

2. Can I map only a portion of a image to a plain?

 

 

You might actually be looking for ray marching. You can more easily test intersections with objects (such as your plane) and use a fisheye-like projection to curve the rays to produce the sphere effect. Then animating the plane movement is as basic as off-setting through the X and Z directions.

Share this post


Link to post
Share on other sites

Now that I have done just a little bit of searching it seems that using raytracing in a video game is not a good choice unless everyone is using a server farm to play the game.
Hence why I mentioned pre-calculating the lookup projection.

 

Your camera, by the constraints you gave us, is at a fixed viewing angle, and a fixed distance from the "sphere" you want to move around over. The only object it is viewing is a single sphere, onto which you are going to project a small portion of a flat 2D map. So, you only have to do one frame worth of raytracing, and then remember the U,V coordinates that each on-screen pixel got cast to (or "none", if it cast to not intersecting with the sphere at all). To render each frame, you then walk the screen, read the U,V coordinate (or lack thereof) for each pixel, apply a translate/rotate matrix to that U,V coordinate (rotating around only the axis from the center of the sphere to your camera, so this is only a 2x2 or 3x3 matrix), and then sample the texel at that coordinate of your map. This would be very cheap as a fragment shader applied to a single full-screen quad.

 

It's not real-time ray-tracing, because you're not performing a full scene traversal and lighting analysis every pixel, every frame. Your "scene" is actually static; an unmoving sphere and an unmoving camera. You'll be doing only a simple U/V transform for each pixel, each frame.

 

 

However, it is also sounding like you're quite new to graphics programming in general, not just OpenGL. You'll want to master a simple flat 2D tilemap first, then try projecting a view of it that is bent down at the edges to make it look like the map is curved onto a sphere. If you are already well-versed in shader programming, then you could probably dive straight in to the technique above, though.

Share this post


Link to post
Share on other sites

and use a fisheye-like projection to curve the rays to produce the sphere effect

I'm not looking for a sphere effect. I want a flat plain. Thanks for the input. More information on what I'm doing the static camera angle, character position, having a small viewer of the sky, the ground needs to give the view the feeling they are moving. I'm not using box texture I will use grass and others.

 

 

 


However, it is also sounding like you're quite new to graphics programming in general, not just openGL.

That is correct. I'm developing on Linux so OpenGL is the best option if I need it. I was hoping that something like this would make sense to do with out openGL.

Edited by workaround

Share this post


Link to post
Share on other sites

You want a flat plane? So, something akin to this, at 12m15s; [url]https://www.youtube.com/watch?v=PsCPOJA8MCg#t=12m15s[/url] ?

 

That's vastly easier. Look up just about any OpenGL tile map drawing. I also encourage you to learn how to use a VBO early, before you learn any bad habits that immediate mode encourages.

Share this post


Link to post
Share on other sites

I've dip my toes into researching this for a future game I want to develop. I wanted to create an engine that take 2D drawing and put them on a 3D isometric plane to be interacted with. One thing of interest to you I've come across in my research is this strange view called "Fish eye". "Fish eye" view distort imagines but I really don't know much about it. There was some C++ library I found a few months ago, but I can't remember the link.  

Edited by LAURENT*

Share this post


Link to post
Share on other sites

I think pseudo 3D is what you're looking for. I experimented with this a while ago. You can do it line-by-line in a for-loop  by changing the end points for each line you draw on the screen.

 

These are good resources:

Lou's Pseudo 3d Page

Pseudo 3D Racing Game Tutorial

 

My understanding is that pseudo 3D was used a lot in older racing games to make the roads curve and to create hills/slopes. Check out the screenshots from this page for examples of what you can do with this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this