Previous topicNext topic

Shaders

Questions, comments, feedback, etc.
Syd
Posts: 60
Joined: Thu Oct 16, 2014 10:32 am

Re: Shaders

Post by Syd »

I've noticed since this change some shaders have a 0.0 alpha set. This doesn't effect magic, but you can trip you up if you're syphoning out etc.

example: https://www.shadertoy.com/view/MlsGRS

Code: Select all

	fragColor = vec4(final*fog,0.0);
Magic
Site Admin
Posts: 3677
Joined: Wed Apr 09, 2014 9:28 pm

Re: Shaders

Post by Magic »

Yeah that's because of premultiplied alpha (a common theme recently it seems: http://magicmusicvisuals.com/forums/vie ... ?f=2&t=355).

Magic handles alpha the same way Shadertoy does, but other apps handle it incorrectly (er, differently). :)

For the technically-inclined, the difference in OpenGL is:

Code: Select all

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
instead of

Code: Select all

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
See http://blogs.msdn.com/b/shawnhar/archiv ... alpha.aspx for more info. The key issue is the proper handling of alpha cutouts and image composition (last sections of that article).

Also http://home.comcast.net/~tom_forsyth/bl ... lpha%5D%5D is a good one, especially the section "Compositing translucent layers".
Post Reply