Skip to content

Commit 6b70e4c

Browse files
committed
fix(volume shader): fix light sphere bound, decrease anisotropy threashold, spelling
1 parent 3b60706 commit 6b70e4c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

Examples/Volume/VolumeMapperLightAndShadow/controller.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
</td>
2222
</tr>
2323
<tr>
24-
<td>Anistropy</td>
24+
<td>Anisotropy</td>
2525
<td>
26-
<input class='anistropy' type="range" min="-1.0" max="1.0" step="0.1" value="0.0" />
26+
<input class='anisotropy' type="range" min="-1.0" max="1.0" step="0.05" value="0.0" />
2727
</td>
2828
</tr>
2929
</table>

Examples/Volume/VolumeMapperLightAndShadow/index.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function createVolumeShadowViewer(rootContainer, fileContents) {
228228
sd.setAttribute('max', 10);
229229
sd.setAttribute('value', 5);
230230
sd.addEventListener('input', updateSD);
231-
const at = document.querySelector('.anistropy');
231+
const at = document.querySelector('.anisotropy');
232232
at.setAttribute('min', -1.0);
233233
at.setAttribute('max', 1.0);
234234
at.setAttribute('value', 0.0);
@@ -257,19 +257,12 @@ function createVolumeShadowViewer(rootContainer, fileContents) {
257257
actorSphere.getProperty().setColor([1, 0, 0]);
258258
actorSphere.getProperty().setLighting(false);
259259
actorSphere.setMapper(mapperSphere);
260+
actorSphere.setUseBounds(false);
260261
renderer.addActor(actorSphere);
261262
}
262263

263264
// Camera and first render
264265
renderer.resetCamera();
265-
renderer
266-
.getActiveCamera()
267-
.setFocalPoint(center[0] - 300, center[1] + 120, center[2] + 100);
268-
renderer.getActiveCamera().setClippingRange([300, 1800]);
269-
renderer
270-
.getActiveCamera()
271-
.setPosition(center[0] + 650, center[1] + 10, center[2] - 200);
272-
renderer.getActiveCamera().setViewUp(0, 0, -1);
273266
renderWindow.render();
274267

275268
// Make some variables global so that you can inspect and

Sources/Rendering/Core/VolumeMapper/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function vtkVolumeMapper(publicAPI, model) {
8484
publicAPI.modified();
8585
};
8686

87-
publicAPI.setVlumeShadowSamplingDistFactor = (vsdf) => {
87+
publicAPI.setVolumeShadowSamplingDistFactor = (vsdf) => {
8888
model.volumeShadowSamplingDistFactor = vsdf >= 1.0 ? vsdf : 1.0;
8989
publicAPI.modified();
9090
};
@@ -112,8 +112,8 @@ const DEFAULT_VALUES = {
112112
preferSizeOverAccuracy: false, // Whether to use halfFloat representation of float, when it is inaccurate
113113
computeNormalFromOpacity: false,
114114
// volume shadow parameters
115-
globalIlluminationReach: 0.0,
116115
volumetricScatteringBlending: 0.0,
116+
globalIlluminationReach: 0.0,
117117
volumeShadowSamplingDistFactor: 5.0,
118118
anisotropy: 0.0,
119119
};
@@ -134,8 +134,8 @@ export function extend(publicAPI, model, initialValues = {}) {
134134
'filterMode',
135135
'preferSizeOverAccuracy',
136136
'computeNormalFromOpacity',
137-
'globalIlluminationReach',
138137
'volumetricScatteringBlending',
138+
'globalIlluminationReach',
139139
'volumeShadowSamplingDistFactor',
140140
'anisotropy',
141141
]);

Sources/Rendering/OpenGL/glsl/vtkVolumeFS.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ vec3 applyShadowRay(vec3 tColor, vec3 posIS, vec3 viewDirectionVC)
727727
float dDotL = dot(viewDirectionVC, normalize(vertLight));
728728
// isotropic scatter returns 0.5 instead of 1/4pi to increase intensity
729729
float phase_attenuation = 0.5;
730-
if (abs(anisotropy) > 0.01){
730+
if (abs(anisotropy) > EPSILON){
731731
phase_attenuation = phase_function(dDotL);
732732
}
733733
float vol_shadow = volume_shadow(posIS, normalize(rotateToIDX(vertLight)));

0 commit comments

Comments
 (0)