-1

I currently have an ray-tracer that can read .obj models and then render the objects described on them. Until now, I was basically working with .obj models where the vertices where around the origin, generally closer than 10 of distance, at maximum being around 100.

Now, I downloaded a different model, where the vertices are far away from the origin, Always at least at hundreds of units from the origin, some vertices being about 5000 away in some axis.

The problem is that now I cannot focus the entire car!

One of my tests was with the distance from camera to origin of -3639. And the result was this: car3669.jpg

Then I step the camera away at -4639 and what was produced was this:

car-4639.jpg

Changing my approach, decided to approach it, placing the camera at -2639 The result:

car2669.jpg

So at -2639 a I am being able to visualize the entire car but it does not fit in my field of view. At -3669 the light is already fading away by some reason. I imagine that might be possible to see the full car proper lightened using a intermediate distance between -2669 and -3669 and also experimenting with the filed of view value, but there is something odd about the Light not covering the entire car at -3669 and I would like to find out the reason.

So I would appreciate suggestions about the cause of this issue and how to proceed in this kind of situation, how to focus the entire car.

user2752471
  • 444
  • 1
  • 6
  • 14
  • This is impossible to answer without knowing how you implement cameras, lights, do lighting calculations, bounding boxes... basically how your whole raytracer works. If you told us all that, then you'd be asking for general debugging help. Too many things can go wrong in a ray tracer. I know because I've written some. S.O. is for more specific focused questions that don't need the design or source for a whole application. – DarenW Jul 30 '18 at 17:22

2 Answers2

0

Your question mentions you are changing the camera position. However, the images show the lighting area changing between the various cases. Just a spotlight in one case, and more of the car being lit in the other.

Most likely, in the third case, nothing of the car is lit, hence everything comes up black. Start by fixing the light staying the same when the camera moves, and see if it fixes your issue.

Jeffrey
  • 11,063
  • 1
  • 21
  • 42
  • ?. The light is static in all these examples. – user2752471 Jul 31 '18 at 15:58
  • Yes, you want a static light, but the rendered images show something else. The first image shows something like a cone of light. The last image has a spoiler/deflector and something like a taxi cab sign on top. So, I'm betting your issue is the spot moving (inavertently). Figure out what moves the spot and you'll have your issue. – Jeffrey Jul 31 '18 at 16:03
0

If you move the camera: It could help looking into the settings for the front and back clipping planes.

If you don't move the camera: The FOV show be larger if the object is larger. I would avoid doing this as this likely will lead to more problems when you read more than one object that are different.

Personally I would scale the input from the file. Ideally to some SI-unit that makes sense.

beyond
  • 451
  • 2
  • 15
  • There are no clipping planes. About the scale suggestion: could I divide all verts coordinates by a value? Example: A vert with coords 1000,2000,800 would became 10,20,8. – user2752471 Jul 31 '18 at 15:58
  • Sure. For a start just play around with the scaling, a good start seems to scale it down by a factor 10. If you want to keep all coordinates in meters (for instance) and you know how big the car is in real life, you can find the object's bounding box' size and find the exact scaling value. – beyond Aug 01 '18 at 06:48
  • If you don't use front and clipping planes, I guess that you have som range on your light source? Your two first pictures imply that there is something range-related going on. Try to render your second image again, but with a white pixel for any hit, black otherwise. No shading at all. – beyond Aug 01 '18 at 06:53