MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / drawSlices

Method drawSlices

cpp/5_Domain_Specific/smokeParticles/SmokeRenderer.cpp:291–331  ·  view source on GitHub ↗

draw particles as slices with shadowing

Source from the content-addressed store, hash-verified

289
290// draw particles as slices with shadowing
291void SmokeRenderer::drawSlices()
292{
293 m_batchSize = mNumParticles / m_numSlices;
294
295 // clear light buffer
296 m_srcLightTexture = 0;
297 m_lightFbo->Bind();
298 m_lightFbo->AttachTexture(GL_TEXTURE_2D, m_lightTexture[m_srcLightTexture], GL_COLOR_ATTACHMENT0_EXT);
299 glClearColor(1.0f - m_lightColor[0], 1.0f - m_lightColor[1], 1.0f - m_lightColor[2], 0.0f);
300 glClear(GL_COLOR_BUFFER_BIT);
301 m_lightFbo->Disable();
302
303 // clear volume image
304 m_imageFbo->Bind();
305 glClearColor(0.0, 0.0, 0.0, 0.0);
306 glClear(GL_COLOR_BUFFER_BIT);
307 m_imageFbo->Disable();
308
309 glActiveTexture(GL_TEXTURE0);
310 glMatrixMode(GL_TEXTURE);
311 glLoadMatrixf((GLfloat *)m_shadowMatrix.get_value());
312
313 // render slices
314 if (m_numDisplayedSlices > m_numSlices)
315 m_numDisplayedSlices = m_numSlices;
316
317 for (int i = 0; i < m_numDisplayedSlices; i++) {
318 // draw slice from camera view, sampling light buffer
319 drawSlice(i);
320 // draw slice from light view to light buffer, accumulating shadows
321 drawSliceLightView(i);
322
323 if (m_doBlur) {
324 blurLightBuffer();
325 }
326 }
327
328 glActiveTexture(GL_TEXTURE0);
329 glMatrixMode(GL_TEXTURE);
330 glLoadIdentity();
331}
332
333// blur light buffer to simulate scattering effects
334void SmokeRenderer::blurLightBuffer()

Callers

nothing calls this directly

Calls 4

AttachTextureMethod · 0.80
DisableMethod · 0.80
BindMethod · 0.45
get_valueMethod · 0.45

Tested by

no test coverage detected