We changed our privacy policy. Read more.
8

While there is some interesting research into order-independent transparency rendering, it's extremely complex to implement. And even sorting individual leaves can still cause artifacts where one leaf overlaps itself. So your safest bet is probably Alpha Testing. This is where you specify a threshold opacity value; anything above that value is rendered 100% ...


6

The best way to sort your scene is actually to do it in at least two stages/buckets. It is true that you need back-to-front sorting for translucent geometry for proper alpha-blending, but you want front-to-back sorting for best Z-buffer performance on opaque geometry. You can often get away with not bothering to sort opaque objects at all, leaving them ...


6

Use a file format that supports alpha (png), an editor that can save it with a transparent background (gimp2, photoshop, basically not paint) and make sure you load the sprite correctly


5

In your first example (glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)), you're telling it to blend colors based on the alpha of the image which gets drawn on top (the "Foreground" one). So when you're blending 50% between the foreground color (38,50,168) and the background color (38,50,168) in the bottom left corner of the image, you unsurprisingly get ...


5

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


5

With the introduction of programmable blending units, the intuitive meaning of alpha being a measure of opaqueness doesn't always hold. In the two-operand blend you have two contributing fragments: the source (what you're blending, the new fragment), the destination (what already exists in the spot you're blending to). You have two independent blending ...


4

You need to write: return float4(1.0f, 0.0f, 0.0f, 1.0f); The float4 is necessary to construct a vector. The way you've written it currently, the compiler is interpreting it as the comma operator. The result is that you only return the last element (the alpha component), which then gets replicated to all four components of the result.


3

Using premultiplied alpha everywhere is a fine choice for composition. It allows you to include both additive and alpha-blended elements, as well as anything in between, and you can composite premultiplied-alpha images together using GPU hardware blend modes. In cases where alpha has the usual interpretation (opacity) I'm not aware of any reason not to use ...


3

Wrapping the SKEmitterNode in an SKEffectNode allows the EmitterNode to be rendered into a framebuffer which is subsequently rendered onto the screen. I tested this out (after much push and pull of different nodes and scenes and views) and this results in the exact effect you want, where the Add blend mode is applied to a background that is not rendered ...


2

BlendState.ColorWriteChannels is a bitfield with a bit for each of the four channels. You can make it write to RGB only by setting blendState.ColorWriteChannels = ColorWriteChannels.Red | ColorWriteChannels.Green | ColorWriteChannels.Blue;


2

With shaders and ordinary alpha blending I don't think this is possible. If you wanted to replace all the alpha values in the scene by a global constant, you could use D3DBLEND_BLENDFACTOR and D3DBLEND_INVBLENDFACTOR. But it sounds to me like you want to multiply each pixel's alpha value by a global constant. This is best done in the pixel shader. That ...


2

You can try drawing on a texture in memory without alpha and then draws the result with the desired value of alpha. This link tells you how to draw texture memory: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Render_to_texture.php


2

Unfortunately, the problem is hopeless as it stands. You cannot get acceptable filtering at boundaries without each tile being somehow more aware of its neighbours. I recommend changing the way you draw tiles. Here is what you should do. First, render your tiles to an offscreen framebuffer at ratio 1:1 (using GL_NEAREST, which already works for you). Then, ...


2

Ok I figured this stuff out, was not obvious. The reference MSDN page i talked about does state that "Blend type" "Alpha Blending" uses the following formula in XNA 4: (source × Blend.SourceAlpha) + (destination × Blend.InvSourceAlpha) But despite this, BlendState.AlphaBlend field has the following pre-set parameters: ColorSourceBlend Blend.One ...


2

You basically put a one alpha value in each channel. For example you have Alpha0 = 0.5, Alpha1 = 0.2, Alpha2 = 0.7, Alpha3 = 1.0. The "packed" texture would be R = 0.5, G = 0.2, B = 0.7, A = 1.0.


2

If I have understood your approach, instead of drawing let's say a grid on nxn quads, you are building a mesh from all that quads and trying to render it with a single draw call, right? Storing sprite colors into vertex color attributes it's fine, and that's a rather common approach. For what concern blending (and not considering gl_LastFragData), you can'...


2

This issue happens with some MSAA or CSAA implementations. Try disabling anti-aliasing and see if it goes away. If that is the case you might need to force multi-sampling resolve before rendering your transparency. The other solution would be to force some overlap of your tiles.


2

To get rid of the lines, you need to set Pixmap.setBlending(Blending.NONE); before you draw the circle.


2

One way of doing this is using min blending. With Unity this can be set up in ShaderLab using the BlendOp command. If your objects are all monochrome as seen here, you may simply be able to use min blending directly on the objects as they're rendered and avoid having an alpha channel at all. (White is transparent when using min blending.) Min blending ...


2

If you calculate the final result as final.red = bitmap.red + viewport.red and divide by 255, then you are simply averaging them out, without taking alpha into account. The way I learned to calculate transparency is a formula that is also present in the top of the page you linked: res.r = dst.r * (1 - src.a) + src.r * src.a res.g = dst.g * (1 -src.a) ...


2

Here is how I would have done it (I've reworked your script, tell me if you don't understand something) using UnityEngine; using UnityStandardAssets.Characters.FirstPerson; public class FadeScript : MonoBehaviour { public FirstPersonController fpc; private Material material ; private float targetAlpha = 1 ; private float fadeDuration = 1 ; ...


2

You're drawing the sprite the wrong way: Gdx.gl.glClearColor(0, 0, 0, 1); // Clear the screen with black Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Clear the screen batch.enableBlending(); // Enable alpha batch.begin(); sprite.setAlpha(0); sprite.draw(batch); // This is how you should draw a sprite. batch.end(); batch.disableBlending(); This works ...


2

Change this: float3 rgb = overlying.rgb * overlying.a + (1 - overlying.a) * underlying.a * underlying.rgb; float alpha = underlying.a + (1 - underlying.a) * overlying.a; return float4(rgb, alpha); To this: return underlying + (1 - underlying.a) * overlying; Formula for alpha blending is: $$pixelColour=src\_pixel+(1−src_α).dest\_pixel$$ Taken from here, ...


2

The usual way is: Render opaque objects first Blending disabled (this does not save memory — the render target still has just as many pixels with just as many bits of colour information — but it does save time spent doing the blending calculation) Sorted front to back (so earlier objects tend to occlude later objects, and you can skip drawing some of the ...


1

This portion of your code is not technically blend state, but could be affecting the behavior here: glDepthMask(FALSE) glDepthFunc(GL_EQUAL) D3D11 does have corresponding state to this, and you can set it by creating and binding a ID3D11DepthStencilState object, in a similar way to what you're doing with the ID3D11BlendState. See https://msdn.microsoft....


1

What do you mean by "wrong"? Your first step could be to say clearly (to yourself, or in a unit test, or in this question) "I expected alphaBlend(something,something) to produce (something, preferably a number), but what I got was (something else)." Like, blended red and blue, expected purple, got mauve. Or whatever. Hex values would be clearer... At a ...


1

This is just a guess, but I notice that the edges of your image(s) are anti-aliased. When you scale the images down using Linear filtering, the semi-transparent edges might be set to black, because the filter cannot handle semi-transparent pixels. This is just an idea, but it might be worth a try to remove the semi-transparent pixels which surround the image(...


1

A quote from the document you pasted: 15.070 If I draw a translucent primitive and draw another primitive behind it, I expect the second primitive to show through the first, but it's not there? Is depth buffering enabled? If you're drawing a polygon that's behind another polygon, and depth test is enabled, then the new polygon will typically ...


1

It took quite a while but I've found the solution and am posting it here for anyone else who has the same issue. The draw code remains the same. Pixel Shader: // Texture sprite sheet. uniform extern texture ScreenTexture; sampler screen : register(s0) = sampler_state { Texture = <ScreenTexture>; MinFilter = POINT; // Stops pixels bleeding ...


1

I think you may be interested in glDepthRange (...). That affects the mapping from NDC [-1.0,1.0] to window-space Z (the depth buffer stores window-space Z) during the viewport transformation. Effectively the nearplane becomes nearVal and the farplane becomes farVal. You can fool with this to bias and/or rescale your assigned depth values, but GL clamps ...


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