Skip to main content
8 votes
Accepted

How to write a transparent shader for a sprite that ignores transparent sprites behind it?

Just change your Stencil like below Image: Stencil Op/Comparison Values Comparison Functions ...
Seyed Morteza Kamali's user avatar
6 votes
Accepted

Can I clip a collection of geometry to render only inside a particular worldspace volume?

One way to do this is with the clip function in a shader, which aborts rendering of a pixel if it fails a particular condition. This lets you create custom-shaped ...
DMGregory's user avatar
  • 135k
6 votes
Accepted

Modern OpenGL, billboarding, alpha transparency

With the help of Bálint, I successfully got the issue fixed. Bálint suggested using the discard keyword in GLSL to discard pixels that are not visible (i.e, ...
Daniel_1985's user avatar
6 votes
Accepted

How to get rid of the white border/background on my png image?

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
Bálint's user avatar
  • 14.9k
4 votes
Accepted

How front-to-back blending works?

I think a figured it out. I was correct about back-to-front blending. The destination color stores the already blended layers in premultiplied format, we assume that the alpha is 1. We don't care ...
racz16's user avatar
  • 171
3 votes

How are semitransparent polygons rendered in the correct order?

TLDR; this is one of the holy grails of computer science. It is very hard to correctly sort transparent polygons, especially when they intersect. See also painter's algorithm and this SO question. ...
Draco18s no longer trusts SE's user avatar
3 votes

Fade in rendering mode doesn't work as intended

Here's a simple fix you can use when rendering a solid object like a building. We'll copy the building and render it twice in the same location: Drawing only to the depth buffer, without writing ...
DMGregory's user avatar
  • 135k
3 votes

How to change the transparency of an object in using code?

In recent Unity version, this code is invalid gameObject.renderer.material.color.a = 0.0f ; instead first you have to get materail from rendere like this ...
Muhammad Faizan Khan's user avatar
3 votes

Why is my alpha transparency not working correctly in Unity?

Try using a different shader on your material. Unlit/Transparent should do the trick, though without any lighting.
Iggy's user avatar
  • 640
2 votes
Accepted

Why isn't my image's transparency honoured in the Unity sprite?

This may help: "simply change the render queue: - select Object Material - change view to Debug Mode (Inspector Window top right drop down menu) - change Custom Render Queue value for ...
n_plum's user avatar
  • 394
2 votes

UE4 How to Avoid Boundary Seams with Multiple Refractive Meshes

You don't say if your boxmodel uses separate materials per face - if not, I suggest that you do this. Then pre-pass each face before drawing the block, checking for a water block against each face; if ...
JonS's user avatar
  • 299
2 votes

Modern OpenGL, billboarding, alpha transparency

Yes it's the render order, but not in the way you think. The depth buffer only contains 1 dimensional data, it can't represent transparency. Even if part of the texture is transparent, it will still ...
Bálint's user avatar
  • 14.9k
2 votes

How are semitransparent polygons rendered in the correct order?

Option 1: Additive blending One easy trick you can use for explosions and such is using a special blend function. glBlendFunc( GL_ONE, GL_ONE ); This is called ...
Bram's user avatar
  • 3,719
2 votes

How to get 60fps animation in terms of rounding/truncating position/alpha floats

There’s no case I can think of where rounding values during an animation is a good idea. Color and opacity already get “rounded” by the display’s color depth (i.e. to one of 256 brightness values), ...
Noah Witherspoon's user avatar
2 votes
Accepted

Add oceans to an earth model with only continents?

I have been able to achieve it with very little changes: background water sphere uses material with standard shader and Transparent rendering mode continents-only ...
aybe's user avatar
  • 773
2 votes

Add oceans to an earth model with only continents?

You can upscale the earth model, subdivide the larger triangles that end up underwater and make sure the new vertices are all the same distance from the center as the existing vertices. There are 2 ...
ratchet freak's user avatar
2 votes
Accepted

Unity Vertex Color Shader with Transparency

After continuing testing different combinations of Shader parameters I got it working like this: I feel silly because this actually makes sense, so I don't know why I didn't try that...
Daniel Marques's user avatar
2 votes

How can I make my Camera's RenderTexture output have a transparent background?

For Unity 2019.4 I needed to set one camera as an overlay camera via... "Camera Component" --> "Render Type" --> Overlay. Secondly, I needed to take the other camera and add ...
mrVentures's user avatar
2 votes

How can I make my Camera's RenderTexture output have a transparent background?

I had the same problem and realized that my RenderTexture had a depth of 24, so no alpha. Here's a piece a code that to allows me to take a picture of a 3d model to use it as a sprite, with no ...
Vince's user avatar
  • 21
2 votes
Accepted

Rendering order objects with transparency?

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 ...
DMGregory's user avatar
  • 135k
2 votes
Accepted

Does OIT Rendering work for semi-transparent textures with opaque parts?

As documented in the link you cite: Both new methods guarantee correct coverage of background ie. they promise that the right amount of the opaque pixels behind all the transparent objects will be ...
DMGregory's user avatar
  • 135k
2 votes

Does OIT Rendering work for semi-transparent textures with opaque parts?

I found a suprisingly simple solution for my Problem. Now I don't add my Texures that have either fully transparent or opaque Pixels to the transparent mesh/buffer, but instead to the mesh for solid ...
TheBaum's user avatar
  • 43
2 votes
Accepted

Can't make simple shader transparent in Unity

This is covered in the documentation: Optional parameters Transparency and alpha testing is controlled by alpha and alphatest ...
DMGregory's user avatar
  • 135k
1 vote

How can I make my Camera's RenderTexture output have a transparent background?

If you want to layer cameras on top of each other and use the lower layered camera as the "background" to the other cameras, you need to set the Clear Flags of the higher layer cameras to Depth Only. ...
John Hamilton's user avatar
1 vote

Rendering to Texture with Transparency in Monogame?

Turns out, while no documentation I've seen backs this up, that if you throw a texture2D directly at the screen via rendertarget being null, it gets wiped out by any RenderTargets you draw via ...
user130089's user avatar
1 vote
Accepted

DX11: Alpha blending not working with textured quads

You need to set your alpha blending state according to the effect you want to achieve. In the Output Merge Stage (when you combine the objects you're drawing with the backbuffer) the blending occours ...
Liuka's user avatar
  • 585
1 vote
Accepted

Partially transparent surface over opaque surface causes strange artifacts

The "walls" are not walls, they're missing grass pixels due to the depth test. This problem is Transparency Sorting From one angle the water plane is drawn before the next chunk behind it preventing ...
Stephane Hockenhull's user avatar
1 vote
Accepted

How can I improve the display of my png files?

After you Add the alpha channel, how did you remove the background? If there are still visible bits along the edge, you can use the Eraser tool to go over the edges, or the selection tool to select an ...
Jimmy's user avatar
  • 9,029
1 vote
Accepted

Unity Custom Sprite Shader: Don't write transparent pixels into Depth Buffer

Two answers here; the first one is the one that usually works best, the second is closer to the exact answer you requested. First method In your example image, it looks like you are drawing two ...
Victor T.'s user avatar
  • 1,381

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