<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=Producing_sexy_ray-traced_images</id>
	<title>Producing sexy ray-traced images - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?action=history&amp;feed=atom&amp;title=Producing_sexy_ray-traced_images"/>
	<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Producing_sexy_ray-traced_images&amp;action=history"/>
	<updated>2026-04-13T13:53:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.7</generator>
	<entry>
		<id>https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Producing_sexy_ray-traced_images&amp;diff=1260&amp;oldid=prev</id>
		<title>Adk44: Created page with &quot;Pardon the title but you&#039;ll understand when you see the results!  === Before you ray trace === Before you start playing with ray tracing, you need to be sure that you&#039;re happy...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wikis.ch.cam.ac.uk/ro-walesdocs/wiki/index.php?title=Producing_sexy_ray-traced_images&amp;diff=1260&amp;oldid=prev"/>
		<updated>2019-05-13T10:56:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Pardon the title but you&amp;#039;ll understand when you see the results!  === Before you ray trace === Before you start playing with ray tracing, you need to be sure that you&amp;#039;re happy...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Pardon the title but you&amp;#039;ll understand when you see the results!&lt;br /&gt;
&lt;br /&gt;
=== Before you ray trace ===&lt;br /&gt;
Before you start playing with ray tracing, you need to be sure that you&amp;#039;re happy with the way your system is represented. There are LOADS of options in Pymol to change how things appear, and most of them are not available in the GUI. For a complete list, go to &amp;#039;&amp;#039;&amp;#039;Settings&amp;gt;Edit All&amp;#039;&amp;#039;&amp;#039; and have a play around!&lt;br /&gt;
&lt;br /&gt;
So, you&amp;#039;ve got a PDB, loaded it into Pymol and arranged it so that it looks how you&amp;#039;d like - some bits as a cartoon, some as sticks etc. How do you go about making an image that you can then use for a poster, or a paper, or a CPGS/thesis? The answer lies in ray tracing. To get Pymol to actually produce a ray traced image is remarkably easy, just type&lt;br /&gt;
&lt;br /&gt;
[[Image:Ray1.png|thumb|Met-enk before ray tracing|200px|right]]&lt;br /&gt;
[[Image:Ray2.png|thumb|Met-enk after ray tracing with default settings|200px|right]]&lt;br /&gt;
&lt;br /&gt;
 ray&lt;br /&gt;
&lt;br /&gt;
in either the viewing window, or the GUI and press enter. After a few seconds (progress is indicated by a bar at the top of the viewing window), you will see the image suddenly change! You could now save this image using&lt;br /&gt;
&lt;br /&gt;
 png raytraced.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
BUT you&amp;#039;d quickly find that &lt;br /&gt;
* the image quality isn&amp;#039;t up to much and so you can&amp;#039;t use it in a publication&lt;br /&gt;
* it&amp;#039;s too small to be used on a poster&lt;br /&gt;
* a black background is NEVER a good idea for images you might print for obvious reasons&lt;br /&gt;
&lt;br /&gt;
To resolve these issues, I will now go through the key settings you should ALWAYS have set, &lt;br /&gt;
&lt;br /&gt;
=== Recommended settings ===&lt;br /&gt;
&lt;br /&gt;
[[Image:Ray3.png|thumb|Met-enk after ray tracing with the recommended settings and using mode 0|200px|right]]&lt;br /&gt;
[[Image:Ray4.png|thumb|Met-enk after ray tracing with the recommended settings and using mode 1|200px|right]]&lt;br /&gt;
[[Image:Ray5.png|thumb|Met-enk after ray tracing with the recommended settings and using mode 2|200px|right]]&lt;br /&gt;
[[Image:Ray6.png|thumb|Met-enk after ray tracing with the recommended settings and using mode 3|200px|right]]&lt;br /&gt;
&lt;br /&gt;
 set ray_trace_fog,0&lt;br /&gt;
 set ray_shadows,0&lt;br /&gt;
 unset depth_cue&lt;br /&gt;
 bg_color white&lt;br /&gt;
 set antialias,2&lt;br /&gt;
 set hash_max, 300&lt;br /&gt;
&lt;br /&gt;
You may actually want to have shadows in your image, but for anything larger than a small peptide, it can become very distracting. If you type &amp;#039;&amp;#039;ray&amp;#039;&amp;#039; again now, you can already see the improvement. &amp;#039;hash_max&amp;#039; is very important as it defines the maximum amount of memory Pymol can use while ray tracing and defaults to a wimpy 100mb. Setting it to 300 seems to be around the point where further increases give no return. Make sure you have enough RAM though! But...there is more to come! Pymol supports a selection of ray tracing modes, four in fact. Which one you choose to use depends largely on which effect you require. Modes are selected with the command:&lt;br /&gt;
&lt;br /&gt;
 set ray_trace_mode,  X&lt;br /&gt;
 &lt;br /&gt;
where X is 0,1,2 or 3. 0 is the default, 1 puts a black outline around the molecule, 2 gives you a black and white &amp;#039;sketch&amp;#039; and 3 gives you a funky cartoon like image, with quantised colouring! All four are demonstrated in the images here. My personal favourite is mode 3 although you should bear in mind that it might not look as good when printed. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;NOTE: if the outline of your image appears white, you can fix this using the following:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 set ray_trace_color, black&lt;br /&gt;
&lt;br /&gt;
If you&amp;#039;re using the image in a composite, or presentation you might want a transparent background. You can set this using:&lt;br /&gt;
&lt;br /&gt;
 set ray_opaque_background, off&lt;br /&gt;
&lt;br /&gt;
=== Ray tracing surfaces ===&lt;br /&gt;
&lt;br /&gt;
Ray tracing surfaces requires some additional thought. Mode 3 doesn&amp;#039;t work so well, and you also can have problems with specular reflections giving &amp;#039;hot spots&amp;#039; on the surface. I recommend the following settings for surfaces:&lt;br /&gt;
&lt;br /&gt;
 set surface_quality, 2&lt;br /&gt;
 set light_count, 0&lt;br /&gt;
&lt;br /&gt;
=== Making images for publication ===&lt;br /&gt;
&lt;br /&gt;
Once you&amp;#039;ve chosen your ray tracing options, you&amp;#039;re ready to produce the final image. As you&amp;#039;ll likely want it to be publication quality, I recommended using the following&lt;br /&gt;
&lt;br /&gt;
 ray 2000,1500&lt;br /&gt;
 png raytraced.png, dpi=300&lt;br /&gt;
&lt;br /&gt;
[[Image:Ray7.png|thumb|Met-enk after ray tracing with publication quality settings using mode 3|200px|right]]&lt;br /&gt;
&lt;br /&gt;
These settings can of course be changed. You might find that you need to change the resolution if you have a wide-screen monitor (2000x1500 is for  4:3 aspect ratio monitors) as you might end up inadvertently chopping bits off the image. If in doubt, you can always just use the resolution your desktop is set to.  PyMOL&amp;#039;s &amp;quot;ray X, Y&amp;quot; command means that a ray-traced image of size X-by-Y dots will be produced. So if you want a 300 dpi, 10&amp;quot; x 6&amp;quot; image, then you&amp;#039;d do &amp;quot;ray 3000,1800&amp;quot;. Be warned though - you can max out your system RAM by setting the resolution too high. I&amp;#039;d recommend you &amp;#039;&amp;#039;&amp;#039;always&amp;#039;&amp;#039;&amp;#039; save your session as a .pse file before you ray trace. That way, if you do crash Pymol, you don&amp;#039;t lose anything.&lt;br /&gt;
&lt;br /&gt;
Voila! you are now the proud owner of a rather good looking image! For more info, you should check out the [http://www.pymolwiki.org/index.php/Main_Page Pymol Wiki].&lt;br /&gt;
&lt;br /&gt;
Once you have a pretty png file you may need it in a compressed tiff format for a journal.&lt;br /&gt;
This is easily done via the convert program which is a member of the ImageMagick suite.&lt;br /&gt;
The compression is sometimes necessary.&lt;br /&gt;
&lt;br /&gt;
 convert  -compress lzw  raytraced.png raytraced.tiff&lt;/div&gt;</summary>
		<author><name>Adk44</name></author>
	</entry>
</feed>