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

Function renderPixelStandard

tutorials/forest/forest_device.cpp:334–420  ·  view source on GitHub ↗

task that renders a single screen tile */

Source from the content-addressed store, hash-verified

332
333/* task that renders a single screen tile */
334void renderPixelStandard(const TutorialData& data,
335 int x, int y,
336 int* pixels,
337 const unsigned int width,
338 const unsigned int height,
339 const float time,
340 const ISPCCamera& camera, RayStats& stats)
341{
342 Vec3fa color_accum = Vec3fa(0.0f);
343
344 // multiple samples per pixel because otherwise it looks very
345 // bad due to geometric noise/aliasing in the far-field
346 for (int j = 0; j < data.spp; ++j)
347 for (int i = 0; i < data.spp; ++i)
348 {
349 float fx = (float) x + ((float)i + 0.5f) / 3;
350 float fy = (float) y + ((float)j + 0.5f) / 3;
351 /* initialize ray */
352 Ray ray(Vec3fa(camera.xfm.p), Vec3fa(normalize(fx*camera.xfm.l.vx + fy*camera.xfm.l.vy + camera.xfm.l.vz)), 0.0f, inf);
353
354 /* intersect ray with scene */
355 RTCIntersectArguments iargs;
356 rtcInitIntersectArguments(&iargs);
357 iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK);
358 rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs);
359 RayStats_addRay(stats);
360
361 /* shade pixels */
362 Vec3fa color = Vec3fa(0.0f);
363 if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
364 {
365 Vec3fa diffuse = Vec3fa(1.0f);
366 if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID) {
367 unsigned int tree_idx = 0;
368 if (data.use_instance_array && ray.instPrimID[0] != RTC_INVALID_GEOMETRY_ID) {
369 tree_idx = ray.instPrimID[0];
370 } else {
371 tree_idx = ray.instID[0] - 1;
372 }
373
374 unsigned int tree_id = data.trees_selected[data.tree_ids_device[tree_idx]];
375 Triangle* tree_triangles = data.tree_triangles[tree_id];
376 Triangle triangle = tree_triangles[ray.primID];
377
378 Vec3f* tree_colors = data.tree_vertex_colors[tree_id];
379 Vec3f c0 = tree_colors[triangle.v0];
380 Vec3f c1 = tree_colors[triangle.v1];
381 Vec3f c2 = tree_colors[triangle.v2];
382 float u = ray.u, v = ray.v, w = 1.0f-ray.u-ray.v;
383 Vec3f c = w*c0 + u*c1 + v*c2;
384 diffuse = Vec3fa(c);
385 }
386 else if (ray.geomID == 0) {
387 // ground
388 diffuse = Vec3fa(0.5f, 0.8f, 0.0f);
389 }
390
391 //color = Vec3fa(0.5f) + 0.5 * normal;

Callers 2

renderTileTaskFunction · 0.70
renderFrameStandardFunction · 0.70

Calls 13

RTCRayHit_Function · 0.85
RayStats_addRayFunction · 0.85
negFunction · 0.85
rtcInitOccludedArgumentsFunction · 0.85
RTCRay_Function · 0.85
RayStats_addShadowRayFunction · 0.85
Vec3faClass · 0.50
normalizeFunction · 0.50
rtcTraversableIntersect1Function · 0.50
rtcTraversableOccluded1Function · 0.50
clampFunction · 0.50

Tested by

no test coverage detected