muddrox
Member
Hello, there everyone! I developed a shader that makes any sprite a solid color. It works wonderfully on windows. However, this shader fails to work the same way on Mac. On Mac, the shader effect produces a weird, staticy, rectangular effect over the sprites that are drawn with it. I have no idea why this is the case because it works perfect on my windows computer.
Here is my Shader:
-vertex shader
-Fragment Shader
Now, here is the object that actually uses the shader: As you notice in the create event, some values are initially empty. These variables are changed right after the object's create an event using another script I created called, scr_effect_flash. This script is called from within another object to initialize the variables after this object's create event. Anyways, despite what the create event initially implies, the variable, color, is immediately changed to be either c_red, c_green, or c_blue.
obj_effect_flash
-create event
-Step Event
-Draw Event
I hope this is enough information to get some ideas thrown around. I have no idea what is wrong as it works perfectly on windows but not Mac. Everything else in the game works right on Mac except for that specific shader. I thank you all in advance for you help!
Update:
I added some screenshot of examples of what is going on between windows and Mac:
Windows version (working correctly):
Mac Version (working incorrectly):
Here is my Shader:
-vertex shader
Code:
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}
Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec4 color;
void main()
{
float tex_alpha = texture2D( gm_BaseTexture, v_vTexcoord ).a;
if ( tex_alpha > 0.0 ) {
gl_FragColor = color;
}
}
obj_effect_flash
-create event
Code:
color = noone;
image_speed = 0;
uni_color = shader_get_uniform(shd_solid_color, "color");
var_red = 0;
var_green = 0;
var_blue = 0;
var_alpha = image_alpha;
glitter = part_type_create();
part_type_shape(glitter,pt_shape_spark);
part_type_size(glitter,0.10,0.10,0,0);
part_type_scale(glitter,1,1);
part_type_alpha2(glitter,1,0);
part_type_speed(glitter,0.10,2,0,0);
part_type_gravity(glitter,0,270);
part_type_orientation(glitter,0,0,0,0,1);
part_type_blend(glitter,1);
part_type_life(glitter,30,180);
emit_glitter = part_emitter_create(global.ps_main);
dir = noone;
emit = false;
Code:
if ( emit == false && dir != noone ) {
var regSize = 30;
part_type_direction(glitter, dir - 20, dir + 20, 0, 20);
part_type_color1(glitter, color);
part_emitter_region(global.ps_main,emit_glitter,x-regSize,x+regSize,y-regSize,y+regSize,ps_shape_ellipse,ps_distr_gaussian);
part_emitter_burst(global.ps_main,emit_glitter,glitter,5);
}
if ( !instance_exists(obj_player) ){
instance_destroy();
}
if ( image_alpha > 0 ) {
image_alpha -= .1;
} else {
instance_destroy();
}
Code:
if ( !sprite_exists(sprite_index) ) exit;
var_red = 1 * ( color_get_red(color) / 255 );
var_green = 1 * ( color_get_green(color) / 255 );
var_blue = 1 * ( color_get_blue(color) / 255 );
var_alpha = image_alpha;
shader_set(shd_solid_color);
shader_set_uniform_f(uni_color, var_red, var_green, var_blue, var_alpha);
draw_self();
shader_reset();
Update:
I added some screenshot of examples of what is going on between windows and Mac:
Windows version (working correctly):
Mac Version (working incorrectly):
Last edited: