kupo15
Member
The better I get at shaders, the less I understand how to manage it all. So many uniforms that have to be assigned to specific shaders. Also the logical way to organize things seems not good for shaders given the nature.
For example, if I have a palette swap shader and a contrast shader, my normal instinct would be to make them both separately and then apply them independently. But this won't be good because then you are double processing the pixels with two passes. Then if you want to also have a pixelation shader as well, that's 3 passes.
Does this mean its better to essentially create shaders with every single combination possible and have a ton of uniform sets to match then pick which one to apply in the draw event?
Or would it be better to only have ONE shader only that does it all and you pass uniforms that toggle on and off the different steps of the different effects? And somehow doing it without if statements in the Shader.
Here are my stray thoughts I had how to wrap my head around this as I was talking with Hopeless. Just pasting my spitballing from our chat:
@Xor @The Reverend @GMWolf
For example, if I have a palette swap shader and a contrast shader, my normal instinct would be to make them both separately and then apply them independently. But this won't be good because then you are double processing the pixels with two passes. Then if you want to also have a pixelation shader as well, that's 3 passes.
Does this mean its better to essentially create shaders with every single combination possible and have a ton of uniform sets to match then pick which one to apply in the draw event?
Code:
// DRAW
shader = pixel
shader_set(shader)
switch shader
{
case pixel: set pixel uniforms break
case pixel palette: set pixel palette unforms break
}
draw_sprites
end shader
Here are my stray thoughts I had how to wrap my head around this as I was talking with Hopeless. Just pasting my spitballing from our chat:
hmm well looking at the code, perhaps you do have to have each object set/get it in the create so both can have different values. i think what's confusing is that it seems like you are working backwards
I was always confused why its uniform_GET in the create event....not set
so with scripts, you call the script and set variables in it. but with shaders, I think the uniforms inside the shader are where they are initialized...aka the true create event is there. and the objects create event is getting the reference to those uniforms kinda like pixel_pointer = shader.pixSize
do we have to do it in the create event? Can we call that every frame in the draw? otherwise if you have two shaders that use the same uniform and you want to use the same variable you have to do like texSize1 = get (shader0) texSize2 = get (shader1)
blahh, its so fragmented dealing with 3 different places lol I wish I could just pass them in like you do with scripts
Its definitely a clusterF to figure out how to organize the code
that's where my 2 hour time waste struggle happened. I think I overrode the same variable with another shader because I wanted one shader to draw the distortion, and another one which basically is the same to draw the normal map somewhere else for previewing
in that case it would be great to be able to run shader code inside of a shader
I was always confused why its uniform_GET in the create event....not set
so with scripts, you call the script and set variables in it. but with shaders, I think the uniforms inside the shader are where they are initialized...aka the true create event is there. and the objects create event is getting the reference to those uniforms kinda like pixel_pointer = shader.pixSize
do we have to do it in the create event? Can we call that every frame in the draw? otherwise if you have two shaders that use the same uniform and you want to use the same variable you have to do like texSize1 = get (shader0) texSize2 = get (shader1)
blahh, its so fragmented dealing with 3 different places lol I wish I could just pass them in like you do with scripts
Its definitely a clusterF to figure out how to organize the code
that's where my 2 hour time waste struggle happened. I think I overrode the same variable with another shader because I wanted one shader to draw the distortion, and another one which basically is the same to draw the normal map somewhere else for previewing
in that case it would be great to be able to run shader code inside of a shader
@Xor @The Reverend @GMWolf
Last edited: