Hi
I would like to start discussion about shading techniques for 3D fractals. At start I will share my experience in this topic. I rendered the same view of 3D Mandelbrot fractal (Twenbee's formula) in several shading techniques.
My method of rendering bases on high resolution slices (big 3D array) containing information about number of iteration for each voxel (3D pixel). I know that this is not most efficient method but 3D arrays deliver information about whole fractal and enable rendering with complex shading. Another benefit is possibility to render transparent fog where opacity is proportional to number of iterations.
I have developed following shading methods:
- hard shadows
- angle of incidence of light based on estimated normal vectors
- environment mapping based on estimated normal vectors
- global illumination
Hard shadowshttp://www.fractalforums.com/gallery/?sa=view;id=927This is the simplest method for shading 3D fractals. From each visible voxel you have to send virtual ray towards light source. If ray meets some obstacle you have to set light intensity for rendered point as zero or decrease light intensity proportional to opacity of encountered voxel (number of fractal iterations).
Angle of incidence of lighthttp://www.fractalforums.com/gallery/?sa=view;id=928Calculating angle of incidence of light requires information about angle of normal vector for surface near rendered voxel. It is very difficult to calculate accurate normal vector for 3D array of voxels when fractal is rendered using iteration count. Iteration count function unfortunately is not solid. There is Distance Estimation method which provides solid function of distance to fractal border but it is possible to use this method only for hypercomplex fractals. David Makin developed method for calculating distance function but I tried with this with no result
(I don't understand enough David's algorithm).
The simplest method of getting normal vector is calculate something like gradient of potential function where potential equals to iteration count or estimated distance.
This is very simple to calculate. For normal vector calculation you have only subtract values of adjacent pixel in every direction (x,y and z). For example:
delta x = f(x+0.5,y,z) - f(x-0.5,y,z)
delta y = f(x,y+0.5,z) - f(x,y-0.5,z)
delta z = f(x,y,z+0.5) - f(x,y,z-0.5)
(I can use 0.5 offset value because I'm using 3D interpolation)
Next you have to normalize this vector by dividing each component by length of above vector.
Dot product of normal vector and light direction vector will be intensity of light.
light intensity = N.x * light.x + N.y*light.y + N.z*light.z
This simple method is working but looks not so good in zoom
You can achieve best result when you calculate average gradient for some small area near calculated point. I usually use 3x3x3 voxels area.
Bellow is an example render with this approach. On this image fractal surface is smooth but unfortunately lost some details.
http://www.fractalforums.com/gallery/?sa=view;id=930To be continued...