Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have the following function:

normalSpheres = 
 Table[Sphere[RandomVariate[NormalDistribution[0, 10], 3], .2], {500}];

Manipulate[
 Graphics3D[normalSpheres, Background -> Black, ViewAngle -> 1, 
  ViewVector -> {{50 Sin[t], 50 Cos[t], 0}, {0, 0, 0}}, 
  ImageSize -> Large], {t, 0, 2 Pi}]

enter image description here

I want to imbue this with a feeling of depth though. The best way I can think of is by creating a blur effect for each Sphere that increases the further away the object is from the ViewPoint (or ViewVector[[1]] in this case).

Does anybody have any tips on how I could achieve this?

P.S. sorry if the GIF makes anyone dizzy...

Keyword: depth of field

share|improve this question
1  
It's hard to do blurring of any sort — depth of field, motion blur, etc. — in the traditional hardware rendering pipeline, which is what I believe Mathematica uses for its 3D graphics. To depict fuzzy, blurry things (like smoke and fire) in games one typically uses sprites, i.e. predefined 2D images with transparency that are inserted into the 3D scene. One could try the same thing here by precomputing images of 3D spheres with varying amounts of blur. But that's more work than I'm willing to attempt right now :) –  Rahul May 16 '14 at 4:03
    
What's your main goal? 1. If it's just creating a sense of depth, I think ybeltukov's solution is great and better than blurring. 2. If you want blurring, export the scene from Mathematica and use tools which are designed for the purpose, such as Blender. 3. If you simply want to push the boundaries of what's possible with Mathematica, and doing it with Mathematica is more important than getting the best possible result, then perhaps indicate this in the question. –  Szabolcs Mar 1 at 19:01

2 Answers 2

In spirit of djp's answer: one can put a point lighting source at the camera position to distinguish distances to spheres.

With the option

Lighting -> {{"Point", White, ImageScaled@{0, 0, 0}, {0, 0, 5}}}

I obtain

enter image description here

share|improve this answer

Show the spheres together with a black semi-opaque bitmap. It gives "fog", but not blur.

spheres = 
  Table[Sphere[
    RandomVariate[UniformDistribution[{0.2, 0.8}], 3], .01], {100}];
cube = {{{RGBColor[0, 0, 0, 0.07]}}};
c = Image3D[cube];
s = Graphics3D[spheres, Background -> Black, ImageSize -> Large];
Show[s, c]

Spheres with fog but no blur

It gives distance, but not depth of field. I tried to achieve depth of field by using a series of slabs where I applied "Blur" to each slab, but it didn't work --- the documentation claims that Blur works with 3D images but IMHO it doesn't.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.