Page 2 of 3

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 15:04
by Skinnytorus
Not exactly. I wanna modulate fog density by a 3d noise texture.
Take a look at that: http://blendersushi.blogspot.ru/2012/01 ... nsity.html

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 17:08
by ikam
ok i see

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 17:15
by Skinnytorus
My logic is this: if the spherical fog shader has a falloff, then it's a gradient. Gradient is a lerp function, right? Why can't we use some other function (noise) to modulate the falloff? You see?

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 19:19
by ikam
it should be possible to do somthing for spherefog.
let me try.

ps : you can show the code in material operator, by getting Pixelshader, relative code to fog here is marked by the "// tint " comment.
Enable customCode to test your changes, it is how I debug shaders ;)

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 19:36
by ikam
try this :

float radius = temp00.x * 10;

for the first line. (temp00 is the 1st slot texture) and put a perlin texture

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 19:59
by Skinnytorus
The material becomes all red after I insert the line. Can you share your example file?

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 20:26
by ikam
here

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 20:44
by Skinnytorus
That's much better, but how do we deal with a situation with different materials?

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 20:57
by ikam
repeat operation on each material you want to expose the effect. and use a 2nd texture slot (a second diffuse) only to bind the texture to the shader, and to use this second texture for the fog modulation. first diffuse will be the real diffuse texture.

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:02
by ikam
if you like the effect, I can modify spherefog operator to get an optional texture on input...

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:05
by Skinnytorus
I got your point. Thanks. If you rotate camera, the fog texture is scrolling. Kinda cool effect, but normally, it should stay in place. And another problem - it's a 2d effect. Can it be 3d?

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:14
by ikam
no it is only 2d. it affect only surfaces from camera direction.
WIth a sphere we can't show the trick and we think that is a 3d volume, but with another shape we see that texture is scrolling.

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:26
by Skinnytorus
I see. A sprite with camera projection ;). Why not? It may sometime be of some use. Go on with the modification. Thanks.

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:36
by ikam
we also can replace fog color by a texture :p

Re: Volumetrics / Ray Marching

PostPosted: Thursday, 15.May 2014, 21:38
by Skinnytorus
A cool effect. Maybe you should make fog texture animatable?