Volume rendering - Volumetric Lighting

130 views
Skip to first unread message

Bob Read

unread,
Aug 15, 2017, 9:59:55 AM8/15/17
to WebGL Dev List
I am trying to implement volumetric lighting as described by Muhammad Movania and Feng Lin in Chapter 17 of WebGL Insights (http://webglinsights.com). There are a couple of JavaScript objects in listings 17.5 and 17.7 called shadowShader and volumeShader but they are not explained very well in the article. Can anybody help me understand what they are and how they were created?

Many thanks,

Bob

Muhammad Mobeen Movania

unread,
Aug 15, 2017, 3:50:25 PM8/15/17
to webgl-d...@googlegroups.com
Hi bob,
   I wrote that chapter and code. The best reference for shadowShader and volumeShader is the half angle slicing code in chapter 7 of opengl development cookbook. For implementation details, refer to this github repo: https://github.com/mmmovania/opengl33_dev_cookbook_2013/tree/master/Chapter7/HalfAngleSlicing

The shaders are shared in this repository.

Hope this helps.
Mobeen

Bob Read

unread,
Sep 1, 2017, 6:35:46 AM9/1/17
to WebGL Dev List
Hi Mobeen,

Many, many thanks for replying. I'll look at the references and hopefully I'll be able to implement your volume slicing technique on my own CT scan data. I am relatively new to WebGL so I am on a very steep learning curve right now!

Best wishes,

Bob

Bob Read

unread,
Sep 1, 2017, 10:32:37 AM9/1/17
to WebGL Dev List
Hi Mobeen,

I've looked at the references you suggested but I still haven't got my head around the shadowShader.getProgram() in Listing 17.5 and the volumeShader.getProgram() in Listing 17.7.

This is different to the way I usually create and use a shader program.
I would normally just use gl.useProgram(shaderProgram) with shaderProgram defined as follows...

var fragmentShader = createShader(gl, document.getElementById("fShader").innerHTML, "fragment");
var vertexShader = createShader(gl, document.getElementById("vShader").innerHTML, "vertex");
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertexShader);
gl.attachShader(shaderProgram, fragmentShader);
gl.linkProgram(shaderProgram);

Is the shadowShader code described in Listings 17.12 and 17.13?
Where can I find the volumeShader code?

Best wishes,

Bob
Reply all
Reply to author
Forward
0 new messages