texture_set_stage

Indicates which texture "slot" to add a texture to when working with shaders.

Syntax:

GML Code Example

texture_set_stage(stage, tex);


Argument Description
stage The texture "slot" to use.
tex The texture to use.


Returns: N/A


Description

This function will set the given stage "slot" a texture to be used. The number of stage "slots" available will depend on the platform you are compiling to, with a maximum of 8 being available for Windows, Mac and Linux, but on lower end Android devices (for example) this number can be as low as 2. It is also worth noting that the first stage "slot" is always used automatically by GameMaker: Studio.

NOTE: This function will do nothing outside of the context of a running shader! See Shaders for more information.


Example:

GML Code Example

glassshader_bgsampler = shader_get_sampler_index(GlassShader, "s_BackgroundSampler")
 spr = sprite_get_texture(sprite_index, 0);
 shader_set(GlassShader);
 texture_set_stage(glassshader_bgsampler, spr);
 shader_reset();
 

The above code will get the handle for the sampler within the shader indexed as "GlassShader" and then set that shader constant to the given sprite texture.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here