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

Function renderPixelStandard

tutorials/viewer/viewer_device.cpp:204–282  ·  view source on GitHub ↗

task that renders a single screen tile */

Source from the content-addressed store, hash-verified

202
203/* task that renders a single screen tile */
204void renderPixelStandard(const TutorialData& data,
205 int x, int y,
206 int* pixels,
207 const unsigned int width,
208 const unsigned int height,
209 const float time,
210 const ISPCCamera& camera,
211 RayStats& stats,
212 const RTCFeatureFlags feature_mask)
213{
214 /* initialize sampler */
215 RandomSampler sampler;
216 RandomSampler_init(sampler, (int)x, (int)y, 0);
217
218 /* initialize ray */
219 float ray_time = data.motion_blur ? RandomSampler_get1D(sampler) : time;
220 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, ray_time);
221
222 /* intersect ray with scene */
223 RTCIntersectArguments args;
224 rtcInitIntersectArguments(&args);
225 args.flags = data.iflags_coherent;
226#if RTC_MIN_WIDTH
227 args.minWidthDistanceFactor = 0.5f*data.min_width/width;
228#endif
229 args.feature_mask = feature_mask;
230
231 rtcTraversableIntersect1(data.traversable,RTCRayHit_(ray),&args);
232 RayStats_addRay(stats);
233
234 /* shade background black */
235 if (ray.geomID == RTC_INVALID_GEOMETRY_ID) {
236 pixels[y*width+x] = 0;
237 return;
238 }
239
240 /* shade all rays that hit something */
241 Vec3fa color = Vec3fa(0.5f);
242
243 /* compute differential geometry */
244 DifferentialGeometry dg;
245 dg.geomID = ray.geomID;
246 dg.primID = ray.primID;
247 dg.u = ray.u;
248 dg.v = ray.v;
249 dg.P = ray.org+ray.tfar*ray.dir;
250 dg.Ng = ray.Ng;
251 dg.Ns = ray.Ng;
252
253#if 0
254 if (data.use_smooth_normals)
255 if (ray.geomID != RTC_INVALID_GEOMETRY_ID) // FIXME: workaround for ISPC bug, location reached with empty execution mask
256 {
257 Vec3fa dPdu,dPdv;
258 auto geomID = ray.geomID; {
259 rtcInterpolate1(rtcGetGeometry(data.scene,geomID),ray.primID,ray.u,ray.v,RTC_BUFFER_TYPE_VERTEX,0,nullptr,&dPdu.x,&dPdv.x,3);
260 }
261 dg.Ns = cross(dPdv,dPdu);

Callers 2

renderTileTaskFunction · 0.70
renderFrameStandardFunction · 0.70

Calls 15

RandomSampler_initFunction · 0.85
RandomSampler_get1DFunction · 0.85
RTCRayHit_Function · 0.85
RayStats_addRayFunction · 0.85
rtcInterpolate1Function · 0.85
negFunction · 0.85
postIntersectFunction · 0.70
face_forwardFunction · 0.70
Vec3faClass · 0.50
normalizeFunction · 0.50
rtcTraversableIntersect1Function · 0.50

Tested by

no test coverage detected