D3PLOT 22.1

Ray Tracing a D3PLOT Image

Ray-tracing a D3PLOT image.

The process gone through is:

  • Select the window to be rendered. Only a single model in a single window is handled at present.

  • Select the ultimate image resolution. This will default to the current D3PLOT window size, but other options are available including arbitrary sizes.

  • Define the output image filename which at present is limited to type .png. A name will be provided automatically, but you can over-ride this.

  • Define the intermediate POV-Ray input file, .pov. Again a filename will be provided automatically, but you can over-ride this.

  • Define the "rules" file which is used to assign ray-tracing material properties to each part in the model.

  • Define a "materials library" file containing material property definitions that you wish to use.

Finally use Ray trace to execute the process. This will apply the rules and launch the POV-Ray executable as a separate process to generate the image.

Defaults are provided for all the above so that no intervebtion is required to produce the default image. However once you start using this you will quickly become aware of the need to provide something other than the default ray-tracing material properties in order to obtain good results.

(The Preview button is an idea that has not come to fruition in D3PLOT 15.0, so it just prints a message stating this. The aim in future releases is to give a "fast but crude" preview of what the final image will look like using conventional D3PLOT rendering.)

Setting up the "visual universe": lights, camera position, etc

POV-Ray has the concept of a "universe" in which the model exists, defined as a coordinate system somewhere in space. The model to be rendered is specified in that coordinate system, and the camera (eye position, and where it is pointing) and lights are all defined in that system.

Fortunately D3PLOT has a more or less identical concept, and this is translated automatically for you into POV-Ray definitions. So as long as you are happy to replicate the D3PLOT view and lighting setup exactly you do not need to take any action as it "just happens".

However you may find that the differences between D3PLOT and POV-Ray lighting, and in particular the fact that in D3PLOT light rays can shine through opaque objects whereas in POV-Ray they cannot, can result in the "inside" of models looking rather dark. The crude solution to this is to increase the ambient light level, but too much of this "washes out" the scene, and a better solution may be to put a local light source inside the object to illuminate its contents.

Ray-tracing material properties

Within D3PLOT you have the following "material rendering properties"

D3PLOT simplistic material rendering properties
Colour A Red, Green, Blue (RGB) mixture, each 0 - 100%
Transparency

From 0% (opaque) to 100% (clear)

Diffuse Brightness From 0% (dark) to 100% (full)
Specular Shininess From 0% (dull) to 100% (very shiny)

You have no control over the "surface texture" of materials, which appear to be somewhere between dull plastic (low shininess) and metallic (high shininess).

However within a ray-tracer there is a much more sophisticated model. Colour and transparency are much the same, but surface properties are much more complex:

POV_Ray material rendering properties (or at least some of them)
Colour and transparency

Defined by a " pigment ", typically

pigment { color rgb <r.r, g.g, b.b> }
pigment { color rgbt <r.r, g.g, b,b. t.t> }

Where:

  • r.r, g.g, b.b are RGB colour values in the range 0.0 (dark) to 1.0 (full brightness)
  • t.t is transparency in the range 0.0 (clear) to 1.0 (opaque)
Brightness and shininess

Defined as components of a " finish ", typically

finish { ambient a.a diffuse d.d phong p.p }

Where:

  • ambient a.a is the material's response to ambient light in the range 0.0 (dark) to 1.0 (full brightness)
  • diffuse d.d is the material's response to direct light in the same range
  • phong p.p is the material's "shininess" in response to direct light, in the same range

The "phong" value is approximately the same as D3PLO|T''s "shininess" value, but D3PLOT uses a simplistic model which combines both "specular brightness" (reflection of white light) and "shininess" (how concentrated those white highlights are).

It is also possible to define "specular" values to control the concentration of white highlights.

Roughness

Part of a finish , typically:

finish { other attributes roughness r.r }

Roughness in POV-Ray approximates appearance on the scale 0.0 (shiny) to 1.0 (matt)

Reflection

Part of a finish , typically:

finish { other attributes reflection { r.r }}

Reflection ranges from 0.0 (no reflections) to 1.0 (reflects all incoming rays). Clearly high reflection means that the intrinsic colour of the item is not that significant, so high reflections should be used with low diffuse brightnesses.

Metallic

Part of a finish , typically:

finish { other attributes metallic}

This keyword uses an empirical algorithm to make surfaces look "more metallic".

... and there are plenty more attributes, but the above are the most common and - more importantly - the most easily understood.

POV-Ray then assembles this pigment and finish into a " texture ", for example:

texture { pigment { color rgb < 0.2, 0.3, 0.4> } finish < ambient 0.2 diffuse 0.5 roughness 0.3 reflection 0.1 } }

and it this texture which determines how the object is rendered.

The POV-Ray #declare syntax, and associated conventions.

POV-Ray definitions can be quite verbose, so it has a #declare syntax to help with this, for example:

#declare P_Black_steel = color rgb <0.0, 0.0, 0.0>

Which creates simplified definitions of otherwise verbose definitions. For example after the #declare definition above you can use P_Black_Steel as shorthand for the full pigment definition.

The following naming conventions have been adopted by the POV-Ray community, and it is recommended that you comply with them:

#declare prefix meaning
P_xxx "pigment" definition
F_xxx "finish" definition
T_xxx "texture" definition

We have adopted these conventions in our standard material library file, see below.

So how do we create and assign textures to D3PLOT objects?

Assigning ray-tracing material properties using the "rules" and "matlib" files.

Ray-tracing properties are assigned on a per-part basis (it is not currently possible to assign properties to individual elements) and this is done using a pair of files


The "material library" file: rt_matlib.txt

A default version of this file is provided in $OA_INSTALL/common_library/rt_matlib.txt , and D3PLOT is preconfigured to find it there. It contains two things:

  • "#include" statements to include standard POV-Ray include files that are provided as part of the standard installation.
  • Some very simple material definitions

Examples of typical definitions within the file are

// Steel textures

#declare T_Black_Dull_Steel = texture { pigment { P_Black_Steel } finish { F_MetalA } }
#declare T_Black_Med_Steel = texture { pigment { P_Black_Steel } finish { F_MetalC } }
#declare T_Black_Shiny_Steel = texture { pigment { P_Black_Steel } finish { F_MetalE } }

#declare T_Light_Dull_Steel = texture { pigment { P_Light_Steel } finish { F_MetalA } }
#declare T_Light_Med_Steel = texture { pigment { P_Light_Steel } finish { F_MetalC } }
#declare T_Light_Shiny_Steel = texture { pigment { P_Light_Steel } finish { F_MetalE } }

Here is a simple example demonstrating how two of these textures might be used to replace intrinsic D3PLOT properties:


Original D3PLOT image, showing that the two end platens
have received metallic properties for ray-tracing


Ray-traced image. The far platen is highly reflective polished
steel reflecting the crush tube, the near platen is dull.

There are some other simple texture definitions in that file, and you could also explore the various include files (eg "metals.inc") that come with the POV-Ray install bundle. On a Windows machine these will be installed in

%USERPROFILE%\Documents\POV-Ray\v3.7\include

Where %USERPROFILE% is typically C:\users\ your_name , although on a large corporate system with roaming profiles it may be on a network disk, for example H:\users\ your_name. (To find the valueof environment variables on Windows open an MS-DOS (command) window and type "set".)

If you are at all ambitious about creating your own textures it is recommended that you copy that file to your own directory, add your own definitions and make this the current "rt_matlib" file for your own experimentation. You can do this by two methods:

  1. Use the file selector to navigate to your private file and select it, making it current in the panel. Then use Save settings to oa_pref file to save this as a preference.

  2. Set the preference d3plot*povray_matlib_file: full_path_and_filename directly.

The "rules" file: rt_rules.txt

This file gives a simple text-based method of assigning POV-Ray textures to parts in your model. A placeholder file containing its syntax and rules is provided in $OA_INSTALL/common_library/rt_rules.txt , and D3PLOT is pre-configured to look for it there, however that file does not contain any actual definitions, rather it is intended to be copied to a local area where you can set up your own rules. You can do this by two methods:

  1. Use the file selector to navigate to your private file and select it, making it current in the panel. Then use Save settings to oa_pref file to save this as a preference.

  2. Set the preference d3plot*povray_rules_file: full_path_and_filename directly.
Rules file syntax:
  • Lines starting $, % or $ are treated as comments and are ignored

  • Blank lines are ignored

  • Data-bearing lines have the general form:

    Keywordarguments= definition

  • Lines are processed in the order encountered, so if an earlier line is superseded by a later definition then that later definition "wins" and becomes current.

  • Each line is free format, and keywords are not case-sensitive. However properties using #define should use the correct case.

  • Where an entry is a single word it can be written verbatim, but if it contains white space it must be enclosed in "...". For example "rigid steel".

The purpose of this file is to assign POV-Ray textures to PARTs and MATerials in your model. Some lines define properties for PARTs directly, others refer to MATerials. In the case of MATerials these definitions propagate down to the constituent parts. You can think of it as working like this:

When a property is defined for a material:

For (each part of material)
{
Apply the property to this part
}

For anything other than Part names and labels in the table below to be parsed D3PLOT must have read a .ZTF file from PRIMER, since this contains the extra information (eg materials) that is not present in the normal d3plot / ptf file.

The following table describes the syntax in more detail. Entries in (...) are optional

Keyword Syntax Meaning
default default = definition

All parts in the model get this definition. (See Rules for definition below)

Example default = T_Black_Dull_Steel
part part label_1 (to label_2) = definition

The part of label_1, or if label_2 is defined then all parts in the range label_1 to label_2, get this definition.

Example part 1 = T_Glass_Clear
part 2 to 20 = T_Light_Med_Steel
matl matl label_1 (to label_2) = definition

The material label_1, or if label_2 is defined all materials label_1 to label_2 get this definition. This is propagated to all parts using these materials.

Example matl 1 = T_Glass_Clear
matl 2 to 20 = T_Light_Med_Steel
part_name part_name string_to_match = definition

Assigns definition to all parts whose title matches string_to_match

Example part_name rigid = T_Dark_Shiny_Steel
part_name "moving & ductile" = T_Light_Shiny_Steel

See the rules for string_to_match syntax below.

matl_name matl_name string_to_match = definition

Assigns definition to all materials whose title matches string_to_match. This is propagated to all parts using these materials.

Example matl_name rigid = T_Dark_Shiny_Steel
matl_name "moving & ductile" = T_Light_Shiny_Steel

See the rules for string_to_match syntax below.

matl_type matl_type ls_dyna *MAT name = definition

Assigns definition to all materials using the Ansys LS-DYNA *MAT type name given. This is propagated to all parts using these materials.

Example matl_type *MAT_RIGID = T_Dark_Shiny_Steel
matl_name ELASTIC = T_Light_Shiny_Steel

The Ansys LS-DYNA material name may use any of the following syntax:

*MAT_ name
MAT_ name
name
eg *MAT_RIGID
eg MAT_RIGID
eg RIGID

The name matching is not case-sensitive, for example *MAT_RIGID and *mat_rigid will both work.

property

property type lo hi = definition

Where type is one of

DENSITY Material density
YM Young's modulus
NU Poisson's ratio
YIELD Yield stress
FSTRN Failure strain

Assigns definition to all materials for which property type has the valuelo<=value<= hi. This is propagated to all parts using these materials.

Example property density 7.5e3 8.0e3 = T_Dark_Shiny_Steel
property nu 0.45 0.5 = T_Rubber

The lo .. hi values must be given in the correct order, and (obviously!) they must be in the right units. For example density in the example above is correct for steel in SI units of kg/m3.

Rules for string_to_match

String matching is not case-sensitive, and the test is "does this string match all or part of the part/material name?" A string_to_match may take any of the following forms:

A single word eg steel

Multiple words separated by white space, which must be in "...", forming a string..

These must match exactly, including the number of white spaces. For example string "rigid steel" is not the same as "rigid steel".

eg "rigid steel"

Multiple words or strings separated by the logical operators:

& Logical "and"
| Logical "or"
! Logical "not"

For example

rigid & steel is true only if a name contains both words "rigid" and "steel"
rigid | steel is true if a name contains either (or both) of "rigid" and "steel"
rigid & !steel is true only if a name contains "rigid" but does not also contain "steel"

Expressions may also be put in (...) for example

(rigid & moving) | (elastic & stationary) will be true if a name contains both "rigid" and "moving", or if it contains "elastic" and "stationary". Brackets may be nested up to 20 deep, although if you are writing expressions that complicated you need to have a re-think!

eg

rigid & steel

(rigid & moving) | (elastic & stationary)

Rules for definition

Recall that POV-Ray definitions are textures , that comprise a pigment plus a finish . The "definition" in the table above must be one of the following:

A texture

This will be used verbatim, and all the internal properties in D3PLOT will be ignored.

For example:

T_Clear_Glass
texture { pigment {color rgb <0.7, 0.55, 0.3> } finish {ambient 0.2 diffuse 0.6 phong 0.4 } }

A pigment

This will replace the colour used in D3PLOT, but the current transparency, diffuse brightness and shininess will be merged with it to produce a texture that is a combination of externally supplied pigment colour and internal D3PLOT properties.

For example:

P_Darkish_Brown
pigment { color rgb < 0.3, 0.4, 0.5 > }

A finish

The colour and transparency in D3PLOT will be used verbatim, but the lighting properties will be replaced by this externally defined finish.

For example:

F_MetalA
finish { ambient diffuse 0.4 roughness 0.2 reflection 0.1 }

Suggested initial procedure

There is a lot to take in here, especially if you have no prior experience of computer graphics or ray-tracing. Experience suggests that the best way to proceed is as follows:

  • Find a small model (ideally a few 100 elements at most), but one which has a reasonable variety of shapes with some curvature as it is hard to learn much from flat planes, and use that as a test-bed. The .pov files are verbose, and a small model will be much faster to work with.

  • Copy the rt_rules.txt and rt_matlib.txt files from $OA_INSTALL/common_library to your local directory, and make these the current rules and material library files as seen by the ray-tracing panel. Then you can modify them at will without upsetting anyone else.

  • Generate a .pov file using D3PLOT's default settings. This should produce an image, but what you actually want is the intermediate .pov file, as by editing that you can see almost instantly what the effects of changes will be.

  • Run POV-Ray manually and open this .pov file in its editor so that you can inspect its contents, then try editing and rendering the effects of your changes.

Once you get a feel for what changes you want to make try adding your modified textures to the rt_matlib.txt file, and then writing some simple rules in the rt_rules.txt file to apply them to your model, then use these to get D3PLOT to recreate a modified file for rendering. Only then try moving on to a full scale model.