Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Anybody into Ray Tracing ?

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to write a simple ray tracer as part of a project I am working on (In java of course). The ray tracer will be use as a benchmarking tool so it doesn't have to be another Prov-Ray
I have put together the bones of a really simple tracing engine but in some simple tests the resulting image does not come out as expected.
In the case of a sphere sitting back from the origin every thing looks ok but when I move the sphere to the left or right of the origin it comes out as an ellipse. The further away from the origin the wider the ellipse becomes(the height stays the same) In the case of the sphere I am using the standard method to calculate the intersection( i.e. solving the quadratic eqn after subbing in values for x, y, z in the equation of a sphere). Shading is modeled using Lamberts law and the light source is at the initial projection point, for now I don't deal with shadows.
I'm at a loss as to why the sphere becomes distorted. Does anyone see something obvious that I might be overlooking ? Thanks
 
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the first thing about raytracing, but I just read a tutorial and it doesn't sound too mind-blowing. So here is the hopeless guessing from someone who didn't know anything at all about raytracing yesterday:
What exactly is the initial projection point? It doesn't sound like a trick of lighting and shade or reflection, but it might be the intersection algorithim or some sort of scaling problem projecting points onto the 2D window.
This sort of question would be perfect for the algorithms forum that hasn't been created...
 
Dermot Curley
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved it ! David your guess was right on the mark. I dont know if this is a quirk specific to my implementation or if it holds true in general , but it was caused because I put my projection point too close to the image plane. I dont understand why but when I push the projection point back things look a lot better.
Thanks for the help David.
Regarding the algoritm forum I agree it sounds like a good idea. I'm sure that people interested in graphics would make good use of it.
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm. I can imagine things would get distorted by a computer if the angles got too extreme. I've always had a knack for answering multiple choice questions I know nothing about, but now I'm moving into the big leauge.
I confess though, when I asked, "What exactly is the initial projection point?" it was because I didn't know what that meant -- I think I get it now though .
 
It sure was nice of your sister to lend us her car. Let's show our appreciation by sharing this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic