MCPcopy Create free account
hub / github.com/RenderKit/embree / renderPixelStandard

Function renderPixelStandard

tutorials/user_geometry/user_geometry_device.cpp:744–810  ·  view source on GitHub ↗

task that renders a single screen tile */

Source from the content-addressed store, hash-verified

742
743/* task that renders a single screen tile */
744Vec3fa 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

Callers 2

renderTileStandardFunction · 0.70
renderFrameStandardFunction · 0.70

Calls 15

RTCRayHit_Function · 0.85
RayStats_addRayFunction · 0.85
negFunction · 0.85
rtcInitOccludedArgumentsFunction · 0.85
RTCRay_Function · 0.85
RayStats_addShadowRayFunction · 0.85
face_forwardFunction · 0.70
Vec3faClass · 0.50
normalizeFunction · 0.50
rtcTraversableIntersect1Function · 0.50
xfmVectorFunction · 0.50

Tested by

no test coverage detected