Tutorial 3: Rendering effects
Visualize makes several rendering effects available for when it is necessary to create an image of very high visual quality. In this tutorial, we'll use a model of a turbine engine to demonstrate reflection planes, two types of shadowing, and bloom. This tutorial will make use of the Sandbox application. For C++ users, the mfc_sandbox project is where you'll want to start from. CHPSView::OnUserCodeX function is where you'll want to place your code if you'd like to follow along with this tutorial. C# users will use the wpf_sandbox application - you'll place the code in DemoUserCommandX::Execute.
The first step after building and running the sandbox is to load the turbine model file. That file can be found in the samples/data directory in your Visualize installation. This is an HSF file, so it can be loaded natively by Visualize. Load it into the sandbox using the sandbox's main menu. Alternatively, you can programmatically load the file using the following code snippet:
You'll also want to get a reference to the model's segment key. If you loaded the file programmatically, you should have provided one to the HPS::ImportOptionsKit. If you loaded the model using the sandbox application's file menu, you can get the model segment as follows:
More on loading HSFs can be found in section 9.1 of the Programming Guide. After loading is complete, you should see the following image:
A fancy effect you can apply with relative ease is a reflection plane. Planes are specified in SetSimpleReflectionPlane (see snippet t.3.1.c) using the geometric equation of a plane:
Additional options for the reflected image are also available - such as opacity, blurring, fading, and attenuation. Place the following code into one of the UserCode or DemoUserCommand methods to activate it after the model is loaded.
After rotating the model using the orbit operator (its in the ribbon control of the application), the resulting image should look like the one below:
As with all extra rendering effects, additional processing time is required to achieve the resulting image. Always keep in mind the balance between rendering quality and performance.
In this section, we'll apply a drop shadow as well as shadow maps to the turbine model. Since a drop shadow doesn't normally look good with a reflection plane, we'll disable it to focus on shadows. The first type of shadowing we'll enable is shadow maps. Shadow maps allow the faces of geometry to cast a shadow over any type of geometry that is affected by a light. The first step is to enable shadowing in the segment, then we'll set the shadow map parameters:
Next, we'll enable drop shadows. Drop shadows are called simple shadows in Visualize because the effect is highly constrained. First, the simple shadow can only be cast on a flat plane. Secondly, the shadow can only be generated from a single light source. For most engineering applications, however, the simple shadow creates an adequate effect.
Another effect that can improve the visual quality of a rendering is bloom. Bloom occurs when an intensely bright light reflects off of a shiny surface. The light appears to bleed out into the surrounding air. Bloom is only available in the shader-based drivers such as DirectX11 and OpenGL2. Bloom is enabled using the HPS::PostProcessEffectsKit.
For the highest amount of visual quality, you'll also want to add textures. Applying textures to a model as complex as the turbine is beyond the scope of this tutorial, but an image is provided to demonstrate it. You can find the textured model in the samples/data directory in your Visualize installation. More information on textures can be found in section 5.3 of the programming guide and in Tutorial 2: Applying materials.