renders a single pixel with eyelight shading */
| 319 | |
| 320 | /* renders a single pixel with eyelight shading */ |
| 321 | Vec3fa renderPixelAOShader(const DebugShaderData& data, float x, float y, const ISPCCamera& camera, RayStats& stats, const RTCFeatureFlags feature_mask) |
| 322 | { |
| 323 | /* initialize ray */ |
| 324 | Ray ray; |
| 325 | ray.org = Vec3ff(camera.xfm.p); |
| 326 | ray.dir = Vec3ff(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)); |
| 327 | ray.tnear() = 0.0f; |
| 328 | ray.tfar = inf; |
| 329 | ray.geomID = RTC_INVALID_GEOMETRY_ID; |
| 330 | ray.primID = RTC_INVALID_GEOMETRY_ID; |
| 331 | ray.mask = -1; |
| 332 | ray.time() = data.debug; |
| 333 | |
| 334 | /* intersect ray with scene */ |
| 335 | RTCIntersectArguments args; |
| 336 | rtcInitIntersectArguments(&args); |
| 337 | args.feature_mask = feature_mask; |
| 338 | rtcTraversableIntersect1(data.traversable,RTCRayHit_(ray),&args); |
| 339 | RayStats_addRay(stats); |
| 340 | |
| 341 | /* shade pixel */ |
| 342 | if (ray.geomID == RTC_INVALID_GEOMETRY_ID) return Vec3fa(0.0f); |
| 343 | |
| 344 | Vec3fa Ng = normalize(ray.Ng); |
| 345 | Vec3fa Nf = faceforward(Ng,ray.dir,Ng); |
| 346 | Vec3fa col = Vec3fa(min(1.f,.3f+.8f*abs(dot(Ng,normalize(ray.dir))))); |
| 347 | |
| 348 | /* calculate hit point */ |
| 349 | float intensity = 0; |
| 350 | Vec3fa hitPos = ray.org + ray.tfar * ray.dir; |
| 351 | |
| 352 | #define AMBIENT_OCCLUSION_SAMPLES 64 |
| 353 | /* trace some ambient occlusion rays */ |
| 354 | RandomSampler sampler; |
| 355 | RandomSampler_init(sampler, (int)x, (int)y, 0); |
| 356 | for (int i=0; i<AMBIENT_OCCLUSION_SAMPLES; i++) |
| 357 | { |
| 358 | Vec2f sample = RandomSampler_get2D(sampler); |
| 359 | Sample3f dir = cosineSampleHemisphere(sample.x,sample.y,Nf); |
| 360 | |
| 361 | /* initialize shadow ray */ |
| 362 | Ray shadow; |
| 363 | shadow.org = Vec3ff(hitPos); |
| 364 | shadow.dir = Vec3ff(dir.v); |
| 365 | shadow.tnear() = 0.001f; |
| 366 | shadow.tfar = inf; |
| 367 | shadow.geomID = RTC_INVALID_GEOMETRY_ID; |
| 368 | shadow.primID = RTC_INVALID_GEOMETRY_ID; |
| 369 | shadow.mask = -1; |
| 370 | shadow.time() = data.debug; |
| 371 | |
| 372 | /* trace shadow ray */ |
| 373 | RTCOccludedArguments args; |
| 374 | rtcInitOccludedArguments(&args); |
| 375 | args.feature_mask = feature_mask; |
| 376 | rtcTraversableOccluded1(data.traversable,RTCRay_(shadow),&args); |
| 377 | RayStats_addShadowRay(stats); |
| 378 |
nothing calls this directly
no test coverage detected