|
|
Hello,
I would like to build an image of a crystal made of a lot of atoms
and chemical bonds. I wrote a following source file, but it is very
heavy and sometimes causes shortage of memory. Also, it is very slow.
Please change the Lattice_Constant value in the source file from 0.5
to 0.01 to check what happens.
(Since my final goal is to build an animation, faster rendering is
better.)
I also tried an isosurface with a function like:
function{ 0.3 - pow(cos(x/Lattice_Constant*pi),2)
* pow(cos(y/Lattice_Constant*pi),2)
* pow(cos(z/Lattice_Constant*pi),2) }
but the result image is something wrong.
I imagine there should be cleverer way to do this. Could someone
give hints?
//---------- source code ----------//
camera{ location <0.2,0.7,-1> look_at <0,0,0> }
light_source{ <-200,200,-200> rgb<1,1,1> }
global_settings{ ambient_light rgb 3 }
#declare T_Atom = texture{pigment {rgb<.3, .5, .7>} finish{phong 0.3}}
#declare T_Bond = texture{pigment {rgb<.7, .5, .3>} finish{phong 0.3}}
#declare Lattice_Constant=0.05;
#declare Xmax=3;
#declare Ymax=0;
#declare Zmax=5;
#declare Xmin=-4;
#declare Ymin=-2;
#declare Zmin=0;
// Place atoms at lattice points
#declare X=Xmin; #while(X<=Xmax)
#declare Y=Ymin; #while(Y<=Ymax)
#declare Z=Zmin; #while(Z<=Zmax)
sphere{ <X,Y,Z>, Lattice_Constant*0.3 texture{T_Atom} }
#declare Z=Z+Lattice_Constant; #end
#declare Y=Y+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end
// Place chemical bonds
#declare X=Xmin; #while(X<=Xmax)
#declare Y=Ymin; #while(Y<=Ymax)
cylinder{ <X,Y,Zmin>, <X,Y,Zmax>, Lattice_Constant*0.1 texture{T_Bond} }
#declare Y=Y+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end
#declare X=Xmin; #while(X<=Xmax)
#declare Z=Zmin; #while(Z<=Zmax)
cylinder{ <X,Ymin,Z>, <X,Ymax,Z>, Lattice_Constant*0.1 texture{T_Bond} }
#declare Z=Z+Lattice_Constant; #end
#declare X=X+Lattice_Constant; #end
#declare Z=Zmin; #while(Z<=Zmax)
#declare Y=Ymin; #while(Y<=Ymax)
cylinder{ <Xmin,Y,Z>, <Xmax,Y,Z>, Lattice_Constant*0.1 texture{T_Bond} }
#declare Y=Y+Lattice_Constant; #end
#declare Z=Z+Lattice_Constant; #end
Post a reply to this message
|
|
|
|
Am 08.07.2010 08:27, schrieb Tomohiro:
> Hello,
>
> I would like to build an image of a crystal made of a lot of atoms
> and chemical bonds. I wrote a following source file, but it is very
> heavy and sometimes causes shortage of memory. Also, it is very slow.
> Please change the Lattice_Constant value in the source file from 0.5
> to 0.01 to check what happens.
> (Since my final goal is to build an animation, faster rendering is
> better.)
You might try using a blob object rather than individual spheres and
cylinders. With well-chosen parameters the visual difference will be
very low, and it will enable you to trim down memory consumption
significantly.
For best effect, #declare a blob with, say, 20x20x20 atoms, then place
as many copies of this blob as you need.
Alternatively, you can use a so-called "infinity box", which will allow
you to repeat the scene's contents /ad infinitum/; this way, you'll only
need to model a single "cell" of the lattice, so you'll need even less
memory than the blob approach. There's a sample scene for this approach
(scenes/advanced/infinitybox.pov).
I'm not sure which of these approaches gives better rendering speed though.
Post a reply to this message
|
|
|
|
I tried blob and it was true that it reduced time and memory significantly,
but it was not enough.
Thus I used isosurface's with functions of
0.55 - abs(cos(x/Dist*pi) * cos(y/Dist*pi) * cos(z/Dist*pi)) for atoms
0.89 - abs(cos(y/Dist*pi) * cos(z/Dist*pi)) for bonds
where Dist is the lattice constant, while it is not a true sphere.
Last time I wrote the result was something wrong but I found that
usage of max_gradient value of about 3000 - 5000 will give a
good result. This was faster than usage of blob.
However, even using sufficiently large max_gradient, some small
artifacts remain. The artifacts seem to be related to shadow on
an "atom" or a "bond" from other "atoms" or "bonds".
Post a reply to this message
|
|