Hi all -
I'm still hard at work on LABWS and tonight I decided to finally start implementing some shader effects. Naturally my first attempt is to figure out how to make a spaceship look like it's splattered with poop.
My first attempt is attached as a .love file. (Press 'space' to reload). I think I have the hang of it, sort of, but I'm sure my code could be much better. I also have a few questions about implementation:
-Are there any fundamental misunderstandings in the way that I've implemented this code that I need to get past before I can be a competent shader coder?
-If I wanted each enemy ship to keep track of multiple splatters, how would I tell the shader to render multiple splatters? Ideally an enemy that gets hit from angle A will have a splatter permanently at angle A; then, later, when it gets hit from angle B, it retains a permanent splatter at angle B. Is there some way of passing data into a shader that gets stored permanently? Or should I just do something like pass in a vec4 of angles every time that the ship gets hit and then use a for loop in the shader to shade every splatter?
-Right now I can only overlay an opaque splatter over the ship (hardcode the pixel color values) or have a semi-transparent overlay (multiply the desired color value by the current pixel value). If I wanted some sort of gradient transparency overlay (i.e., a splatter with variable transparency overlaid on the ship sprite) how would I do that? I have tried just returning pixel values of, for instance, splatter.r * sprite.r * splatter.a, but this doesn't return the results that I want.
Thanks all!
Shader Question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 4
- Joined: Thu Aug 06, 2015 8:43 pm
Shader Question
- Attachments
-
- shadertest.love
- (7.56 KiB) Downloaded 78 times
-
- Prole
- Posts: 4
- Joined: Thu Aug 06, 2015 8:43 pm
Re: Shader Question
Follow-up question: when I try to implement this shader in a dynamic context, the shader generates a new noise function every frame. Ideally, I would like it to generate the noise function once and then draw from the same preset function for every future rendering. Any easy way to do this?
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests