Tag Info

Hot answers tagged

15

If I follow the issue correctly try calling Begin with BlendState.NonPremultiplied. This article may also help shed some light on how alpha blending works in XNA: http://blogs.msdn.com/b/shawnhar/archive/2010/04/08/premultiplied-alpha-in-xna-game-studio-4-0.aspx


12

Your problem will solve rendering with 1bit alpha. Which means you specify some alpha of source texture which is not rendered (mostly 0.5). You have to write your own shader for saving depth from light and use instruction discard. Discard exists in hlsl, glsl and in cg as well. It exists only in pixel/fragment shader and discards curent fragment from the ...


11

There are lots of ways to achieve order-independent transparency. The first (and I think oldest) type of algorithm is called depth peeling and works by "peeling" one transparency layer per pass (in the most basic version). This Nvidia paper for Dual Depth Peeling shows peeling two layers at the same time. The second type which I only know as ...


10

This looks like a case of not drawing with a premultiplied alpha texture correctly. Here's a few helpful links on the subject: http://www.youtube.com/watch?v=dU9AXzCabiM http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx If you search for "premultiplied alpha" and iOS you might find a direct solution to your problem. I suspect ...


9

I've talked about this a few times before (see related answers at the bottom) but I'll repeat myself. As you can imagine, checking every pixel against every other pixel would be very inefficient, even if you limited those pixels to the rectangle range that is actually intersecting. But like you mentioned, your second option also has its share of problems. ...


9

In addition to everything you've stated (textures with alpha channels, drawing the landscape before drawing the wall+window), you also need to do two more things. First, you need to enable OpenGL's blending functionality: glEnable(GL_BLEND); Second, you need to tell OpenGL how to calculate the colors of blended pixels (which OpenGL calls "fragments", ...


8

This is a fairly common approach to transparency in games that use deferred shading. Proper transparency doesn't work well at all with deferred shading, since only one surface's data (depth, normal vector, color, etc.) can be stored at each pixel, and proper transparency involves multiple surfaces overlapping at a pixel, each requiring independent lighting. ...


6

Create a new SamplerState of your own and set it like this: mySampler.Filter = TextureFilter.Linear; mySampler.AddressU = TextureAddressMode.Clamp; mySampler.AddressV = TextureAddressMode.Wrap; mySampler.AddressW = TextureAddressMode.Wrap; The V coordinate will be wrapped (since you want horizontal repeat) and the U will be clamped.


6

Fully agree with Alex's response, though if you stick with premultiplied alpha I believe you could also do it this way new Color(new Vector4(alpha, alpha, alpha, alpha )) Shawn also did a post explaining the difference between premultiplied and non-multiplied alpha - http://blogs.msdn.com/b/shawnhar/archive/2009/11/06/premultiplied-alpha.aspx


6

As thedaian mentioned in his comment, converting the magenta pixels to transparent in JavaScript is going to be slow. You should convert your images to a suitable format beforehand. ImageMagick can be really useful for this kind of tasks. Converting your tile with magenta background to an image with transparency is as simple as this: convert ...


6

Your alpha-blended objects should not participate in a depth pre-pass. For a given final pixel, its color will be a number of colors blended together at different depths: the portion of the color furthest away from the camera will either be the sky/background or an opaque object, and all the other contributions will be from semi-transparent objects. And if ...


6

I've been the graphics performance guy for a few big-name 3D iOS titles, so I completely feel your pain on this one. My experience has been that transparent pixels are the most expensive thing you can render on modern iOS devices. Your conjecture is right; the greater number of pixels on the iPhone4 really kills its performance in general, and transparent ...


6

Jens covered the different ways pretty well. I would like to add that additive blending is also order independent and it can be used in limited use cases to achieve pretty good results with very little programming effort. The following image is rendered with a color something like (-0.5, 1.0, -0.5) with additive blending. Positive color values are given for ...


5

Judging from a quick look at the libgdx wiki's SpriteBatch entry, alpha blending is on by default. Blending is enabled by default. This means that when a texture is drawn, translucent portions of the texture are merged with pixels already on the screen at that location. This means that you can do what you said: open the Hero texture in Paint .NET and ...


5

(No experience with 3D programming on iOS, but this should work on regular OpenGL devices.) I can think of 2 options that might fix this. Try separating the model in 2 parts, first render the opaque part and then render the transparent part. Another option might be to disable alpha writing when rendering the object. What I think is happening is that when ...


5

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 ...


5

You don't, at least not for writes. Z-buffer writing/ordering and transparency is not really something you can do easily. Most techniques require significantly more work than you're likely prepared for, like using depth peeling. Sort your objects. Typically you would sort opaque (or alpha cutout) objects front-to-back with Z-buffering enabled, then do a ...


4

Here's what I would do. Step 1: Don't sort. Just do it. See if it's a problem. Most likely isn't. Step 2: Limit particles into such that do not really need sorting, such as: Just solids (with possibly alpha-to-coverage edges) let zbuffer take care of the sorting. Just additive bits a+b = b+a, so order doesn't matter Step 3: if more is needed, ...


4

Alpha blending in 3D is tricky, simply due to the fact that you're (usually) still rendering the quad (or polygon) to the depth buffer using the depth buffer, even if your visible texture is just a tiny part of that. To achieve proper rendering you'll have to render everything in the correct order, essentially from back to front. If you don't use the ...


4

You want a stencil. Stencils let you flexibly define regions that love.graphics operations won't affect. Here's an example. It does this: Draw some colourful circles. Set an inverted stencil made of two triangles. Draw a black rectangle over everything. See how the black rectangle doesn't actually cover everything? It's cut out where the triangles ...


4

.png images wont show the transparent area. But you will have to make sure that the "white" area is transparent and not white. If its not a .png image just go in to photoshop or any other image editor, cut out (magic wand) the white area and save it as a .png


4

JPG is lossy. Don't use that for sprites -- you will end up with nasty artifacts that will look bad. There's a couple reasons you might want to use colur-keying, but they're a bit lost in todays hardware. Taking a quick look at color key advantages: Pros They use up less disk space -- there is no alpha channel to store By consequence, their memory foot ...


3

Let me give you the bad news straight away: there is no fix for this, not in Ogre, not in any engine. This website explains the problem nicely: http://blogs.msdn.com/b/shawnhar/archive/2009/02/18/depth-sorting-alpha-blended-objects.aspx However, a solution in your case could be to first render all your opaque objects, turn off depth writing, render the ...


3

SOLVED: Thanks to Demi. Here is the final code: // Render opaque objects [_scene render:renderer opaque:true]; // First planar shadow pass (if needed) [self renderPlanarShadows:renderer]; // Render transparent objects glColorMask(1, 1, 1, 0); if (_zSortingEnabled) { [_scene ...


3

What do you get if you try and swap the order you draw them in? Transparent pixels still create depth buffer entries. If you're drawing the back one after the first it's not processing the pixels behind the front image, making it look like there's no alpha. For reference, take a look at the Painter's alogrithm.


3

The problem is exactly what you say you aren't looking for. Drawing entirely transparent models is a non-trivial task, since to achieve correct blending closer polygons must be drawn after the further ones. If you don't want to use more advanced techniques like depth peeling, try breaking your model in small pieces and draw them sorted from back to front, ...


3

In order to get proper blending you will probably have to break the object up into multiple models. And even then you are still limited since from certain angles you will be able to break the transparant blend again. Transparancy is actually quite difficult to get correct without using some cool but fairly exotic solutions. One that comes to mind is Order ...


3

This looks like a culling issue, like Trevor Powell pointed out. A simple way to test if it really is a problem related to culling is to turn it off like this: RasterizerState rasterizerState = new RasterizerState(); rasterizerState.CullMode = CullMode.None; GraphicsDevice.RasterizerState = rasterizerState; Please note that disabling culling is not the ...


3

Changing the colours of a vertex buffer is relatively expensive. You'd have to use something like VertexPositionColor and then modify every vertex every time you want to change transparency! It would be much easier, and faster, to add transparency using a shader (pixel or vertex). Fortunately BasicEffect does exactly what you need - it even has an ...


3

You are drawing all sprites in the same postition and same size, if textures don't have alpha channel you will only see one of them. Test this to draw a grid with 8 columns: var size = 100; var width = 8; var n=0; foreach(KeyValuePair<string, Texture2D> Border in lstBorders) { var x = (n % width)*size; var y = ...



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