vurtun / nuklear

A single-header ANSI C gui library
13.69k stars 1.11k forks source link

Transparency Issue when setting up Nuklear #866

Open rglusic opened 5 years ago

rglusic commented 5 years ago

Hello, I recently implemented Nuklear into my rendering framework as I believe it will be useful. I'm having a strange transparency issue though. I'm probably just missing something obvious, but I've yet to figure it out so I figured I'd ask here.

When I was making my implementation, I was mostly following along with the SDL_OpenGL3 demo listed under demos. Upon completing my implementation, I created the demo Nuklear window to test it and for some strange reason, the window is mostly transparent. I noticed that If i modify the shader to include if(Frag_UV.st == 0) { Out_Color = Frag_Color; return; } The issue goes away, but I feel that this hack shouldn't be necessary. I've attached an image below to show the issue. Sorry if this is kind of a 'newbish' question. Any help would be appreciated. I realize that this isn't entirely a Nuklear issue, and more of an issue of rendering it in OpenGL. However, I felt it might be easier to get someone's help who knows the internals of Nuklear very well. Perhaps I missed something simple. Thanks in advance, Ryan Annotation 2019-06-19 233917

dumblob commented 5 years ago

Well, everything except for nuklear.h is community maintained, so you're asking on a right place. Unfortunately though, I can't help much in this case, but what I'm asking myself how texture() behaves so that the multiplication Frag_Color * texture(... doesn't produce the desired outcome.

rglusic commented 5 years ago

You are correct. It's related to texture. More specifically its related to the textures coordinates being zero for an instance. I changed my work around to now do this instead: vec2 texCoord = Frag_UV; if(Frag_UV.st == 0) { texCoord = vec2(0.0019, 0.0019); } Out_Color = Frag_Color * texture(Texture, texCoord); This also seems to work. Strange that this is the issue though. I must not be providing the correct precision to one of the strides somewhere in my code.