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

Function renderTileStandard

tutorials/voronoi/voronoi_device.cpp:175–214  ·  view source on GitHub ↗

renders a single screen tile */

Source from the content-addressed store, hash-verified

173
174/* renders a single screen tile */
175void renderTileStandard(int taskIndex,
176 int threadIndex,
177 int* pixels,
178 const unsigned int width,
179 const unsigned int height,
180 const float time,
181 const ISPCCamera& camera,
182 const int numTilesX,
183 const int numTilesY)
184{
185 const unsigned int tileY = taskIndex / numTilesX;
186 const unsigned int tileX = taskIndex - tileY * numTilesX;
187 const unsigned int x0 = tileX * TILE_SIZE_X;
188 const unsigned int x1 = min(x0+TILE_SIZE_X,width);
189 const unsigned int y0 = tileY * TILE_SIZE_Y;
190 const unsigned int y1 = min(y0+TILE_SIZE_Y,height);
191
192 for (unsigned int y=y0; y<y1; y++) for (unsigned int x=x0; x<x1; x++)
193 {
194 Vec3fa color = Vec3fa(0.f);
195 if (data.show_voronoi)
196 {
197 Vec3fa q = Vec3fa((float(x) + 0.5f) / width, 0.f, (float(y) + 0.5f) / height);
198
199 KNNResult result(data.num_knn, data.points);
200 result.k = 1;
201 knnQuery(q, data.tmax, &result);
202 unsigned int primID = result.knn.empty() ? RTC_INVALID_GEOMETRY_ID : result.knn.top().primID;
203
204 if (primID != RTC_INVALID_GEOMETRY_ID)
205 color = data.colors[primID % 27];
206 }
207
208 /* write color to framebuffer */
209 unsigned int r = (unsigned int) (255.0f * clamp(color.x,0.0f,1.0f));
210 unsigned int g = (unsigned int) (255.0f * clamp(color.y,0.0f,1.0f));
211 unsigned int b = (unsigned int) (255.0f * clamp(color.z,0.0f,1.0f));
212 pixels[y*width+x] = (b << 16) + (g << 8) + r;
213 }
214}
215
216/* task that renders a single screen tile */
217void renderTileTask (int taskIndex, int threadIndex, int* pixels,

Callers 1

renderTileTaskFunction · 0.70

Calls 5

knnQueryFunction · 0.85
minFunction · 0.50
Vec3faClass · 0.50
clampFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected