Welcome to Fractal Forums

Fractal Art => Animations Showcase (Rate My short Animation) => Topic started by: 3dickulus on August 21, 2013, 05:49:23 AM




Title: God Ray Octo Bulb
Post by: 3dickulus on August 21, 2013, 05:49:23 AM
This is my first attempt at actually hacking the GLSL code part of Fragmentarium
Something simple, add a "god ray" effect to whatever is being rendered.
Revised: Works best in the dark with some black fog.

http://vimeo.com/moogaloop.swf?clip_id=72793321

 Rendered with Fragmentarium 1.0b+ (http://www.digilanti.org/fragmentarium/)


Title: Re: God Ray Octo Bulb
Post by: mclarekin on August 21, 2013, 07:03:08 AM
cool effect, well done.  :) :)


I am following all the fragmentarium animation posts with much interest, though with very little technical understanding. :)



Title: Re: God Ray Octo Bulb
Post by: 3dickulus on August 21, 2013, 07:42:03 AM
tnx  :)

I'm still learning something new every day, this little hack is far from perfect, it messes everything else up so it's render this effect only or render normally but can't just turn it on and off or ease in ease out... yet  :) it's derived from something at https://github.com/larsendt/dynamic-tex (https://github.com/larsendt/dynamic-tex), not coded entirely by me, I just figured out how to patch it in as a 'post' effect.


Title: Re: God Ray Octo Bulb
Post by: 3dickulus on October 06, 2013, 02:16:57 PM
just for fun here is a little post-effect tutorial.

Files of interest: 3D.frag Buffershader.frag

Step 1:

In 3D.frag add the variables for the post effect to the variable editor by adding a new group before the "Post" group...

Code:
#group Godray
// based on https://github.com/larsendt/dynamic-tex
uniform int Samples; slider[0,0,500]
uniform float Intensity; slider[0,5.0,10.0]
uniform float Decay; slider[0.8,0.9,1.0]
// X screen location to emanate from.  Positive = out of screen Negative = into screen
uniform float ScreenX; slider[-1.0,0.5,1.0]
// Y screen location to emanate from.  Positive = out of screen Negative = into screen
uniform float ScreenY; slider[-1.0,0.5,1.0]
uniform int SubframeMax; slider[1,10,1000]

Step 2:

Then in Buffershader.frag in the main() routine after local variables and before the first test add...

Code:
// God Ray
// based on https://github.com/larsendt/dynamic-tex
if(Samples > 0) {
vec2 p = pos;
vec2 dir = vec2(ScreenX,ScreenY) - p; // Standard GodRay
float sam = float(1.0/Samples);
float i = Intensity;
if(ScreenX < 0.0 || ScreenY < 0.0) dir = p + vec2(ScreenX,ScreenY); // Anti-GodRay
dir *= sam;
for(int s = 0; s < Samples; s++) {
c += (texture2D(frontbuffer, p).rgb * i * sam) / float(SubframeMax);
i *= Decay;
p += dir;
}
}

Step 3:

Load the attached frag file with the 3Dickulus version of Fragmentarium and apply the GodRay preset.

Results: render test Posted above ^ ^ ^


Title: Re: God Ray Octo Bulb
Post by: LMarkoya on October 06, 2013, 10:03:02 PM
Nice job and a cool effect  :thumbsup1:


Title: Re: God Ray Octo Bulb
Post by: Nahee_Enterprises on October 06, 2013, 10:20:14 PM
    This is my first attempt at actually hacking the GLSL code part of Fragmentarium
    Something simple, add a "god ray" effect to whatever is being rendered.
    Revised:  Works best in the dark with some black fog.
            http://vimeo.com/moogaloop.swf?clip_id=72793321 (http://vimeo.com/moogaloop.swf?clip_id=72793321)
    Rendered with Fragmentarium 1.0b+ (http://www.digilanti.org/fragmentarium/Fragmentarium-v0.9.53Dickulus.zip)

Very nice effect with the lighting.  Some of the frames went by too quickly to appreciate the image, and at times the "light" was a bit too bright to actually see anything, but was a good initial test.     :D
 


Title: Re: God Ray Octo Bulb
Post by: 3dickulus on October 07, 2013, 12:21:11 AM
Thank you X2 :D

just thought I should share the whole thing as it makes a good post-effect tutorial.

provides God-Ray and Anti-God-Ray effect or with a little math could track the spotlight source direction  :D


Title: Re: God Ray Octo Bulb
Post by: barcud on October 07, 2013, 02:33:16 PM
This 'rays through fog' effect was something I was looking for so I gave it a try.

I just wanted to do it for one image ut a bigger render and I came across the results shown below.
When I render it with the 'God Ray' to an image where the Buffer size is locke to image size it works fine.
If I want to create a bigger render (3x3 tiles) the rays seem to get lost somehow. :sad1:

The files were created with the example frac, the changes to 3D and Buffershader and the subframe rendering set to 50.

Is that just me ( and my inability to use Fragmentarium) ?


Title: Re: God Ray Octo Bulb
Post by: DarkBeam on October 07, 2013, 07:02:33 PM
it looks more like a "zoom blur" :dink:


Title: Re: God Ray Octo Bulb
Post by: 3dickulus on October 07, 2013, 08:09:21 PM
I'm sure you applied this correctly as your images show the effect and it's limitations.
As an exorcize for the user...  :dink:

ScreenX and ScreenY values need to be offset based on which tile we are in ie: in top left tile means offset to bottom right, 2x2 will be easy because 4 corners will be the center, more than that will get a bit more complicated.

(3x3) another bug that will show up is that when we are below and/or to the right the offset will be negative which will give an Anti effect ie:the rays may bleed from bright spots into the image rather than out.

this effect was not intended for anything more than a single frame image so it might be that for tiled images it will have to be applied post assembly, after all tiles have been rendered and put together as a single image or the code may have to be rewritten completely.

it looks more like a "zoom blur" :dink:
DarkBeam is absolutely correct, this is a POST effect, this is NOT raytracing light emanating from behind or within the object,
it is bright spots smeared in a direction from an offset point,
"zoom blur" is the process "god ray" is the effect?



Title: Re: God Ray Octo Bulb
Post by: barcud on October 07, 2013, 08:45:32 PM
OK, got it.
Still, a great effect.


Title: Re: God Ray Octo Bulb
Post by: Syntopia on October 07, 2013, 10:23:05 PM
Nice effect, 3dickulus.

Just to clarify: some screen space effects will not work in tile mode since they depend on pixels from other tiles. For tile mode to work, each pixel must be calculated independently.

But in Fragmentarium v1.0 and later, you don't have to use tiled rendering. Just set the Buffer size to 'custom size', and choose whatever resolution you want. The preview window will be limited to the dimensions that are currently shown, but when you do the 'High Resolution ...' render, the actual 'custom size' buffer settings will be used. Notice that this might time out the GPU, and make the system unresponsize for some time.


Title: Re: God Ray Octo Bulb
Post by: 3dickulus on October 07, 2013, 10:56:16 PM
Thank you Syntopia for pointing that out and thanks again for creating Fragmentarium.

As my "hacks" are applied to your codebase "Custom" buffer size is available in the 3Dickulus version as well
so the frag file and code posted above should work for any resolution that is rendered as a single frame with no tiling. :beer:
however, if tiling is required then the code posted above will not work without a rewrite.

QImage/QPixmap XY axis are limited to 32767x32767 pixels afaik.


Title: Re: God Ray Octo Bulb
Post by: Nahee_Enterprises on October 08, 2013, 11:06:51 AM
    This 'rays through fog' effect was something I was looking for so I gave it a try.
    I just wanted to do it for one image ut a bigger render and I came across the results shown below.
    When I render it with the 'God Ray' to an image where the Buffer size is locke to image size it works fine.
    If I want to create a bigger render (3x3 tiles) the rays seem to get lost somehow.  :sad1:
    The files were created with the example frac, the changes to 3D and Buffershader and the subframe rendering set to 50.
    Is that just me ( and my inability to use Fragmentarium) ?
            RenderAs3x3tilesSquares.jpg
            RenderAsBufferSizeOK.jpg

Your last attachment turned out very good.     :D
 


Title: Re: God Ray Octo Bulb
Post by: 3dickulus on October 08, 2013, 11:18:18 AM
good to hear, tnx

a bit of a roller-coaster ride :D