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

Function renderPixel

tutorials/instanced_geometry/instanced_geometry_device.cpp:169–220  ·  view source on GitHub ↗

task that renders a single screen tile */

Source from the content-addressed store, hash-verified

167
168/* task that renders a single screen tile */
169Vec3fa renderPixel(const TutorialData& data, float x, float y, const ISPCCamera& camera, RayStats& stats)
170{
171 /* initialize ray */
172 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);
173
174 /* intersect ray with scene */
175 RTCIntersectArguments iargs;
176 rtcInitIntersectArguments(&iargs);
177 iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK);
178
179 rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs);
180 RayStats_addRay(stats);
181
182 /* shade pixels */
183 Vec3fa color = Vec3fa(0.0f);
184 if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
185 {
186 /* calculate shading normal in world space */
187 Vec3fa Ns = ray.Ng;
188 if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID)
189 {
190 AffineSpace3fa xfm;
191 rtcGetGeometryTransformFromTraversable(data.g_traversable,ray.instID[0],0.0f,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,&xfm);
192 Ns = xfmNormal(xfm,Ns);
193 //Ns = xfmVector(data.normal_xfm[ray.instID[0]],Ns);
194 }
195 Ns = normalize(Ns);
196
197 /* calculate diffuse color of geometries */
198 Vec3fa diffuse = Vec3fa(1,1,1);
199 if (ray.instID[0] != RTC_INVALID_GEOMETRY_ID)
200 diffuse = data.colors[4*ray.instID[0]+ray.geomID];
201 color = color + diffuse*0.5;
202
203 /* initialize shadow ray */
204 Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));
205 Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf);
206
207 /* trace shadow ray */
208 RTCOccludedArguments sargs;
209 rtcInitOccludedArguments(&sargs);
210 sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK);
211
212 rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs);
213 RayStats_addShadowRay(stats);
214
215 /* add light contribution */
216 if (shadow.tfar >= 0.0f)
217 color = color + diffuse*clamp(-dot(lightDir,Ns),0.0f,1.0f);
218 }
219 return color;
220}
221
222void renderPixelStandard(const TutorialData& data,
223 int x, int y,

Callers 1

renderPixelStandardFunction · 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
Vec3faClass · 0.50
normalizeFunction · 0.50
rtcTraversableIntersect1Function · 0.50
xfmNormalFunction · 0.50

Tested by

no test coverage detected