Tons Of Spheres (Composition by gtoledo3)

Author: gtoledo3
License:
Date: 2011.12.06
Compatibility: 10.5, 10.6, 10.7
Categories:
Required plugins:
(none)

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: http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm

...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.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

...and, this may make plugging in different distance equations a bit more clear (I can see how it still may be confusing?). Some additional with torus, hexagon and cylinder shapes. :-)

psonice's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Cool! I'm really happy to see this :D

Now you've got the basics down, go do something really cool with it :)

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Cool, thanks. I think I may have it down a few steps past this, but tend to post many steps behind wherever I'm currently poking around :-) I've made some more complex scenes. This originated in a thing where I was testing drawing many objects and texturing them via a vao/vbo route, vs. doing it all in a fragment shader (for some scenarios).

This isn't anything "really cool with it", but it's a little mix between the two shapes :-)

PreviewAttachmentSize
tons of hex spheres.qtz10.18 KB
tons of hex spheres.png
tons of hex spheres.png209.47 KB
tons of hex donuts.png
tons of hex donuts.png194.51 KB
tons of hex donuts.qtz10.39 KB

photonal's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Nice one! Thanks for sharing that.

benoitlahoz's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Great runs ;-) Thanks for sharing !!

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Here's a twist up that has a rippling floor, and has "breathing" tubes. :-)

PreviewAttachmentSize
tons of breathing stuff.qtz11.12 KB
tons of breathing_stuff.png
tons of breathing_stuff.png148.59 KB

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Thanks @ benoit & photonal :-) Checkout the examples at glsl sandbox, and the "704" glsl example; this is essentially a mish mash of stuff informed by that, as well as iq's stuff.

cybero's picture
Re: Tons Of Spheres (Composition by gtoledo3)

That's some thread, thanks for posting those great shaders' QC porting, re-workings and developments.

Just managed to crash a 2d Fluid Simulation fed by an RII of the Spheres shader.

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

cybero wrote:
That's some thread, thanks for posting those great shaders' QC porting, re-workings and developments.

Just managed to crash a 2d Fluid Simulation fed by an RII of the Spheres shader.

Ok, here's a sort of big issue...

The Render In Image patch basically sucks.

I saw that with some caveats; in some scenarios, one can coax better performance out of a patch. It's also essential to be able to grab the texture of a scene and feed it back on itself, in a "self contained" way.

What I've found recently is that there is a pretty big issue when running some shaders inside of the Render In Image patch, and them flipping on the y axis. This is an issue in Lion as well as Snow Leopard, but the issue exhibits itself in different ways. In Lion, the image flips, but if you do, say, a feedback loop, at least the feedback loop seems to return "flipped" as well - but not all the time :-). In SL, there seems to be some issues with stuff not getting returned "correctly" with the flip, and maybe some kind of bit depth/color issues that keep finicky stuff from working correctly.

This means, basically, one cannot make Render In Image oriented patches, at least right now, and have any expectation of compositions working in the same way between 10.7,10.6, and 10.5. There seem to be fairly big changes between this patch between each version of the OS, that amounts to big inconsistencies. As is, it can't be construed to be working 100% correctly. It puts QC in a crappy place, because this is a majorly important function.

I have a render in image type environment patch that isn't totally crazy :-) ...that I put together awhile back, along with similar patch to help with multipass rendering. I've had way more pressing projects that have kept me from giving a last look at those, tightening them up, and releasing. It's not great though, because it's "skanky", and doesn't leave a standard api solution, afaik.

This is a roundabout way of saying...

Take a look at any shader you're thinking of feeding "openCL". See if it has flipped or done any other weird stuff. If it has, think hard before connecting it! Also, as much OpenCL stuff as I've done, I'm extremely hesitant about it's stability across Macs. I've managed to totally destroy multiple partitions by doing stuff like "hooking up a Render In Image patch to an OpenCL kernel". QC has "issues", especially with OpenCL and RII, so be careful :-)

gtoledo3's picture
Re: Tons Of Spheres (Composition by gtoledo3)

Here's another :-)

Also, on the RII thing, make sure you have specified pixel w/h to whatever the fluid sim is expecting.

PreviewAttachmentSize
tons of breathing stuff 3.qtz10.28 KB