This page is about more advanced coding using the Directx rendering pipeline through NETLink. The more basic examples can be found here:NETLink and Directx
Two pass shader
This example demonstrates Specular Bump Mapping.
It uses new functions from NetLink to convert data types.
the result, our earth displaying with texture and bumps ,, looks like this:
you can download the notebook:SpecularBumpMap5.2.nb.
The notebook also requires the following files specularBumpVertexPixelShader.fx,VertexBufferUtils.dll
Animated Vertex shader
This example demonstrates how the vertex shader can manipulate points and normals .
the result, is a dodecahedron that transform into a sphere and relaxes to a more compressed state:
you can download the notebook:AnimatedVertex.nb.
The notebook also requires the following files SimpleVertexShader.fx,VertexBufferUtils.dll
Multiple Instances shader
This example demonstrates how the code and the vertex shader can instances several copies of the same object.
the result, is the dodecahedron is transformed 3 times. One time animated and the other 2 not animated but moving:
you can download the notebook:MultipleInstances.nb.
The notebook also requires the following files MultipleInstancesShader.fx,VertexBufferUtils.dll
Reflection (Environment) Mapping
This example demonstrates how the code and the vertex shader can create the reflection of the environment on an object (a sphere in this case).
the result, is the colorfull room reflecting on a metallic sphere.
you can download the notebook:Sphere_reflection_sample.nb.
The notebook also requires the following files Directx_Reflection_Mapping.zip.
User interface under DirectX
This example demonstrates how Mathematica and DirectX can manage events and create a simple user interface.
Display text on the image.
enable the mouse to move the image. Left, right buttons and mousewheel.
Keyboard events select one of 3 objects.
This code has also been updated to use a better management of lost devices and reset devices. This means the image will come back after your favorite screen saver takes releases the screen.
the result, is the colorfull room reflecting on a metallic sphere, cube or dodecahedron.
you can download the notebook:User_Interface.nb.
The notebook also requires the following files UserInterface.zip.
Hardware Shadows under DirectX
This example demonstrates how Mathematica and DirectX can generate and display shadows in a 3D scene using the hardware. (You need a capable graphic card. A future example will not require such a card)
Display 3 objects rotating.
A light projecting shadows under the objects.
a decal on the light projecting a bitmap (the Mathematica-users logo).
the result, is the colorfull room reflecting on a metallic sphere, cube or dodecahedron.
you can download the notebook:Shadows.nb.
The notebook also requires the following files Shadows.zip.
Enjoy,
Luc