added scenes/trans-boxes.fart, changed Scene to consider all back-faces as front-faces by inverting the normal vector, fixed bug in Scene::calculateLightContribution() which was messing up shadow values and back-face intensities for transparent objects
git-svn-id: svn://anubis/fart/trunk@187 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
b50c4de1bc
commit
24ef1eca3c
1
.todo
1
.todo
@ -4,3 +4,4 @@ FART To-Do List
|
|||||||
- Continue for transparency
|
- Continue for transparency
|
||||||
- Scan for cameras before scene items
|
- Scan for cameras before scene items
|
||||||
- Test subtractions of subtractions
|
- Test subtractions of subtractions
|
||||||
|
- Add built-in timing around Scene::render()
|
||||||
|
@ -158,6 +158,13 @@ Color Scene::traceRayRecurse(const Ray & ray, int depth, double factor)
|
|||||||
Vector surfacePoint = ray[hit.dist];
|
Vector surfacePoint = ray[hit.dist];
|
||||||
Vector surfaceNormal = hit.shape->getNormalAt(surfacePoint);
|
Vector surfaceNormal = hit.shape->getNormalAt(surfacePoint);
|
||||||
|
|
||||||
|
/* check for backfaces */
|
||||||
|
if (ray.getDirection() % surfaceNormal > 0.0)
|
||||||
|
{
|
||||||
|
/* if dot product is positive, this is a back-face */
|
||||||
|
surfaceNormal = -surfaceNormal;
|
||||||
|
}
|
||||||
|
|
||||||
color = computePhong(material,
|
color = computePhong(material,
|
||||||
ray,
|
ray,
|
||||||
surfacePoint,
|
surfacePoint,
|
||||||
@ -215,7 +222,6 @@ Scene::ShapeDistance Scene::getRayClosestHit(const Ray & ray)
|
|||||||
{
|
{
|
||||||
refptr<Shape> shape = intersections[i].shape;
|
refptr<Shape> shape = intersections[i].shape;
|
||||||
const Vector & isect_point = intersections[i].vector;
|
const Vector & isect_point = intersections[i].vector;
|
||||||
Vector normal = shape->getNormalAt(isect_point);
|
|
||||||
double intersect_dist = (isect_point - ray.getOrigin()).mag();
|
double intersect_dist = (isect_point - ray.getOrigin()).mag();
|
||||||
if (foundOne == false || intersect_dist < hit.dist)
|
if (foundOne == false || intersect_dist < hit.dist)
|
||||||
{
|
{
|
||||||
@ -313,7 +319,9 @@ double Scene::calculateLightContribution(const Ray & toLight,
|
|||||||
if ( contrib < SCENE_FACTOR_THRESHOLD )
|
if ( contrib < SCENE_FACTOR_THRESHOLD )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
dist_so_far += hit.dist + 0.0001;
|
double offset = hit.dist + 0.0001;
|
||||||
|
dist_so_far += offset;
|
||||||
|
currentRay = currentRay.shift(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contrib;
|
return contrib;
|
||||||
|
46
scenes/trans-boxes.fart
Normal file
46
scenes/trans-boxes.fart
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
|
||||||
|
scene
|
||||||
|
{
|
||||||
|
options
|
||||||
|
{
|
||||||
|
width 800
|
||||||
|
height 600
|
||||||
|
multisample 3
|
||||||
|
}
|
||||||
|
|
||||||
|
camera
|
||||||
|
{
|
||||||
|
position <3, -4, 4>
|
||||||
|
look_at <0, 0, 0>
|
||||||
|
up <0, 0, 1>
|
||||||
|
}
|
||||||
|
|
||||||
|
light { position <5, -2, 5> }
|
||||||
|
|
||||||
|
plane
|
||||||
|
{
|
||||||
|
position <0, 0, 1>, 0
|
||||||
|
material { color <0.8, 0.8, 0.8> }
|
||||||
|
}
|
||||||
|
|
||||||
|
box
|
||||||
|
{
|
||||||
|
size <1, 1, 1>
|
||||||
|
translate <0, -1.5, 0.6>
|
||||||
|
material { color <0, 0, 1> transparency 0.8 }
|
||||||
|
}
|
||||||
|
|
||||||
|
box
|
||||||
|
{
|
||||||
|
size <1, 1, 1>
|
||||||
|
translate <0, 0, 0.6>
|
||||||
|
material { color <0, 0, 1> transparency 0.4 }
|
||||||
|
}
|
||||||
|
|
||||||
|
box
|
||||||
|
{
|
||||||
|
size <1, 1, 1>
|
||||||
|
translate <0, 1.5, 0.6>
|
||||||
|
material { color <0, 0, 1> transparency 0.1 }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user