|
Post by packetslave on Aug 13, 2020 6:04:12 GMT
I'm playing around with the Stanford Bunny model (69,630 triangles). It's rendering in a reasonable amount of time, but my bunny has a bad case of acne. This is rendered at 1600 x 1200 w/ 16 randomized samples per pixel. The same code renders my teapot (3600 triangles) with no acne and nice smoothed edges. Any suggestions for helping Mr. Bunny clear his skin up? The PBRT book talks a fair bit about minimizing floating point error, maybe that's an issue?
|
|
|
Post by packetslave on Aug 13, 2020 7:01:54 GMT
|
|
|
Post by Jamis on Aug 20, 2020 15:19:01 GMT
Hey packetslave , that's odd about the acne. Where did you download the model? I grabbed a copy from www.prinmath.com/csci5229/OBJ/index.html, and it seems to render okay without any additional optimizations: Do you have your implementation posted anywhere? I could compare it with my own and see if anything jumps out at me.
|
|
|
Post by matthew on Dec 24, 2020 21:42:32 GMT
I'm having the same problem. My rabbit looks horrible; I used the one Jamis referred to. My current debugging technique is to set the default background color to Hot Pink and then I am setting all shadows to Lime Green. I wish I could post the picture but all the acne got replaced with lime green colors which tells me the problem is definitely having to do with shadows; specifically OverPoint. I don't know why this is happening since the math and algorithms are just as described in the book and pass all the tests. I am using C# so perhaps it is the .NET VM if that is happening. I have some ideas and I will check back if anything works but I do recommend changing the colors as I described to help isolate where the acne is actually coming from.
Here is a code sample from Material.Lighting:
if ((lightDotNormal < 0) || inShadow) { diffuse = inShadow ? Color.LimeGreen : Color.Black; specular = inShadow ? Color.LimeGreen : Color.Black; } else {
The solution I came up with is surprising... I had to stop letting the object shadow itself. My solution involved two things: 1) Make sure the hit object is not the same as the object being tested i.e. (hit.Object != obj) 2) Make sure the direction of the shadow vector isn't hitting the wrong side of the shape, in this case a triangle i.e. (Ray Direction DOT Normal Vector) > 0
I changed IsShadowed called from ShadeHit in the World class. Instead of passing in the OverPoint I am now passing the whole Computations object:
public bool IsShadowed(RTObject obj, Computations comps)
{
bool isShadowed = false;
var point = comps.OverPoint;
foreach (var light in Lights)
{
var v = new Vector(light.Position - point);
var distance = v.Magnitude;
var direction = v.Normalize;
var r = new Ray(point, direction);
var intersections = Intersect(r);
var dN = direction.Dot(comps.NormalVector);
var h = intersections.Hit;
if ((h != null) && (h.t < distance) && (h.Object.HasShadow) && (h.Object != obj) && (dN <= 0))
{
isShadowed = true;
break;
}
}
return isShadowed;
}
|
|