Asset - Scripts EZ Shader - Simplify working with Shaders

S

smashingparadox

Guest
Hi everyone,

Here is my shader interface library:
https://marketplace.yoyogames.com/assets/6348/ez-shader

How does this help?
When you use shaders in your game, you often want to be able to modify variables inside the shader. But in order to do this, you have to do a weird handshake to attach GameMaker variables to *GL shader variables. This library does all the handshaking for you, so that you can simply set GameMaker variables to control shaders.


Avoid writing this code... I've done it for you!
upload_2018-9-30_12-59-34.png
(From the Marketplace Page):
Description

EZ Shader

EZ Shader eliminates the redundancy of setting up shaders in Game Maker. Just call 3 scripts and you can quickly interface with shader parameters (uniform variables).

Features
  • Scripts for getting and setting 19 commonly used uniform variables
  • Bonus function: draw a rectangular outline with a defined width: draw_rect(x1, y1, x2, y2, border_width);
  • Bonus function: draw a button with style: draw_btn(x, y, color, text);
How to use EZ Shader in your game in 3 easy steps:

The main scripts you need are

ezshader();
get_uniforms();
set_uniforms();

1. In a create event, call
ezshader();
get_uniforms(your_shader_name);

2. In a draw event, call
Code:
shader_set(your_shader_name);
   set_uniforms();
   {draw something}
shader_reset();
3. (Optional) In another event (step event, button press, etc) call something to modify a uniform variable listed in the ezshader() script
Code:
//Make the parameter for a shader oscillate
params[2] = cos(global.Time / 20) * 20;

//Make the color of the shader oscillate
setShaderColor(0.5, 1, cos(global.Time/20), 1);
 
Last edited by a moderator:
Top