johns
New Member
Posts: 4
|
Post by johns on Jan 3, 2021 23:28:50 GMT
I was hoping I might be able to get some help here regarding an odd issue im having. When I ray trace a sphere on its own, the lighting looks fine, transformations and all. But when in a world setting, any sphere that has a transform on it appears shadowed. I know it must have something to do with the normals, but I cant figure it out. These are the two functions, the equivalents work fine for planes, but fall apart for spheres for some reason. public Vector NormalAt(Point p) { Point localPoint = Transform.Inverse() * p; Vector localNormal = LocalNormalAt(localPoint); Vector worldNormal = Transform.Inverse().Transpose() * localNormal; worldNormal.Normalize(); return worldNormal; } public override Vector LocalNormalAt(Point p) { Vector objNormal = p - Point.Origin(); return objNormal; } Attachments:pinhole.bmp (6.2 KB)
|
|
|
Post by cloose on Jan 4, 2021 15:53:13 GMT
Hi johns,
on first look, it looks okay. Is Point.Origin() always at (0, 0, 0)? Since without transformations, the sphere is a unit sphere at the origin.
|
|
johns
New Member
Posts: 4
|
Post by johns on Jan 4, 2021 20:32:14 GMT
Yeah, i should have clarified that part. Point.Origin() is a static function that returns a new point at 0,0,0
|
|
johns
New Member
Posts: 4
|
Post by johns on Jan 9, 2021 19:30:34 GMT
I honestly dont know what the problem was but it corrected itself after me rewriting all the intersection code in both the world and shapes.
|
|