task that renders a single screen tile */
| 742 | |
| 743 | /* task that renders a single screen tile */ |
| 744 | Vec3fa renderPixelStandard(const TutorialData& data, |
| 745 | float x, float y, const ISPCCamera& camera, |
| 746 | RayStats& stats) |
| 747 | { |
| 748 | /* initialize ray */ |
| 749 | Ray ray(Vec3fa(camera.xfm.p), |
| 750 | Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz)), |
| 751 | 0.0f, inf, 0.0f, -1, |
| 752 | RTC_INVALID_GEOMETRY_ID, RTC_INVALID_GEOMETRY_ID); |
| 753 | |
| 754 | /* intersect ray with scene */ |
| 755 | RTCIntersectArguments iargs; |
| 756 | rtcInitIntersectArguments(&iargs); |
| 757 | #if USE_ARGUMENT_CALLBACKS |
| 758 | iargs.filter = contextFilterFunction; |
| 759 | #endif |
| 760 | #if USE_ARGUMENT_CALLBACKS |
| 761 | iargs.intersect = contextIntersectFunc; |
| 762 | #endif |
| 763 | iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); |
| 764 | |
| 765 | rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); |
| 766 | RayStats_addRay(stats); |
| 767 | |
| 768 | /* shade pixels */ |
| 769 | Vec3fa color = Vec3fa(0.0f); |
| 770 | if (ray.geomID != RTC_INVALID_GEOMETRY_ID) |
| 771 | { |
| 772 | /* calculate shading normal in world space */ |
| 773 | Vec3fa Ns = ray.Ng; |
| 774 | |
| 775 | if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID) { |
| 776 | Ns = xfmVector(data.g_instance[ray.instID[0]]->normal2world,Vec3fa(Ns)); |
| 777 | } |
| 778 | Ns = face_forward(ray.dir,normalize(Ns)); |
| 779 | |
| 780 | /* calculate diffuse color of geometries */ |
| 781 | Vec3fa diffuse = Vec3fa(0.0f); |
| 782 | if (ray.instID[0] == 0) diffuse = data.colors[4*ray.instID[0]+ray.primID]; |
| 783 | else if (ray.instID[0] == -1) diffuse = data.colors[4*4+ray.primID]; |
| 784 | else diffuse = data.colors[4*ray.instID[0]+ray.geomID]; |
| 785 | color = color + diffuse*0.5f; |
| 786 | |
| 787 | /* initialize shadow ray */ |
| 788 | Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); |
| 789 | Ray shadow(ray.org + 0.999f*ray.tfar*ray.dir, neg(lightDir), 0.001f, inf); |
| 790 | |
| 791 | /* trace shadow ray */ |
| 792 | RTCOccludedArguments sargs; |
| 793 | rtcInitOccludedArguments(&sargs); |
| 794 | #if USE_ARGUMENT_CALLBACKS |
| 795 | sargs.filter = contextFilterFunction; |
| 796 | #endif |
| 797 | #if USE_ARGUMENT_CALLBACKS |
| 798 | sargs.occluded = contextOccludedFunc; |
| 799 | #endif |
| 800 | sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); |
| 801 |
no test coverage detected