Tag Info

Hot answers tagged

12

I admit I'm not aware of any ideal solution to this problem, so I'll describe a workaround that you may or may not be comfortable with: Render all of the particles using additive blending to a separate texture (or render target) with its background cleared to transparent. Render that texture (or render target) on top of your scene using alpha blending. I ...


9

Short Answer Look into depth peeling. From my research it seems to be the best alternative, although computationally expensive because it requires multiple rendering passes. Here's another more recent and faster implementation, also by NVIDIA. Long Answer That is a tough question. Most books I've read skim over the subject and leave it at: Start by ...


7

The correct answer is #1: sort all of your things by depth and render them (obviously turn off depth writing, but not testing). What is a "thing"? Each "thing" must be a convex object; it cannot self-overlap. If you have an object that is concave, it must therefore be broken up into convex pieces. This is the standard way of rendering a transparent scene. ...


5

You have to stop thinking of blend equations (and any graphics mechanism or tool) as "what it looks like." Blend equations are not "additive", "multiplicative" or anything of the sort. The blend equations do math; that's all they do. The question is how you use that math to achieve a desired visual effect. The limits are your imagination. If you can't see ...


4

When rendering with multisampled anti-aliasing, a coverage value is computed for each fragment; this coverage value is based on the fraction of the pixel that would be covered by the fragment based on the triangle that created the fragment. The net result is that the edges of the triangle are anti-aliased. Because the coverage is based ultimately on what the ...


4

OK, so here's my solution (please comment if it can be done better)... Turns out that I should in fact be using alpha testing (though, I discovered this by accident, so I'm not entirely sure why it works). create() { // ... // some other code here // ... Gdx.gl.glEnable(GL10.GL_DEPTH_TEST); Gdx.gl.glEnable(GL10.GL_ALPHA_TEST); } ...


4

As David Gouveia pointed out, there's no satisfying replacement for additive blending on bright backgrounds. The best effect I found (that doesn't require something like rendering to a backbuffer) is to use the following GL blendmode: SRC: GL_ONE DST: GL_ONE_MINUS_SRC_ALPHA It's not as nice as additive blending, but way better than GL_SRC_ALPHA, ...


4

The problem is caused by the SpriteBatch.Begin() changing some of the rendering states. This problem is solved in XNA 3.1 and earlier by using the SaveState flag (see this answer). However in XNA 4.0+ you need to restore the state yourself. Insert the following code after your sprite drawing but before your model drawing (or 3D primitive drawing) ...


4

case GL_FUNC_ADD: output = add( source_colour, destination_colour ) This is where you've gone wrong. The source and destination factors are multiplied into the source and destination colors, then added together. The OpenGL Wiki article on blending goes into greater detail on this matter.


3

Edit: I missed that these aren't sprites, but actually polys. You want multitexturing. Keeping the content here, hopefully off use to someone looking for something similar. You want to create a series of "Fringe" tiles and layer those where you need them. You will need to create corner and edge pieces for each of the tiles you intend to use, and it would be ...


3

It is called a barycentre. Here your point is: P = (A * A_ratio + B * B_ratio + C * C_ratio) / (A_ratio + B_ratio + C_ratio) Badly, Wikipedia have no dedicaced page for this, so you'll have to understand the explanation of center of mass, which is just a generalization of barycentres applied to physics. EDIT: your second method is equal to: P - default ...


3

Well first off, the particle images you're using appear to have a black background, resulting in the dark fringes in that second image. Don't do that; that is, don't draw the shape of the particle on the color channels. Instead, the image should be solidly colored and only define the shape in the alpha channel. Doing that will improve the look of alpha ...


3

Your problem lies in the Z-Buffer. When you draw transparent polygons, depth writing must be disabled to achieve correct transparency, or the polygons must be ordered back-to-front so they correctly overlap. But, since you are drawing a concave object (one plane intersects the other) and it has transparent and opaque sections, both of these methods can't be ...


2

Here's a custom BlendState that should do the same as Game Maker's bm_subtract does, based on the post found here. Here's a complete example with combining two RenderTarget2Ds, so you also see how they work in practice. private GraphicsDeviceManager graphics; private SpriteBatch spriteBatch; private RenderTarget2D sprites; private RenderTarget2D shadows; ...


2

Bad news is that you can't implement all of photoshop's blend modes with glBlendFunc, even though there are a bazillion of combinations that you can use. Good news is, when you move to shaders, the orange book (OpenGL Shading Language, http://www.amazon.com/exec/obidos/ASIN/0321637631/khongrou-20 ) contains a chapter with shaders to emulate the photoshop's ...


2

Alpha testing is used to stop the renderer drawing pixels to any buffer, including the z buffer. Alpha blending is just a visual thing - values are still written to the zbuffer, which can result in problems like this - invisible pixels are infront of subsequently rendered pixels which means they'll fail the ztest when you draw the new pixels. This is what ...


2

You can use geometry instancing to draw a large number of trees in one draw call. (That article is written about Direct3D 9, but the same feature should be available in any 3D graphics API.) That should improve CPU performance, if that's indeed the bottleneck. If the trees are alpha-blended you still have to sort them back-to-front yourself, though, which ...


1

OK, my lack of understanding of Paint objects and how filtering works let me to make some incorrect assumptions about how straight forward this might be. I have figured it out in the end anyway. To do additive blending you need grey scale images that represent each channel of colour: alpha, red, green and blue. Gimp has the functionality to separate ...


1

Calculate the relative offset from Default to each point and add them on top of Default with the given weights. This means that you can't divide by the sum of the weights unlike in the previous answer you got. deltaA = A - Default; deltaB = B - Default; deltaC = C - Default; point = Default + deltaA * weightA + deltaB * weightB + deltaC * weightC;


1

I wrote an article about auto tiling that is a technique used to achieve that. http://autoloot-games.com/?p=232 Here is a video showing it running: http://www.youtube.com/watch?feature=player_embedded&v=x_iKY_laARs


1

Normally you store the transparency of a texture in the alpha channel, you can use an external editor like Paint.Net (free) or Photoshop to edit the alpha channels of a picture. However since you're using shaders there is another trick you can do. A color is totally black if all it's color channels (R/G/B) are 0. It's gray when it's 128/128/128 and white ...


1

The process itself is rather complicated, as it involves using a lot of quaternions and matrix operations. You can't just take average of bones rotations/positions, since it would result in bizarre picture. Here's a sample code from Havok Animation component (used for blending two hkQsTransforms - universal transform class). void hkQsTransform::setZero(); ...


1

Try inverting the image, in substraction what happens is that (for every channel (RGB) of every pixel) the following calculation is done: result = clip( source - filter, 0, 255 ). With filter the white image you posted. Meaning that the white parts of the source becoming black, and the black parts staying the same.


1

It looks to me like depth write is enabled when you draw the trees. The problem is that whichever quad draws first lays down depth as if the whole quad was opaque, when it's not, due to the alpha-blended texture. When the second quad draws, parts of it are culled away that should be visible. There are a few possible approaches to fix this, each with its ...


1

OpenGL is a state machine, whenever you set it to a state you need to revert that state after you've used it. You have set current texture to be "texture", once you've called the list you need to restore the 0 texture (no texture state). Textures aren't stored with display lists, so there's no need to bind them when making lists. Your code should look like ...


1

I have tested the example2a and it worked without changes. These are the files that I have used: gutil.py: import pygame from OpenGL.GL import * from OpenGL.GLU import * def initializeDisplay( w, h ): pygame.display.set_mode((w,h),pygame.OPENGL|pygame.DOUBLEBUF) glClearColor( 0.0, 0.0, 0.0, 1.0 ) glClear( GL_COLOR_BUFFER_BIT | ...



Only top voted, non community-wiki answers of a minimum length are eligible