Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF 3D Dynamic Textures

Tags:

c#

.net

wpf

directx

3d

I am writing a program (c# .NET 4.0 WPF 3D) that renders earth slices (like OpendTect's or Petrel's seismics module).

The problem is that I need to be able to zoom in deeply, and still see the details.

I tried putting a huge detailed texture (5000x5000), but it eats too much memory (200-300 MB), and crashes when I try to increase the size.

Now I want to see if there is any way of using something like a dynamic texture - the one that will change depending on distance to the camera.

Or maybe there is some other way of dealing with high-resolution surfaces?

I use this code to load texture:

wbm = new WriteableBitmap(
(int)1306*scale,
(int)ns*scale,
96,
96,
PixelFormats.Indexed8,
new BitmapPalette(getColors()));

...

visual3d.Material = visual3d.BackMaterial
= new DiffuseMaterial(new ImageBrush(wbm));
like image 724
Timur Nuriyasov Avatar asked Jul 11 '26 14:07

Timur Nuriyasov


1 Answers

You have several options here:

  • Optimize current solution. 5000 * 5000 * 4 is around 100 MB. How do you load and show the texture? I have an app that renders up to 1100 3d objects and uses 300MB of memory and the performance is good enough. I strongly advice you to run a profiler, not only for pure performance reasons, but it helps to catch bugs! I my WPF 3D, thanks to the profiler I found that I was doing useless tessellation.
  • Create one low resolution image of whole texture and a few small high resolution images which are parts of the texture. If the user clicks/zooms-in you will load small high resolution image that will fit viewport. Similar effect to google maps.
  • Use XNA. You can host XNA inside WPF and use DXT texture. I'm not sure, but WPF doesn't support that texture formant directly.
like image 123
Lukasz Madon Avatar answered Jul 13 '26 11:07

Lukasz Madon