I'm trying to make my sound effects work as in 3D environment in a 2D platformer game.
The problem is that when I set Spatial Blend option to 3D on my sound effects it gets really quiet but if I keep it on 2D it will play at the same volume through-out the entire room.
All of the answers to this problem recommend keeping the Spatial Blend option on 2d but I actually want to hear the sound effect at different volume levels depending on where the camera/character is.
May be change curve distance volume?
Related
So correct me if i'm wrong, but I think all elements in 3d graphics are meshes.
So the question is really, how do you take mesh data and create a 2d projection based on the mesh data, the camera location, rotations of camera & mesh, etc.
I realize this is fairly complicated and I would be satisfied by just knowing what the technical term for this is called so I may search and research it.
You can read about 3D projection on Wikipedia.
So, I'm currently developing a puzzle game of sorts, and I came upon something I'm not sure how to approach.
As you can see from the screenshot below, the text on the sides next to the main square is distorted along the diagonal of the quadrilateral. This is because this is not a screenshot of a 3D environment, but rather a 2D environment where the squares have been stretched in such a way that it looks like it's 3D.
I have tried using 3D perspective and changing depths, and while it solves the issue of the distorted sides, I was wondering if it's possible to fix this issue without doing 3D perspectives. Mainly because the current mesh transformation scheme took a while to get to, and converting that to something that works on 3D space is extra effort that might be avoidable.
I have a feeling this is unavoidable, but I'm curious if anyone knows a solution. I'm currently using OpenGL ES 1.
Probably not the answer you wanted, but I'd go with the 3d transformation because it will save you not only this distortion, but will simplify many other things down the road and give you opportunities to do nice effects.
What you are lacking in this scene is "perspective-correct interpolation", which is slightly non-linear, and is done automatically when you provide coordinates with depth information.
It may be possible to emulate it another way (though your options are limited since you do not have shaders available) but they will all likely be less efficient than using the dedicated functionality of your GPU. I recommend that you switch to using 3D coordinates.
Actually, I just found the answer. Turns out there's a Q coordinate which you can use to play around with trapezoidal texture distortion:
texture mapping a trapezoid with a square texture in OpenGL
http://www.xyzw.us/~cass/qcoord/
http://hacksoflife.blogspot.com.au/2008/08/perspective-correct-texturing-in-opengl.html
Looks like it won't be as correct as doing it 3D, but I suppose it will be easier for my use right now.
I am working on a library for procedural texture generation (https://github.com/mikera/clisk) which is starting to come together quite nicely.
I'm now trying to work out good ways of producing tileable 2D textures.
One approach that seems plausible is to map the (0,0) - (1,1) 2D texture space onto a surface within a 3D texture in such a way that the surface connects the left and right edges and top and bottom edges of the texture (e.g. a torus). In doing so, that should ensure that the 2D texture is automatically tileable.
Since I already have good (non-tileable) 3D textures (perlin noise, fractal noise etc.) this seems like it would be a good way to allow the creation of tileable 2D textures from an arbitrary 3D texture.
So my quesyions:
Is this a valid technique?
If so, what kind of surface should I map onto in order to minimise distortions / get an good looking tiling effect?
Any pitfalls to be aware of?
Using 3D noise for this will produce distortion, the answer is to use 4D noise, though that is not the only way - you can also make the 2D function tileable.
Here's a couple of useful links:
http://www.gamedev.net/blog/33/entry-2138456-seamless-noise/
Introduces the 4D method
https://gamedev.stackexchange.com/questions/23625/how-do-you-generate-tileable-perlin-noise
Has multiple answers for this: making the 2D tileable, 3D with distortion, and the 4D method
I've been working on 2D games for a long time now (because 2D is all I know how to do) and want to step it up a notch. I don't want to go fully 3D because I don't think I have the mathematical knowledge to work with 3D graphics, but instead want to start developing some graphics that lie somewhere inbetween.
By inbetween I mean graphics that will still render as 2D, but may have been created using 3D software and then exported at various angles. Some examples of the style could include:
Age of Empires 1.
Diablo 1 & 2.
Starcraft 1.
Is there any software used specifically for creating a 3D model and then generating a 2D sprite-sheet from it? Here is an example of such graphics that may help in making sense:
Blender is free 3D modeling tool, where you can make sprite sheet out of the model. I don't know how to do this but I know it's possible, because my friend is using it for our game (he is making 3D spaceship models and transforming them into 2D sprites)
http://www.blender.org/
I am not aware of such a specialized software, but have you considered simply using a 3d engine with a fixed camera looking at the scene from above and all objects at ground level?
That way you can use regular tools for modeling and still have the logic and (with a few settings to the physics engine) physics of a of a 2D game.
Unity engine might be able to help you.
I am currently working on a game in SDL which has destructible terrain. At the moment the terrain is one large (5000*500, for testing) bitmap which is randomly generated.
Each frame the main surface is cleared and the terrain bitmap is blitted into it. The current resolution is 1200 * 700, so when I was testing 1200 * 500 pixels were visible at most of the points.
Now the problem is: The FPS are already dropping! I thought one simple bitmap shouldn't show any effect - but I am already falling down to ~24 FPS with this!
Why is blitting & drawing a bitmap of that size so slow?
Am I taking a false approach at destructible terrain?
How have games like Worms done this? The FPS seem really high although there's definitely a lot of pixels drawn in there
Whenever you initialize a surface, do it the following way:
SDL_Surface* mySurface;
SDL_Surface* tempSurface;
tempSurface = SDL_LoadIMG("./path/to/image/image.jpg_or_whatever");
/* SDL_LoadIMG() is correct name? Not sure now, I`m at work, so I can`t verify it. */
mySurface = SDL_DisplayFormat(tempSurface);
SDL_FreeSurface(tempSurface);
The SDL_DisplayFormat() method converts the pixel format of your surface to the format the video surface uses. If you don`t do it the way I described above, SDL does this each time the surface is blitted.
And always remember: just blit the necessary parts that really are visible to the player.
That`s my first guess, why you are having performance problems. Post your code or ask more specific questions, if you want more tipps. Good luck with your game.
If you redraw the whole screen at each frame your will always get a bad FPS. You have to redraw only part of the screen which have changed. You can also try to use SDL_HWSURFACE to use hardware but it won't work on every graphical card.
2d in SDL is pretty slow and there isn't much you can do to make it faster (on windows at least it uses GDI for drawing by default.) Your options are:
Go opengl and start using textured quads for sprites.
Try SFML. It provides a hardware accelerated 2d environment.
Use SDL 1.3 Get a source snapshot it is unstable and still under development but hardware accelerated 2d is supposed to be one of the main selling points.