spritesheet glsl / iterator demo

gtoledo3's picture

I've had the idea of manipulating gl color of render patches that are inside of a GLSL shader to create texture offsets since a discussion about this a long time back on the qc developer list.

This morning I was kind of curious to try hooking up a sprite sheet to the same kind of setup, offsetting y as well as x, and iterating a bunch of sprites inside.

It works. I didn't take the time to get a sprite sheet where stuff is spaced correctly or fine tune the x/y offsets, so you'll see some icons cut off/lapping onto other sprites. That's why it's here in the Woodshed. I think it's a neat thing for people to be aware is possible though, so here it is.

This would probably be a sweet way to approach certain things. You'll likely be limited by resolution of color steps, so tread lightly and test well.

Tons Of Spheres (Composition by gtoledo3)

Author: gtoledo3
License: Creative Commons Attribution-NonCommercial
Date: 2011.12.06
Compatibility: 10.5, 10.6, 10.7
Required plugins:

This composition is based around a shader that creates many spheres, with lighting, using only the fragment shader. It's based on functions found at:

...and also heavily informed by many of the examples at glsl sandbox, and probably tons of other related demoscene type shaders I've seen.

I wanted to take a distance function, create a shape with that function, and then create a grid in x/y/z with it, ala many traditional graphics examples. So, this shows how to create an object in the fragment shader, repeat it many times, and light it in a basic way.

GLSL Sandbox

psonice's picture

Not directly QC related, but I'm sure some of you will love this :)

It's a site where you can create shaders in a browser with WebGL. The shader displays in the whole window (it just draws a single window-sized quad), with a code editor overlay for you to write your shader in. It provides a few uniforms for animation (time, mouse position + screen res), and you can save (it gets added to the gallery automatically, and there's versioning built in).

Current address (might change, not sure) is:

It's under heavy development still, so it'll probably improve loads. It was made by one mr. doob who I guess some of you will have heard of, if not you should look him up, he's done some really cool work :)

Dither Circles (Composition by gtoledo3)

Author: gtoledo3
License: Creative Commons Attribution-NoDerivs
Date: 2011.10.08
Compatibility: 10.4, 10.5, 10.6, 10.7
Required plugins:

I was looking at Toneburst's port of a webGL crosshatch shader, and I thought the idea of writing different fragment colors and maybe shapes, depending on luminance, was really interesting.

I setup this shader to draw circles that are dependent on luminosity from depth channel.

For four steps of depth, you can control the inner/outer color of the circle, control the interpolation between inner and outer color, void out an area in the middle of the circle (or make it bigger than the outer circle radius, to draw a "smaller" dot than the main circle size).

I don't know if it's really appropriate to call it a dither shader at this point, but I did start with the the crosshatch mono - I deleted all of the "if" stuff after each luminance step, and inserted the code to draw the circles, which was based on this example @

The "inner circle" discards kind of "build up" in steps. So, if the first Circ_Inner has a value, all of the subsequent ones will have holes too - you can "add" in bigger holes, or change inner/outer values to kind of tweak around that. It was easier than setting up more conditional statements, and this was just a fun endeavor anyway. :-)

Voronoi Shader (Interactive - reworked from p_g) (Composition by gtoledo3)

Author: gtoledo3
License: Creative Commons Attribution-NonCommercial-NoDerivs
Date: 2011.10.06
Compatibility: 10.6, 10.7
Required plugins:

I was reading:

...and there was a really interesting shader, and video. The video showcased four interactive areas, making a voronoi, totally with a pixel shader, and I thought it was pretty cool.

The showcased code only had it setup for three areas, and there was no real setup / qtz, etc., so it was a bit of a fun challenge to add in the extra yellow area to do what it was doing in the video.