I load DDS images (DXT5) with transparent alpha into OpenGL. Because the alpha is not pre-multiplied and can not be pre-multiplied based on DXT5 specs I get thin black halo around the visible part of the texture because I do some blending operations on GPU.My question is: what can be the best workaround for it.My OpenGL renderer updates scene textures on each frame loading those from IO so if I decompress the DDS then pre-muliply , then compress back I get huge overhead.Another option I thought would be to add another render pass and do the pre-multiply in fragment shader and render to texture,then use it for the main pass.This one adds overhead to the whole pipeline because I already have a descent number of passes.What are additional options here?
Asked
Active
Viewed 668 times
1

Reinier Torenbeek
- 16,669
- 7
- 46
- 69

Michael IV
- 11,016
- 12
- 92
- 223
-
1"*My OpenGL renderer updates scene textures on each frame loading those from IO*" You're loading and compressing textures every frame? Why? – Nicol Bolas Nov 05 '12 at 15:57
-
Can't explain here as it is commercial stuff but that is special purpose renderer.It is supposed to work that way :) – Michael IV Nov 05 '12 at 16:40
-
That is ,btw,the reason I use DDS here - to speed up upload time.Ah sorry , I am not compressing the textures in real time.I load ready DDSs – Michael IV Nov 05 '12 at 16:41
2 Answers
0
Why not just have your shader do the pre-multiplication of the alpha in situ, then do whatever you were going to do normally?
There's no need to render that to a texture. Just always pre-multiply in your shader, for all textures where you need pre-multiplication.

Nicol Bolas
- 449,505
- 63
- 781
- 982
-
That doesn't help.That is why I am trying the workarounds...It doesn't help ,btw , because it happens in MSAA pass so unpremuliplied DDS texture data gets interpolated and sets that nasty halo with thin black border.I figured out that GL_NEAREST removes it but it adds edge pixelation instead if the planeto which the texture applied is scaled a little. – Michael IV Nov 05 '12 at 16:39
-
You can't multisample a DDS texture (unless you're doing it *manually*, in which case it stops being multisampling). So it's not clear what you're talking about. – Nicol Bolas Nov 05 '12 at 16:58
-
By default I run several passes.The first is MSAA.I render geometry in that pass with DDS textures.Now when you say I can't do that ,may be that is the problem?I mean the black halo comes from the fact I do MSAA on DDS with alpha channel? – Michael IV Nov 05 '12 at 17:11
-
@MichaelIV: I mean you cannot create a *multisample texture* that uses a compressed internal format. You seem to be dancing around describing your actual rendering algorithm here, and that's not helping anyone get to the root of your problem. – Nicol Bolas Nov 05 '12 at 17:29
-
I use FBO which is not default. It has msaa attachment texture and I render geometry into that FBO. The geometry gets texture input from DDS and it works fine except DDS with alpha. – Michael IV Nov 05 '12 at 17:37
0
The issue solved.I had a corrupted DDS texture.The manual pre-multiplication I was doing by default in fragment shader works perfectly with valid DXT5.

Michael IV
- 11,016
- 12
- 92
- 223