Skip to content

How to make groups #98

Answered by pragma37
HSDSZ asked this question in Q&A
Jul 11, 2021 · 2 comments · 5 replies
Discussion options

You must be logged in to vote

Hi! I'm glad that Malt is helping you to get into shader coding. :)

For grouping variables, you can use structs. For example:

#include "Pipelines/NPR_Pipeline.glsl"

struct TextureSettings
{
    sampler2D texture;
    int uv_index;
};

uniform TextureSettings Color_Texture;

void COMMON_PIXEL_SHADER(Surface S, inout PixelOutput PO)
{
    PO.color = texture(Color_Texture.texture, UV[Color_Texture.uv_index]);
}

Alternatively, you can also use _0_ as a separator in the variable name.

#include "Pipelines/NPR_Pipeline.glsl"

uniform sampler2D Color_Texture_0_texture;
uniform int Color_Texture_0_uv_index;

void COMMON_PIXEL_SHADER(Surface S, inout PixelOutput PO)
{
    PO.color = texture(Color_…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@HSDSZ
Comment options

@HSDSZ
Comment options

@pragma37
Comment options

@HSDSZ
Comment options

Answer selected by pragma37
Comment options

You must be logged in to vote
1 reply
@pragma37
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants