DropShadowShader - coldrockgames/gml-raptor GitHub Wiki

Another simple but lightning fast shader to create drop shadows of any object.

It takes one uniform argument:

__u_shadow_alpha = shader_get_uniform(DropShadowShader, "u_vShadowAlpha");

This shader is meant to be used to draw with an offset (it's not a surface shader, so it doesn't render the object with offset by itself, instead it renders the object as shadow.

This example code shows how the Window object of raptor draws its drop shadow:

if (drop_shadow_visible) {
	shader_set(DropShadowShader);
	shader_set_uniform_f(__u_shadow_alpha, drop_shadow_alpha);
	x += drop_shadow_xdistance;
	y += drop_shadow_ydistance;
	draw_self();
	x -= drop_shadow_xdistance;
	y -= drop_shadow_ydistance;		
	shader_reset();
	draw_self();
}