PDA

View Full Version : Speeding up Blurry reflections with Nodes.



Tobian
05-08-2009, 07:12 PM
Thought I would share some tricks I have been working on to speed up reflection blurs using nodes.

I discussed it over on my SQ Pluto station thread http://www.spinquad.com/forums/showthread.php?t=14476&page=49

But in short, here's the file with the file with the nodal fiddling.

1) I have used a gradient (could have used a logic node) to tell LW that any reflections beyond 0 have a reflection blur value of 0. So the surface will be blurry, but it is not spawning child sample rays beyond that.

2) I have done the same to tell it that beyond N (in this case 1) to make diffuse 1 and reflection 0 - in effect give the reflections a depth beyond which they stop recursion, which is independent of the renderer ray recursion setting.

Scene dependant, it could save a lot of time, and visually looks quite similar. If you needed too, you could raise both depth values, to move closer to visual similarity at the expense of slightly slower (but still faster than base) render speeds!

I have a lot of reflective materials, so I am always looking for ways to lower render times! :)

let me know if this works for you guys!

serge
05-10-2009, 08:40 AM
Over 70 views and no reply for sharing a tip?

I haven't tried it yet but bookmarked for later. Ways to speed up blurry reflections are very welcome. Thanks Tobian! :thumbsup:

Scazzino
05-10-2009, 01:53 PM
Thanks Tobian! :thumbsup:

A similar approach may also be useful for limiting normal reflection recursions while allowing transparency to have more recursions. I often run into the problem where I have to crank up recursions to allow all the transparency effects but then LW wastes too much time doing extra unnecessary reflection recursions... This way we may be able to set the ray recursion limit for the transparencies and use the node trick to limit the reflection recursions only.

I'll have to try it on a scene where I can use nodal surfaces. (Can't on my current scene since I need HD Instance, which isn't yet compatible with 9.6 nodes.)

zapper1998
05-10-2009, 02:37 PM
Just took a look and wow
Learn something new everyday :)
TK

Michael

Tobian
05-10-2009, 06:38 PM
Scazzino - yes, that's exactly what the second tip is useful for.. It effectively limits reflection recursion on a per-surface basis, and I've tested it with increased global recursion, without increased render times! :) I intend to be using it soon for speedier renders! :)

Thanks guys, hope it works out for you!

adamredwoods
05-14-2009, 11:25 AM
How does this trick compare to say, the motion blur trick?
http://spinquad.com/forums/showthread.php?t=7003

Tobian
05-14-2009, 05:18 PM
I have no idea LOL. It would be different now as you'd use the adaptive sampling of the new perspective camera. Yes it would be interesting to see how it compares. It has to be said this optimises with ray-recursion in mind. That method would have blurry reflections in all recursions, so in theory, it SHOULD be faster, but it's difficult to say without running some tests.

Tobian
05-23-2009, 03:42 AM
Ok here's the full version, courtesy of Ben Vost, and Light Wiki

http://www.lightwiki.com/Optimising_Reflection_blur

MooseDog
05-23-2009, 06:45 PM
this is working really well!! thx for the in-depth wiki too, really helpful.

Tobian
05-25-2009, 09:11 AM
Let me know how much time you're shaving off render time, if any! :)

MooseDog
05-27-2009, 09:34 AM
it's definitely a big time saver:thumbsup:

the series of images below are as follows:

old-fashioned blurring:

g.i. 2m38s
render 5m31s

new-fangled blurring:

g.i. 41.4sec !!
render 3m56s

(that's a 30% decrease in render times!! congrats.)

i also did another test with an extension to your network. it involves changing the shading process by running the whole thing through a lambert diffuse node going into diffuse shading only. imho, it provides a more realistic render, but the times really start to climb again. the gods giveth and the gods taketh away! (the idea for the lambert shading thing is not mine at all, i found it i forget where so all credit to the original creator who did the final image below. i just re-purposed it here with your blurring technique. and if anyone sees any improvement to this network, speak-up! i'm pretty sure something is logically off-kilter :) )

new-fangled blurring with lambert:

g.i. 3m41s
render 6m24s

tested on an aging dual-core with 2g of ram. so it should fairly rip on a newer rig.

Tobian
05-27-2009, 05:03 PM
Hmm, the problem with doing that is 2 fold.. You are using an extra Lambert shader for no reason (the default shading IS Lambert) and you are mixing the reflection channel into the diffuse chanel. This could cause problems if you are breaking out passes.

The setup I have is a much more simple way to do it in a energy conserving way. Simply have a Fresnel gradient in the reflection channel, and the inverse in the diffuse. If you want more reflection, increase the Fresnel number. If you want to add in maps, multiply the Fresnel with maps, and again feed the output to the reflection, and the inverse the diffuse. It will create a correctly energy conserving shader, without too much extra overhead.

you are right in that mixing reflection with diffuse to equal 100% is more realistic, but that's not the most efficient method, and as you have seen, slower.

MooseDog
05-28-2009, 08:29 AM
...This could cause problems if you are breaking out passes.

good point!


The setup I have is a much more simple way...

agreed:thumbsup: i'm lovin' it, and have gratefully folded it into my presets and renders.

it would be cool to figure out how to get the "look" of my admittedly processing-heavy experiment from the simple power of your well thought out network:thumbsup:.

Tobian
05-28-2009, 10:13 AM
You can do exactly the same 'look' with my method. i am not sure what the difference is, just replace your gradient in place of my Fresnel node. It's just the Fresnel value is more 'realistic' than just using a regular incidence angle, but that's down to personal preference.

Scazzino
05-28-2009, 11:49 AM
Hey Tobian, this is great to limit the reflection recursions below the ray recursion limit. I often have a problem where I want the overall ray recursion limit low for speed but have a few transparent surfaces that I'd like to use more recursions. Any chance this type of trick could be used in reverse to increase the recursions on transparency? Since I often have many more reflective surfaces, that can't use nodes due to HD Instance, it'd be great if I could use a low recursion limit for the overall scene, but get around that limit for a few transparencies where I could use nodes... I haven't had time to play with it myself but am just thinking out loud here...

Tobian
05-28-2009, 04:04 PM
Hmm, no I don;t think you could do it in reverse, in that way because the nodes are at a per-surface level, so the trick has to apply to the surface it's being applied too hmmm..

gerardstrada
06-04-2009, 09:56 PM
Clever technique Tobian! Thank you for sharing it!


How does this trick compare to say, the motion blur trick?
http://spinquad.com/forums/showthread.php?t=7003
The only thing I can think right now is that they can be used together. Tobian's technique optimizes raytrace calculations and raytrace blurring reflections. With the old trick we still can take advantage of PR mblur for faking the blurry part. By stopping ray recursion per surface, we can optimize render times. It's possible also to apply a micro-procedural texture and smooth out the result with Pom's Random and Take Samples nodes. Results should be smoother but real reflection blur may be probably faster.

MooseDog, interesting tests! by seeing your node setup it seems the difference in your results is not lambertian but the blending mode you are using (normal). To approximate default results we can use additive or screen mode for reflection mix.



Gerardo

erikals
08-20-2009, 06:24 AM
so, with these options, it is hard to figure out what the best method is,...

Tobian method
Gerardo method
Hypersmooth method

http://forums.cgsociety.org/showthread.php?t=231398
http://www.newtek.com/forums/showthread.php?t=98938

Gerardo, i was wondering, can you explain the method you described over at cgtalk... (a loong time ago : ) ...with a bit more detail?

MooseDog
08-20-2009, 08:42 AM
i think best prolly depends on your scene and needs (yep, that's me; captain obvious! :) ). tho i also love hearing anything from gerardo.

as to your thought on animating reflection blur, couldn't you: replace the scalar node in tobian's set-up with a gradient node having only one key, that key being animated via it's envelope.

erikals
08-20-2009, 08:50 AM
i guess, but i'm a bit curious atm at Gerardo's method,...

the thing is, it was written a long time ago, so i'm not sure the example still stands,
and if, how much time would it save compared to LW's current solution.

if anyone could elaborate a bit more (hehe, i have no clue really http://forums.cgsociety.org/images/smilies/smile.gif) ...on that Gerardo setup maybe we could get some more insight to if it'd work.

i'm also interested in hearing from people who have tried hypersmooth, does it run in 9.6? is it fast?

Tobian
08-20-2009, 08:55 AM
Simple - Mine :p

Not sure at all what Hypersmooth does or how it works, but I don't know how it compares to Lightwave's current reflection system(it's been speeded up since LW8), or indeed a proper Gaussian sampling schema (such as Pomm's node! Slow but hugely better!) As to Gerardo's method, you can open my scene, and apply his method instead, and try and get a similar effect, and see how the render times compare. You can also apply some of my methodology to the Gerardo method too (apply the spot node/logic to bump amplitude/movement so bounced recursion rays don't get multi-sampled beyond the first bounce) Either way it's quite possible to combine the techniques (well not hypersmooth)

I am thinking that someone needs to do exhaustive tests to compare - I am not sure I can be bothered :D

erikals
08-20-2009, 09:01 AM
;)

ok, thanks, i will search some more... http://forums.cgsociety.org/images/smilies/smile.gif
http://www.newtek.com/forums/showthread.php?t=61465

gerardstrada
08-21-2009, 02:20 AM
Erikals, the old method still stands. There's an old thread (http://www.spinquad.com/forums/showthread.php?t=7003) over Spinquad forums where I shared the sample scene (the mblur parameter controls the smoothness of the effect). The bump map doesn't need any gradient, btw. Maybe a nodal adaptation could be in this way:

http://imagic.ddgenvivo.tv/forums/microptrfltn.png

We could use a micro-procedural texture instead of a noise map. Pom's Take Samples node could be useful with a very low range of samples (2-3) if we are planning to use low AA passes without Adaptive Sampling.

According to my test here, the old trick is still a bit faster. Mainly because it doesn't use reflection blur option, though I think the Blur parameter offers a better finishing. Then, I'd use Tobian optimization setup if I'd need to apply the reflections over polished materials (no visible bump maps, like in a calm river for example), and the old trick for materials with visible bump maps (like a turbulent sea for example) or still images. Though there's no reason why we can't mix both solutions, too. I like these kind of optimizations through nodes because we can use native LW solutions with simple setups.

There's a faster way also through DP_IFNE that I prefer to use more to enhance LW's reflection blur, but it could work alone as well as post-filter. I probably share the setup in the second HDRI3D article about Filter Node Editors.

Btw, HyperSmooth work only until LW 8.x version, but by running under LW 7.5, it's still surprisingly faster than current anireflections (!)



Gerardo

Tobian
08-21-2009, 06:56 AM
Out of curiosity why do you need to make a vector out of the random node: Scalar inputs go straight into vector one's without a problem?

yeah one problem with any king of normal perturbation is that it affects everything (unless you use a per shader normal as you did there Gerardo) I.e. If you had some glass and you wanted to make it slighty burred on the surface, but not in refraction, you would have to do the normal displacement only in the reflection and not the surface normal (or bump). In the inverse, you often get materials which are quite diffusing, but have a very sharp reflecting surface (smoky glass, semi opaque plastics etc.) It's one of the bugbears of 'materials' that you can't have different reflection and refraction blurs!

erikals
08-21-2009, 12:35 PM
hm,.. i need to do some more tests, here's one,...
just LW reflection blur, rendertime 5min,...
scene posted here,
http://www.newtek.com/forums/showthread.php?t=98572&page=2

http://www.spinquad.com/forums/attachment.php?attachmentid=37908&stc=1&d=1250877869

erikals
08-21-2009, 01:50 PM
Tobian's scene (loacted here (http://www.newtek.com/forums/showthread.php?p=881951#post881951)) with adaptive sampling set to 0.01
rendertime 5min, that's very good for a scene like this,... (using a Quadcore 2.6)

however, the scene setup we have here is not optimized for animation and motionblur,
so i'm gonna do some tests, in a bit.

http://www.newtek.com/forums/attachment.php?attachmentid=76460&stc=1&d=1250885137

erikals
08-21-2009, 03:24 PM
hm, it went surprisingly well, rendertime 10 min on a Quad 2.6

not bad, considering there is no noise... :thumbsup:

http://www.newtek.com/forums/attachment.php?attachmentid=76461&stc=1&d=1250889690

erikals
08-21-2009, 04:38 PM
last test, same scene, lower AA, 'higher' AS 0.25, lower MBpass...

http://www.newtek.com/forums/attachment.php?attachmentid=76464&stc=1&d=1250895875

Simon
08-21-2009, 06:13 PM
it's definitely a big time saver:thumbsup:

the series of images below are as follows:

old-fashioned blurring:

g.i. 2m38s
render 5m31s

new-fangled blurring:

g.i. 41.4sec !!
render 3m56s

(that's a 30% decrease in render times!! congrats.)

i also did another test with an extension to your network. it involves changing the shading process by running the whole thing through a lambert diffuse node going into diffuse shading only. imho, it provides a more realistic render, but the times really start to climb again. the gods giveth and the gods taketh away! (the idea for the lambert shading thing is not mine at all, i found it i forget where so all credit to the original creator who did the final image below. i just re-purposed it here with your blurring technique. and if anyone sees any improvement to this network, speak-up! i'm pretty sure something is logically off-kilter :) )

new-fangled blurring with lambert:

g.i. 3m41s
render 6m24s

tested on an aging dual-core with 2g of ram. so it should fairly rip on a newer rig.

That was my screenshot :) here's the original thread although the attachments seem to have disappeared now. I think that must have been before the delta material was introduced which I guess does a similar thing.

http://www.newtek.com/forums/showthread.php?t=50504&highlight=additive+reflections

gerardstrada
08-22-2009, 01:18 AM
Out of curiosity why do you need to make a vector out of the random node: Scalar inputs go straight into vector one's without a problem?

Mainly because we have the chance to choose what vector we want to move. We can get different - and smoothed results - by moving only the vector in Y direction, for example. And because - as a general rule - I've noticed also that we can commonly get slightly faster results when we made this convertions before.



yeah one problem with any king of normal perturbation is that it affects everything (unless you use a per shader normal as you did there Gerardo) I.e. If you had some glass and you wanted to make it slighty burred on the surface, but not in refraction, you would have to do the normal displacement only in the reflection and not the surface normal (or bump). In the inverse, you often get materials which are quite diffusing, but have a very sharp reflecting surface (smoky glass, semi opaque plastics etc.) It's one of the bugbears of 'materials' that you can't have different reflection and refraction blurs!



I agree. Maybe, you might want to try the old mBlur trick in IOR parameter here. Just input an envelope with repeating values from frame to frame, By activating motion blur you can have blurred refractions but crispy reflections. Btw, the old mBlur trick with micro-procedural textures with blurred reflections can be used also for blurred refractions.

Interesting tests, Erikals! http://forums.cgsociety.org/images/smilies/smile.gif



Gerardo

erikals
10-29-2009, 06:55 PM
found a new cool trick, http://forums.cgsociety.org/images/smilies/smile.gif
http://www.newtek.com/forums/showpost.php?p=942169&postcount=6

Hieron
07-18-2010, 09:08 AM
Hey Tobian, I'd like to thank you for this tip on decoupling the reflection (or anything really) recursion depth from the global one. Even though I wasn't so amazed before.

It sure is helping me very nicely in my current scene. It dropped rendertimes by a factor of 8. And for that, I happily sacrifice the secondary effects of recursed reflections.

Thanks mate.. appreciated.

Tobian
07-19-2010, 06:35 PM
Ahh I am glad it's working out. Yeah It can be very scene dependant, I have found myself and multi-cores affects it too, but it's nice to have, as opposed to nothing, which is the other option! :D

erikals
07-19-2010, 11:02 PM
also use Neat Video to remove noise, works great...(!)
http://www.youtube.com/watch?v=azsGidV871o#t=3m48s
discussion thread,
http://www.newtek.com/forums/showthread.php?t=108638

jrandom
07-22-2010, 04:22 PM
also use Neat Video to remove noise, works great...(!)

They finally made a video version! I've been a user of Neat Image for years.