aa thanks a lot! I'm happy you guys are still following! :D
alllsooo neW THINGS IM EXCITED ABOUT!
Check out these new and improved shrooms!!
Now, the mushrooms aren't the thing i'm so excited about, just a vessel of it:
I have finally figured out a way to draw on top of my lighting shader while still under the other shaders!*
*It's not actually drawn on top, as we will see in my explanation belowThe thing I disliked most about my lighting, specifically the colored lights part, is that it washed out, flattened, and overpowered basically everything on screen in that area. I've spent the most time tweaking color values in such a way to minimize over-flooding necessary detail, while maximizing the prettiness of the lights, because the less opaque I make the lights, the less likely i'll get the colors to match up to the ones I want in my palette. for instance: the brightest blue in that latest gif needs to be fairly opaque in order to turn out that color, but because I couldn't draw beneath the shader, it would just make every pixel in that area that color, and I really hated it. You can tell in the older mushroom gif how low-intensity the lights are. That's the other end of the extreme, and neither looks that great in my eyes, or at least it's not perfect.
This is what they looked like before, and what they would've looked like if I didn't make the lights so dim. The light itself looks so much cooler, but it's totally useless if you can't see what's emitting it!
So, I basically needed a way to draw between the shaders.
For the longest time this has been the last thing i've considered impossible to do. I never thought I'd be able to do the original lighting, never thought i'd be able to turn it into a shader, never thought i'd optimize the lighting algorithm enough to use in the game, etc. etc. I've surpassed them all for the most part, except
the one; drawing between shaders. I spent a long time thinking about this and basically regarded it as impossible to do in Stencyl, the tool I'm using to make the game. I needed to be able to split shaders into layers and draw between them, so I could have my pixel quantization, color palette, and screen warp shaders still in effect and the lighting shader overwritten. Before transitioning to shaders I could do this pretty well:
I have 2 different layers of lighting here: One in front of tiles, and one behind. and
both are behind this beautiful ghost bird.
This was great because I could have high-intensity light on the background, while maintaining detail on the tiles and other stuff immediately behind the light.
(Also these gifs just made me realize I've forgotten to add the light-trail thing in the newer build. maybe it looks better without it? I don't know. Let me know what you think please thanks)
Anyway, here's how I did it.
Just like the dumb hacky way I'm currently sending the tile data and light color arrays to the shader (arrays of 10-digit integers, mod-ing/floor dividing to grab sections of digits as data), This "fix" is too, dumb and hacky.
Basically I'm doing another check in the lighting shader to see if it should draw onto the current pixel or not. The only data any pixel could have is 3 8bit RGB colors (and a useless constant alpha). So What I'm doing is i'm quantizing
(boy I guess I love this word) each 255 integer to a multiple of 16, and checking if each R G and B value is a multiple of 16, and iff it is, don't draw on top of it.
vec4 origColor = texture2D(uImage0, vTexCoord);
if((colored) && (mod(floor(origColor.rgb * 255.0 + 0.5), 16.0) == vec3(0.0))){
gl_FragColor = origColor;
} else {
Because this is terrible and hacky, this basically only works in the case that Ghost Bird is in currently. I'm restricting the game to a small color palette, so I can almost guarantee that none of the colors in the game will randomly create a false-positive for this check. Even the lighting that uses very much off-palette colors, which
used to be drawn on screen normally, is being drawn within the same shader so there's no way these colors could accidentally create false positives either. Any other game and there would be random misplaced pixels.
Also I'm not too sure about the nitty-gritty details of shaders, but this extra check could possibly be saving GPU time. I've read that if-statements are not good because of divergence (maybe this specific check is ok though?), so that may attribute to a slower shader, but if it's not too much slower the check basically exits the whole shader code for that pixel, which has a ton of stuff like color blending, etc.
But yeah. There you go. Final annoyance solved. I have full control over what colors are drawn to the screen. I no longer have anything to whine about besides my own working speed.
Time to go make everything even more pretty!