task that renders a single screen tile */
| 275 | |
| 276 | /* task that renders a single screen tile */ |
| 277 | Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera, RayStats& stats) |
| 278 | { |
| 279 | /* initialize ray */ |
| 280 | Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf, 0.0f, -1, RTC_INVALID_GEOMETRY_ID, RTC_INVALID_GEOMETRY_ID); |
| 281 | ray.instID[0] = 4; |
| 282 | |
| 283 | /* intersect ray with scene */ |
| 284 | rtcIntersect1(g_scene,RTCRayHit_(ray)); |
| 285 | RayStats_addRay(stats); |
| 286 | |
| 287 | /* shade pixels */ |
| 288 | Vec3fa color = Vec3fa(0.0f); |
| 289 | if (ray.geomID != RTC_INVALID_GEOMETRY_ID) |
| 290 | { |
| 291 | Vec3fa diffuse = Vec3fa(1.0f); |
| 292 | color = color + diffuse*0.5; |
| 293 | Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); |
| 294 | |
| 295 | /* initialize shadow ray */ |
| 296 | Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf); |
| 297 | |
| 298 | /* trace shadow ray */ |
| 299 | rtcOccluded1(g_scene,RTCRay_(shadow)); |
| 300 | RayStats_addShadowRay(stats); |
| 301 | |
| 302 | /* add light contribution */ |
| 303 | if (shadow.tfar >= 0.0f) |
| 304 | color = color + diffuse*clamp(-dot(lightDir,normalize(ray.Ng)),0.0f,1.0f); |
| 305 | } |
| 306 | return color; |
| 307 | } |
| 308 | |
| 309 | /* renders a single screen tile */ |
| 310 | void renderTileStandard(int taskIndex, |
no test coverage detected