Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Bugs are sometimes cool.
Index -> Programming, C++ -> C++ Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
apython1992




PostPosted: Sat Jul 09, 2011 7:26 pm   Post subject: Bugs are sometimes cool.

Yeah I'm submitting a bug. I'm starting to work on lighting and shading in my raytracer, and part of that is determining whether an object is in shadow or not. To do this, you need to see if any objects are blocking the light source from a point on the object. My method right now includes seeing if the light source is "in front of itself" (this is the bug, I just haven't fixed it yet), but it ended up producing a kind of cool picture due to the inaccuracy of floating point numbers. Cool!


test.png
 Description:
 Filesize:  332.82 KB
 Viewed:  204 Time(s)

test.png


Sponsor
Sponsor
Sponsor
sponsor
RandomLetters




PostPosted: Sat Jul 09, 2011 8:46 pm   Post subject: RE:Bugs are sometimes cool.

I think you have just found a new way of generating cloud textures like that in photoshop Razz

http://www.photoshopessentials.com/images/elements/8/photo-effects/light-rays/photoshop-elements-clouds.jpg

It looks completely random too.
DemonWasp




PostPosted: Sun Jul 10, 2011 1:10 am   Post subject: RE:Bugs are sometimes cool.

The method photoshop uses is almost certainly unrelated; it's called "midpoint displacement": http://www.gameprogrammer.com/fractal.html

The noise generated is also not random, though it does look like it. In particular, if camera and light source both lie on the normal of a plane, and the camera looks directly at the plane, you should see an interesting artifact (neither square nor circle, but something similar). apython, mind seeing if i'm right on that one?
apython1992




PostPosted: Sun Jul 10, 2011 10:23 am   Post subject: Re: Bugs are sometimes cool.

This is the shot taken (had to re-create the bug) suggested by DemonWasp. I used the exact same scene definition, with the light source placed on the plane's normal in line with the camera. I think the noise was really just because of floating point numbers (sometimes the light may be considered "blocking itself", other times it won't).


test.png
 Description:
 Filesize:  6.39 KB
 Viewed:  3342 Time(s)

test.png


DemonWasp




PostPosted: Sun Jul 10, 2011 3:03 pm   Post subject: RE:Bugs are sometimes cool.

Well, that isn't what I would have predicted. You're absolutely correct that it was floating-point errors, but I would have expected a kind of circular or square pattern, not the pattern we see here (the pink object is always shadowed by itself, the blue sphere is never shadowed by itself).
Display posts from previous:   
   Index -> Programming, C++ -> C++ Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: