Logo by Fiery - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. May 26, 2020, 03:33:04 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Sample code for shaded 3D fractal plots?  (Read 6067 times)
0 Members and 1 Guest are viewing this topic.
Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« on: May 12, 2007, 10:32:20 PM »

I'd like to try my hand at creating 3D renderings of Mandelbrot and Juila plots (rather like the cover of "The Beauty of Fractals", but more interesting plots.) I'll eventually want to implement animated "flyby" movies that zoom into plots, but for now, I just want to create still plots.

I want to use fractional escape counts as a height (z) value.

Can any of you point me to some sample code for taking a height map and rendering it as a 3D plot, ideally shaded as if from a soft, directional light-source? It's not critical that the the lighting and shading be mathematically correct, but just that it help show the form and texture of the 3D plot.

I haven't tackled 3D rendering before, so I could use some sample code to get me started, ideally in C or C++, but pseudo-code would be fine too.



Duncan C
« Last Edit: May 12, 2007, 10:43:49 PM by Duncan C » Logged

Regards,

Duncan C
iteron
Guest
« Reply #1 on: May 23, 2007, 05:29:43 PM »

It's easy to create 3D renderings of Mandelbrot and Julia plots using a program like POVray, it's fully programmable in POVray script which is easy to learn and there are many examples and tutorials available.  Getting POVray to read a heighfield and render it is very simple. Also there are ways to create movies with POVray and because it's a raytracer the results are very impressive.

But I'm not sure this is the kind of thing you have in mind, how are you going to generate the heightfields?  There are several utilities on the web for generating heightfield maps for example John Beales' HFLab is very good  but it is DOS based, you can also use Fractints' POT files but Fractint doesn't give alot of control over the result and it's also DOS based. There's Terraform for UNIX, also some commercial products (expensive).   It's even possible to use POVray itself to create the hightfield bitmaps also Matlab (expensive) or Scilab (free) can generate heighfield bitmaps.

 You could program your own heightfield program (in fact I've not found a nice graphical modern free or low cost program for generating heighfields for Windows) in that case you'll probably use some kind of fractal based technique like the ones described in "The Science of Fractal Images" by Heinz Otto Peitgen.

Are you going to program your own renderer?  If not you'll probably use OpenGL or D3D or a raytracer.  POVray is easier than OpenGL but it doesn't offer the same interactive possibilities other than turning your images into movies.
Good luck with your project.
Regards,
Marc

 
« Last Edit: May 24, 2007, 08:42:26 PM by iteron » Logged
Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #2 on: May 26, 2007, 08:35:10 PM »

It's easy to create 3D renderings of Mandelbrot and Julia plots using a program like POVray, it's fully programmable in POVray script which is easy to learn and there are many examples and tutorials available.  Getting POVray to read a heighfield and render it is very simple. Also there are ways to create movies with POVray and because it's a raytracer the results are very impressive.

But I'm not sure this is the kind of thing you have in mind, how are you going to generate the heightfields?  There are several utilities on the web for generating heightfield maps for example John Beales' HFLab is very good  but it is DOS based, you can also use Fractints' POT files but Fractint doesn't give alot of control over the result and it's also DOS based. There's Terraform for UNIX, also some commercial products (expensive).   It's even possible to use POVray itself to create the hightfield bitmaps also Matlab (expensive) or Scilab (free) can generate heighfield bitmaps.

 You could program your own heightfield program (in fact I've not found a nice graphical modern free or low cost program for generating heighfields for Windows) in that case you'll probably use some kind of fractal based technique like the ones described in "The Science of Fractal Images" by Heinz Otto Peitgen.

Are you going to program your own renderer?  If not you'll probably use OpenGL or D3D or a raytracer.  POVray is easier than OpenGL but it doesn't offer the same interactive possibilities other than turning your images into movies.
Good luck with your project.
Regards,
Marc

 

Marc,

I'm planning on using the distance estimator algorithm spelled out in "The Science of Fractal Images" for my height map. For a modern computer, I think it makes sense to use OpenGL. That way it will work on any system, but will take full advantage of high end graphics cards. Time to read up on OpenGL it seems.

I don't want to rely on a third party application to generate my 3D maps. I want to create them directly from my application. I'm hoping to create 3D animations of various sorts. (Imagine a zoom into a 3D rendering of a Mandelbrot or Julia set, where as you zoom in your point of view changes, and more and more detail is revealed as you zoom deeper and deeper. Or imagine a 3D julia "movie", where it shows how Julia sets change as the source "C" point walks along a curved path through the Mandelbrot set.

Can somebody recommend a good book on 3D graphics in general, and OpenGL in particular?
Logged

Regards,

Duncan C
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #3 on: May 27, 2007, 01:59:03 AM »

Can somebody recommend a good book on 3D graphics in general, and OpenGL in particular?

my current university and the one i attended previously both used "the angelbook": edward angel, "interactive computer graphics: a top-down approach using opengl" (2006 ed). personally i hate it (full of little errors and sometimes greviously misleading), as did many people at my previous university, but most people seem to like it and it's pretty widely used so... you can have a look at that.

what i really wanted to say though: if you follow a well-trodden path your programs will look just like everyone else's; mutatorkammer is already doing almost exactly what you've described in your post. just about everyone codes a little heightmap viewer in introductory graphics courses (i've just had to code one for my silly graphics course), and i wouldn't be surprised if some people used fractals to define the height values - they all look the same and do the same thing sad there's code aaaaaaaaaaaaaaall over the net for rendering heightmaps, it's been done to death.
Logged

lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #4 on: May 27, 2007, 02:15:34 AM »

POVray is easier than OpenGL but it doesn't offer the same interactive possibilities other than turning your images into movies.

actually, in 2004 for a university assignment i implemented realtime ray tracing as a means to visualise l-systems. why? properly implemented, the time complexity of ray tracing is primarily driven by the pixel resolution, NOT the amount of geometry to be rendered, i.e., is O(pixels * log(n)) where n is the number of primitives to be rendered. that means that after a while (with sufficiently much geometry, which the exponential l-system growth assured) ray tracing becomes faster than any gpu, i.e. you get an intersection of the linear and logarithmic curves.

too bad most interesting/original fractals can't be ray traced, so i had to make my own rendering method for those (but that's a long story: http://ompf.org/forum/viewtopic.php?p=3732). in any case, pov-ray inescapably looks way too 80s for my taste wink
Logged

Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #5 on: May 27, 2007, 03:01:15 AM »

Can somebody recommend a good book on 3D graphics in general, and OpenGL in particular?

my current university and the one i attended previously both used "the angelbook": edward angel, "interactive computer graphics: a top-down approach using opengl" (2006 ed). personally i hate it (full of little errors and sometimes greviously misleading), as did many people at my previous university, but most people seem to like it and it's pretty widely used so... you can have a look at that.

what i really wanted to say though: if you follow a well-trodden path your programs will look just like everyone else's; mutatorkammer is already doing almost exactly what you've described in your post. just about everyone codes a little heightmap viewer in introductory graphics courses (i've just had to code one for my silly graphics course), and i wouldn't be surprised if some people used fractals to define the height values - they all look the same and do the same thing sad there's code aaaaaaaaaaaaaaall over the net for rendering heightmaps, it's been done to death.

lycium,

I've seen a fair amount of basic heightmap rendering of Mandelbrot and Julia sets, but I haven't seen very many images that I think are really striking. I also haven't seen any good 3D animations. Have you? if you have, can you point me to some?

I'm envisioning animations where the point of view flies around and into a fractal plot, like a first person view from an airplane, and zooms down into more detailed areas. I want to generate plots that have shadows from a soft directional light source, and pleasing colors.



Duncan C.
Logged

Regards,

Duncan C
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #6 on: May 27, 2007, 03:10:59 AM »

I've seen a fair amount of basic heightmap rendering of Mandelbrot and Julia sets, but I haven't seen very many images that I think are really striking.

since you bring it to a point, neither have i, and i don't really think it's possible. maybe it's just me, but a far more interesting "classic" are quaternionic julia sets: http://local.wasp.uwa.edu.au/~pbourke/fractals/quatjulia/

i've only gotten around to rendering them in my new framework recently, this (very unfinished) render is from last night: http://www.fractographer.com/wip/unfinished.jpg

I also haven't seen any good 3D animations. Have you? if you have, can you point me to some?

actually i'm just busy working on one, hope it'll be finished before the year is out. it's taking forever because it's all being done with my own code, even down to the music to which it'll be synchronised and all the previewing/keyframing software, besides which rendering 1920x1080 (hd) resolution frames at 25fps will take a while.

I'm envisioning animations where the point of view flies around and into a fractal plot, like a first person view from an airplane, and zooms down into more detailed areas. I want to generate plots that have shadows from a soft directional light source, and pleasing colors.

you can forget about the gpu entirely then wink it's very difficult to coax a non-standard, soft "look" out of a gpu, that mostly requires a LOT of expert shader work. i know some geniuses who are only now finding this really possible after really a lifetime of prior work... of course being a ray tracing freak i'm biased, but you can only fart against thunder so long before you notice the difficulty in doing so!

opengl/d3d is exceptionally easy to learn if you know what functionality you want/need, it's doing something truly exceptional with it that's damn hard.
Logged

Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #7 on: May 29, 2007, 01:14:14 AM »

I've seen a fair amount of basic heightmap rendering of Mandelbrot and Julia sets, but I haven't seen very many images that I think are really striking.

since you bring it to a point, neither have i, and i don't really think it's possible. maybe it's just me, but a far more interesting "classic" are quaternionic julia sets: http://local.wasp.uwa.edu.au/~pbourke/fractals/quatjulia/

i've only gotten around to rendering them in my new framework recently, this (very unfinished) render is from last night: http://www.fractographer.com/wip/unfinished.jpg

You've made your opinions on the subject quite clear. You find standard quadratic Mandelbrot and Julia sets to be boring, and done "to death." Message received, loud and clear. We'll just have to agree to disagree.


I also haven't seen any good 3D animations. Have you? if you have, can you point me to some?

actually i'm just busy working on one, hope it'll be finished before the year is out. it's taking forever because it's all being done with my own code, even down to the music to which it'll be synchronised and all the previewing/keyframing software, besides which rendering 1920x1080 (hd) resolution frames at 25fps will take a while.

I'm envisioning animations where the point of view flies around and into a fractal plot, like a first person view from an airplane, and zooms down into more detailed areas. I want to generate plots that have shadows from a soft directional light source, and pleasing colors.

you can forget about the gpu entirely then wink it's very difficult to coax a non-standard, soft "look" out of a gpu, that mostly requires a LOT of expert shader work. i know some geniuses who are only now finding this really possible after really a lifetime of prior work... of course being a ray tracing freak i'm biased, but you can only fart against thunder so long before you notice the difficulty in doing so!

opengl/d3d is exceptionally easy to learn if you know what functionality you want/need, it's doing something truly exceptional with it that's damn hard.

Could you use ray tracing to create a large light source from a grid of point light sources, like the pattern of holes in a circular drain? Wouldn't that give you much the same effect as a large diffuse light-source? A "center weighted" random scattering of point light sources might give better results, since it would avoid odd grid patterns in the highlights on the 3D subject. I've never coded a ray tracing algorithm myself, so I'm only speculating, and borrowing from my knowledge of photography.


Duncan C
Logged

Regards,

Duncan C
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #8 on: May 29, 2007, 01:22:13 AM »

You've made your opinions on the subject quite clear. You find standard quadratic Mandelbrot and Julia sets to be boring, and done "to death."

only in the complex numbers; quaternionic (quadratic) julia sets never cease to amaze me...

Could you use ray tracing to create a large light source from a grid of point light sources, like the pattern of holes in a circular drain? Wouldn't that give you much the same effect as a large diffuse light-source? A "center weighted" random scattering of point light sources might give better results, since it would avoid odd grid patterns in the highlights on the 3D subject. I've never coded a ray tracing algorithm myself, so I'm only speculating, and borrowing from my knowledge of photography.

that is in fact the basis for approximating illumination due to area lights, yes. you can either keep a fixed set of point lights, or choose them randomly (with careful attention to probabilities etc), but in the end you just need sufficiently many representative points; this is especially true with a fixed set because otherwise you'll see numerous distinct, hard-edged shadows.

i'm using this technique to convert a HDR background image "at infinity" into a set of directional lights: http://gl.ict.usc.edu/research/MedianCut/ (i used 1500 or so for my latest 3d fractal on deviantart: http://www.deviantart.com/deviation/55515150/)
Logged

Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #9 on: May 30, 2007, 02:24:30 AM »

Could you use ray tracing to create a large light source from a grid of point light sources, like the pattern of holes in a circular drain? Wouldn't that give you much the same effect as a large diffuse light-source? A "center weighted" random scattering of point light sources might give better results, since it would avoid odd grid patterns in the highlights on the 3D subject. I've never coded a ray tracing algorithm myself, so I'm only speculating, and borrowing from my knowledge of photography.

that is in fact the basis for approximating illumination due to area lights, yes. you can either keep a fixed set of point lights, or choose them randomly (with careful attention to probabilities etc), but in the end you just need sufficiently many representative points; this is especially true with a fixed set because otherwise you'll see numerous distinct, hard-edged shadows.

i'm using this technique to convert a HDR background image "at infinity" into a set of directional lights: http://gl.ict.usc.edu/research/MedianCut/ (i used 1500 or so for my latest 3d fractal on deviantart: http://www.deviantart.com/deviation/55515150/)

lycium,

What do you mean by a background "at infinity?" Is it an infinite distance away? Doesn't that make the lightsource effectively a point source again? The sun, for example, is really huge, but since it is so far away, it's nearly a point source.


Duncan C

 
Logged

Regards,

Duncan C
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #10 on: May 30, 2007, 05:42:56 AM »

nope, it makes it directional: an infinitely far away point light source is a directional light source.
Logged

lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #11 on: May 30, 2007, 05:49:06 AM »

ah i see where the confusion is coming from; even infinitely far away surfaces can subtend angles, they don't necessarily have to be "point" functions (described by the dirac delta function). some links:

http://en.wikipedia.org/wiki/Steradian
http://en.wikipedia.org/wiki/Dirac_delta_function (in this case the directional light source is emitted_radiance * delta(w - w0) where w0 is the light's direction)
Logged

Duncan C
Fractal Fanatic
****
Posts: 348



WWW
« Reply #12 on: November 11, 2007, 05:15:33 AM »


you can forget about the gpu entirely then wink it's very difficult to coax a non-standard, soft "look" out of a gpu, that mostly requires a LOT of expert shader work. i know some geniuses who are only now finding this really possible after really a lifetime of prior work... of course being a ray tracing freak i'm biased, but you can only fart against thunder so long before you notice the difficulty in doing so!

opengl/d3d is exceptionally easy to learn if you know what functionality you want/need, it's doing something truly exceptional with it that's damn hard.


lycium,

I'm getting back to this after a long interruption. I've bought the "OpenGL SUPERBIBLE", and am reading up on OpenGL. It seems to support three types of lighting: Ambient (non-directional), diffuse (soft directional) and specular (hard-edged directional). That's exactly what I want. That combination should give me a nice effect of a slightly glossy-looking surface, with soft-edged shadows that still have detail in them.

Why do you say that a "soft" look is hard to get out of a GPU? It sounds like the diffuse light source supported by OpenGL is what I need.


Duncan C
Logged

Regards,

Duncan C
lycium
Fractal Supremo
*****
Posts: 1158



WWW
« Reply #13 on: November 11, 2007, 08:04:10 AM »

I've bought the "OpenGL SUPERBIBLE", and am reading up on OpenGL.

hmm i've seen that for download in a number of places (4th edition), not from p2p so i'm guessing it's legal... a google search will find it.

It seems to support three types of lighting: Ambient (non-directional), diffuse (soft directional) and specular (hard-edged directional). That's exactly what I want. That combination should give me a nice effect of a slightly glossy-looking surface, with soft-edged shadows that still have detail in them.
those are components of the standard (blinn-)phong local illumination model. more info:

http://en.wikipedia.org/wiki/Phong_reflection_model
http://www.delphi3d.net/articles/viewarticle.php?article=phong.htm


Why do you say that a "soft" look is hard to get out of a GPU? It sounds like the diffuse light source supported by OpenGL is what I need.

i should better qualify what i mean by "soft".

usually gpus only render with what's known as local illumination, that's light paths that go from the light source to the eye via exactly one surface interaction; so if you're sitting in your room during the day, it'd be rendered pitch black unless the sunlight is directly entering through a window, and even then you'd have a pretty hard edged shadow, the illuminated area would be nuked out and everything else would be pitch black.

global illumination deals with all possible light interactions, and is considerably more complex (of course, it results in much more realistic renderings). if i may use my latest render from deviantart to illustrate the kind of soft lighting this facilitates, together with a spectral colour (wavelength-based, no rgb) system:


(the higher quality, 1920x1200 wallpaper render is at http://lyc.deviantart.com/art/cipater-68019331)

in that render i only used diffuse reflection, however i've since implemented the phong model (an energy-conserving variant) to render glossy metals. the surfaces in this non-fractal test render use measured reflectance information (complex refractive indices) for aluminium:




in summary, what i'm saying is that it's difficult to avoid the synthetic/plastic look in classical rasterising (gpu) rendering.
Logged

this is not kasker
Guest
« Reply #14 on: November 11, 2007, 06:38:19 PM »

You could always use a 3d package like Blender to render 3D if you don't want to do all the programming. I like to use vray with 3ds max, it's easy to get realistic effects.

lycium I sent you a pm
Logged
Pages: [1] 2   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Sample colour Maps for M3D (page 2) Mandelbulb 3d « 1 2 » kameelian 29 4456 Last post September 23, 2011, 08:31:05 PM
by DarkBeam
Obtaining the Souce Code for Fractal Explorer? Fractal Explorer fractalatha 0 922 Last post August 10, 2011, 06:27:12 PM
by fractalatha
Julimandel sample from Lenord Mandelbulb3D Gallery DarkBeam 0 396 Last post September 21, 2011, 06:47:16 PM
by DarkBeam
Fractal Building Code + Volume 4 Movies Showcase (Rate My Movie) Brummbaer 1 598 Last post May 16, 2013, 06:20:55 PM
by Dinkydau
Smooth Shaded plugin Plugins kallisti 2 852 Last post December 14, 2013, 11:17:17 AM
by kallisti

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.282 seconds with 27 queries. (Pretty URLs adds 0.02s, 2q)