Introduction
WPF 3D is a real-time rendering method. To get the highest quality renderings of 3D scenes, it is necessary to use a non real-time method that uses techniques like raytracing or radiosity. This can be done in software like Kerkythea, Luxrender, Maxwell, Indigo, etc. These engines simulate the physics of light to achieve near perfect photorealistic renderings.
This article presents an exporter that converts a WPF 3D model to the XML format used by the Kerkythea render engine.
The source code is also located at Codeplex, and I hope other developers would like to contribute to make the exporter complete.
WPF Rendering
The test model consists of four spheres and a checkerboard (a typical raytracing demo scene). with one spot light and two directional lights.
Raytracing
This is the raytracing output from Kerkythea. I used diffuse materials ("Whitted materials" in Kerkythea) with reflections turned on for both the spheres and the checkerboard.
Metropolis Light Transport
The same model rendered using the metropolis light transport algorithm.
Comparison
Ray tracing - Photon map - Metropolis light transport:
Using the Code
The WPF3D model can be exported from a Viewport3D control by the following code:
KerkytheaExporter exporter = new KerkytheaExporter(file);
exporter.BackgroundColor = Colors.Black;
exporter.Width = 1920;
exporter.Height = 1200;
exporter.Reflections = true;
exporter.Shadows = true;
exporter.SoftShadows = true;
exporter.Export(ViewPort1);
exporter.Close();
This will traverse the scene graph, find all the light sources and use the current camera of the Viewport3D.
Issues
- The
Media3D.ModelUIElement3D class is sealed. A new base class was created for the elements used in this scene.
Future Enhancements
- Support texture materials (it already exports texture coordinates)
- The scene graph traversal may be improved with
LogicalTreeHelper?
- Unit tests
Links
History
|
|
 |
 | WPF Transformations pittaman | 4:31 2 Feb '10 |
|
 |
Hello,
I'm currently using the exporter but I'm having an issue.
In WPF we position our 3D models by assigning certain transformations to them using the Transformation property. In the ViewPort we can see our models on the correct location and rotated in the correct manner.
However, in the export to Kerkythea our objects are no longer positioned correctly. In fact, it's almost like the transformations haven't been applied.
I had the same problem with the camera, which we also positioned using a transformation. The camera would always be in the same position for the Kerkythea export, so what I did was transform the camera's Position Point3D with the Transformation manually, using Transform.Transform(Point3D p). This made sure the point saved in the Kerkythea XML was the point with the transformation already applied.
I tried the same approach with each mesh point when exporting, but so far this hasn't been really succesful.
Anybody had this problem or is able to give me a hint?
Thanks.
|
|
|
|
 |
|
 |
good to hear you are using the code! I am continuing the development of this exporter in the helix project. Will update the CodeProject article when everything is sorted out. There is still an issue with the transformations of objects (I suspect mismatch in transformation matrix rotation-translation order or the Visual3D tree traversal). I would be very happy if you could do a debug session and figure this out! The transformation of PerspectiveCameras should work fine.
|
|
|
|
 |
 | Animation andre12345 | 2:07 13 Jul '09 |
|
|
 |
|
 |
You obviously didn't read the first paragraph, as the author stated "it is neccessary to use a non real-time method", meaning the game wouldn't run in real time. Even if you could get the renderer to run in real-time, Kerkythea is still a standalone program, which is why the article implements an exporter.
|
|
|
|
 |
|
 |
Sorry... I will try to pay more attention.
|
|
|
|
 |
|
|
Last Updated 10 Jul 2009 |
Advertise |
Privacy |
Terms of Use |
Copyright ©
CodeProject, 1999-2010