3

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));
Timur Nuriyasov
  • 359
  • 2
  • 16

1 Answers1

1

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.
Lukasz Madon
  • 14,664
  • 14
  • 64
  • 108
  • Thanks for your reply. I have thought about "google maps way" - the problem is that if you scan the whole surface in zoomed-in mode, app will load all these small hi-res images, so instead of one big high-res image, you'll get many small high-res images which eventually take up the same memory space. – Timur Nuriyasov Apr 23 '12 at 12:19
  • 5000*5000*4 is indeed about 100mb. But with all the overhead c# creates, it becomes so large as 300 mb. Also, huge texture way is not a feasible solution - I will have many slices, and if each slice takes 200mb of memory, imagine what will happen when 20 slices are present. – Timur Nuriyasov Apr 23 '12 at 12:23
  • If you move your camera outside the view of one slice you will delete the reference and GC will collect the memory. I advice you to read this post http://stackoverflow.com/questions/538060/proper-use-of-the-idisposable-interface . Secodnly, the hugh texture is a good way, but use DXT - it is compressed format and should use roughly 1/8 of the memory. – Lukasz Madon Apr 23 '12 at 12:36