task that renders a single screen tile */
| 168 | |
| 169 | /* task that renders a single screen tile */ |
| 170 | void renderPixelStandard(const TutorialData& data, |
| 171 | int x, int y, |
| 172 | int* pixels, |
| 173 | const unsigned int width, |
| 174 | const unsigned int height, |
| 175 | const float time, |
| 176 | const ISPCCamera& camera, RayStats& stats) |
| 177 | { |
| 178 | /* initialize ray */ |
| 179 | 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); |
| 180 | |
| 181 | /* intersect ray with scene */ |
| 182 | RTCIntersectArguments iargs; |
| 183 | rtcInitIntersectArguments(&iargs); |
| 184 | iargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); |
| 185 | |
| 186 | rtcTraversableIntersect1(data.g_traversable,RTCRayHit_(ray),&iargs); |
| 187 | RayStats_addRay(stats); |
| 188 | |
| 189 | /* shade pixels */ |
| 190 | Vec3fa color = Vec3fa(0.0f); |
| 191 | if (ray.geomID != RTC_INVALID_GEOMETRY_ID) |
| 192 | { |
| 193 | Vec3fa diffuse = Vec3fa(data.colors[ray.geomID]); |
| 194 | color = color + diffuse*0.1f; |
| 195 | Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1)); |
| 196 | |
| 197 | /* initialize shadow ray */ |
| 198 | Ray shadow(ray.org + ray.tfar*ray.dir, neg(lightDir), 0.001f, inf); |
| 199 | |
| 200 | /* trace shadow ray */ |
| 201 | RTCOccludedArguments sargs; |
| 202 | rtcInitOccludedArguments(&sargs); |
| 203 | sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK); |
| 204 | rtcTraversableOccluded1(data.g_traversable,RTCRay_(shadow),&sargs); |
| 205 | RayStats_addShadowRay(stats); |
| 206 | |
| 207 | /* add light contribution */ |
| 208 | if (shadow.tfar >= 0.0f) |
| 209 | color = color + diffuse*clamp(-dot(lightDir,normalize(ray.Ng)),0.0f,1.0f); |
| 210 | } |
| 211 | |
| 212 | /* write color to framebuffer */ |
| 213 | unsigned int r = (unsigned int) (255.0f * clamp(color.x,0.0f,1.0f)); |
| 214 | unsigned int g = (unsigned int) (255.0f * clamp(color.y,0.0f,1.0f)); |
| 215 | unsigned int b = (unsigned int) (255.0f * clamp(color.z,0.0f,1.0f)); |
| 216 | pixels[y*width+x] = (b << 16) + (g << 8) + r; |
| 217 | } |
| 218 | |
| 219 | /* renders a single screen tile */ |
| 220 | void renderTileStandard(int taskIndex, |
no test coverage detected