Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - lolz123

Pages: 1 ... 14 15 [16] 17 18
Graphics / Slightly more advanced collision detection (with graphics)
« on: August 21, 2011, 08:59:27 pm »
Spatial partitioning allows one to skip checking certain objects entirely, since they are grouped in such a way that the algorithm can simply skip the group. In the game I am currently developing, I created a Quad Tree to sort all of my lights and shadow casters in such away that I can easily detect which lights are visible and which hulls its perimeter can reach using some region queries.

The Quad Tree works by grouping objects into groups which are in turn grouped as well, where every group has 1 parent group and 4 child groups.

For more information, read here:


The example shows it storing points, but you can store anything you want.

The KD-Tree that Box2D uses works differently from the Quad Tree, it turns the game world into a sort of 2D binary search tree. It has advantages and disadvantages over a quad tree, it is faster for region queries but can be slower if re-balancing is required often (the entities in the game work move around allot).

For more on that, go here:


Other methods exist too, such as BSP Trees, Octrees (3D quad tree, Minecraft uses it to store chunks), Bins, R-Trees, etc. All have advantages and disadvantages.

Unless you want to ignore parts of your game world completely if too far away (e.g. Minecraft), you will still have to perform some logic on all entities, but at least you do not have to render them all and do note have to do things like collision checks on them all (trees speed it up by only testing against other objects in the vicinity, not all other objects).

Graphics / SFML 2 Water Shader Problem
« on: August 21, 2011, 02:58:52 pm »
@ Easy: The name of the project is Gore Factor (I could not come up with something better). It uses a form of vector animation in combination with sprite animation. Here is a YouTube video, download link is in the description:


@ Groogy: Well, you don't see much. but here it is:

That white box is the place where the distortion effect is supposed to take place. It flickers seemingly random shades from the rest of the screen.

Graphics / SFML 2 Water Shader Problem
« on: August 19, 2011, 05:24:41 am »

I am pretty new to GLSL, but I was able to create a full screen water distortion effect by setting the pixel colors to that of pixels whose positions are dictated by offsets which are derived from a tiling noise texture. Here is how it looks:

Here is the shader. Time is wrapped to be in the range [0, 256) in order to have the water "flow" without any stutter as the noise texture repeats.

Code: [Select]
uniform sampler2D screenTex;

uniform sampler2D noiseTex;

uniform float time;

void main()
// Get the color of the noise texture at a position the current fragment position offset by the time
vec4 noiseTexCol = texture2D(noiseTex, vec2(gl_TexCoord[0].x + time, gl_TexCoord[0].y + time));

// Reduce the offset
float reducedOffset = noiseTexCol.x / 70;

// Get the color of the screen at the offset location
    vec4 col = texture2D(screenTex,  gl_TexCoord[0].xy + vec2(reducedOffset, reducedOffset));

// Set the fragment color
gl_FragColor = col;

But now I would like to apply that only to a specific region in order to create a body of water. I would like to simply distort a region and apply a blue overlay. I tried binding the shader while I drew a simple blue box, but when I run it what was once a blue box flickers seemingly random colors from the screen texture. I am not sure that I understand the GLSL texture coordinate system properly. Perhaps the lack of texture coordinates on the primitives is causing the color flicker.

Here is the code I am using to draw the body of water:

Code: [Select]
  // Render the water shape with the shader applied
sf::Image screen;
waterShader.SetTexture("screenTex", screen);
waterShader.SetParameter("time", time / 256.0f);

glColor4f(0.2f, 0.2f, 1.0f, 0.4f);



Renderb2Body(body, 80.0f);



glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

Renderb2Body just draws a box. It works fine without the shader.

Any help on this matter is appreciated.

Graphics / Slightly more advanced collision detection (with graphics)
« on: August 17, 2011, 09:55:51 pm »
Most games that do not use a physics library use bounding boxes for collision detection or other simple constructs such as circles and points. Per pixel collision detection can be very taxing on the system and is not used often. If you really need to test against complex shapes, I recommend using a library like Box2D (http://box2d.org/). This is a physics library, but if physics are not desired then you can just use the collision module. I have used Box2D in some of my projects, it is very easy to use. With it, you can use any convex polygon or circle for collision detection. Concave shapes are not supported to my knowledge, but you can just use multiple shapes to achieve the same effect. Also, it is a pretty fast library; it uses a spatial partitioning system (I believe it is a KD-Tree) which is much faster then checking every shape to every shape individually.

Graphics / Render Image Anti-aliasing
« on: August 17, 2011, 04:34:43 pm »
Thanks for the reply.

Unfortunately, enabling smoothing on the render image did not have much of an effect. I do not quite understand why one cannot anti-aliasing any render target besides the main window. Perhaps I can just render to the screen and then take a screenshot and use that. This seems like a pretty ugly workaround though.

Graphics / Render Image Anti-aliasing
« on: August 17, 2011, 12:05:12 am »
Hello everybody,

Does anybody know how to perform anti-aliasing on a render image?
I have found some older posts here about this issue, but they did not actually present a solution to this problem. I also found some threads about a newer OpenGL extension which permits FBO anti-aliasing, but I am not sure how to implement it. Also, I read that it is not possible at all when using a p-buffer.

I would appreciate any help you can offer!

I don't think SFML can software render sprites, it uses OpenGL. What graphics card do you have?

SFML projects / Gore Factor SFML
« on: May 19, 2011, 10:50:22 pm »
Source code is now up.

Graphics / sf::RenderImage::Create extremely slow
« on: May 15, 2011, 02:11:23 pm »
I'll let you know if I figure it out.

Graphics / sf::RenderImage::Create extremely slow
« on: May 15, 2011, 02:52:05 am »
I doubt it is my machine since I was able to compile and run some OpenGL render to texture demos with zero lag (same thing SFML is trying to do). I could, of course, completely ignore SFML and use the lower level OpenGL render to texture stuff, but if possible I would like to use SFML for this.

Graphics / sf::RenderImage::Create extremely slow
« on: May 15, 2011, 01:39:08 am »
Ok, I ran it under the newest version of SFML2 (after wrestling with the usual linker errors :roll: ), but the lagging issue persists.

Graphics / sf::RenderImage::Create extremely slow
« on: May 14, 2011, 11:59:09 pm »
Er... the one titled "LaurentGomila-SFML-cb1f938" (I can't find the official version).

Graphics / sf::RenderImage::Create extremely slow
« on: May 14, 2011, 11:36:46 pm »
I am using SFML 2.

Graphics / sf::RenderImage::Create extremely slow
« on: May 14, 2011, 11:35:57 pm »
The 2nd one is slightly faster, but still ridiculously slow. It takes my 3.07967 secs to create 2 render images.

Graphics / sf::RenderImage::Create extremely slow
« on: May 14, 2011, 11:21:25 pm »
I'm running this on a laptop with a core 2 duo CPU and a HD 3670 GPU with latest drivers. I could try and throw my HD 5970 at it, but that shouldn't be necessary!

Here is the program I used, at the end the time flashes by:

Code: [Select]
int main()
    sf::Clock clock;
sf::RenderImage image;
image.Create( 128, 128 );
std::cout << clock.GetElapsedTime() << std::endl;

return 0;

Even though a system("pause") at the end wouldn't change anything, I wanted to be certain that system calls are not causing this problem.

Pages: 1 ... 14 15 [16] 17 18