Tag Info

Hot answers tagged

34

Digital colors can be made up of three components: red, green, and blue. Combine these together, and you get final color, eg. yellow is 100% red, 100% green and 0% blue. The fourth component is, as you mentioned, transparency. Together, these form the tuple RGBA (red, green, blue, alpha) which represent an image. Now, instead of pixels, think about it ...


16

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

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


10

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


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


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


7

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


7

The term comes from the definition of "channel" that means a specific portion of a frequency spectrum. In this case, the red, green and blue components of a color are often referred to as "channels" (since red, green and blue light are portions of the visible light spectrum). Since alpha is another component of color in computer graphics (although not one ...


6

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


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


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

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

With programmable pipeline you should do it how @notabene instructed. However it's easy to do with fixed pipeline as well without writing any shaders. In OpenGL glAlphaFunc is what you want. For example: glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f);


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


5

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


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

Just don't write to the depth buffer when rendering the particles. This will allow them to all be rendered and blended with each other. You should still perform depth testing though so that they can be properly occluded by geometry in the scene.


5

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


5

Alpha channels were actually invented by George Lucas's company Industrial Light & Magic (actually Alvy Ray Smith did most of the work while working there, who was previously employed by Xerox PARC - who we can thank for almost everything in modern computing!). Alpha channels, in addition to doing cool effects like transparent window, transparent ...


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

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

This is a pretty advanced topic. Generally people like to use Boolean Set Operations implemented with a BSP tree for this kind of destruction, which revolves around splitting polygons over planes. Take a look at this paper by Naylor to learn how. This will let you overlay one mesh upon another and perform a subtraction. The results of the subtraction can ...


4

None of the other examples explain why it's alpha, though. It's from the expression in Alpha Compositing: where Ca and Cb are the two input colour values and Co is the output combined colour. Varying the alpha between 0 and 1 varies the colour between front and back composited images. (Image processing also has "gamma", but not "beta" as far as I know)


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



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