x3dom / x3dom

X3DOM. A framework for integrating and manipulating X3D scenes as HTML5/DOM elements.
http://x3dom.org
Other
825 stars 275 forks source link

OpacityMapVolumeStyle with PointLight fails #808

Open andreasplesch opened 6 years ago

andreasplesch commented 6 years ago

There is a FragmentShader error:

ERROR: [ComposedShader] FragmentShader 
ERROR: 0:116: 'grad' : undeclared identifier 
ERROR: 0:116: 'xyz' : field selection requires structure or vector on left hand side 
ERROR: 0:116: 'lighting' : no matching overloaded function found 

I believe this is due to setting this.surfaceNormalsNeeded to false here: https://github.com/x3dom/x3dom/blob/master/src/nodes/VolumeRendering/VolumeData.js#L72 although when there are lights the shader lighting function does need surface normals.

Perhaps add an additional condition x3dom.nodeTypes.X3DLightNode.lightID==0 before setting this.surfaceNormalsNeeded to false ?

I will add a light to volrenOpacityTestTF_aorta.xhtml to demonstrate.

aarbelaiz commented 6 years ago

Consider using the shaded volume style and compose with the opacity map volume style for lightning.

If you have an x3d scene that does broke when a light is added to the scene then share it so that i can take a look...

Specwise the opacity map volume style does not have to support lightning by its own. So if a light is added to the scene it could be ignored.

El 30 dic. 2017 6:44 p. m., "Andreas Plesch" notifications@github.com escribió:

There is a FragmentShader error:

ERROR: [ComposedShader] FragmentShader ERROR: 0:116: 'grad' : undeclared identifier ERROR: 0:116: 'xyz' : field selection requires structure or vector on left hand side ERROR: 0:116: 'lighting' : no matching overloaded function found

I believe this is due to setting this.surfaceNormalsNeeded to false here: https://github.com/x3dom/x3dom/blob/master/src/nodes/VolumeR endering/VolumeData.js#L72 although when there are lights the shader lighting function does need surface normals.

Perhaps add an additional condition x3dom.nodeTypes.X3DLightNode.lightID==0 before setting this.surfaceNormalsNeeded to false ?

I will add a light to volrenOpacityTestTF_aorta.xhtml to demonstrate.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/x3dom/x3dom/issues/808, or mute the thread https://github.com/notifications/unsubscribe-auth/ABEKN37QtZw6dq8WgLeXgRASQlHSaVwpks5tFnaAgaJpZM4RPpzq .

andreasplesch commented 6 years ago

Ok, here is the aorta opacity map style example modified to use a point light and with the proposed check:

https://x3dom-issue808.glitch.me/

original: https://x3dom-issue808.glitch.me/index.xhtml with light: https://x3dom-issue808.glitch.me/opacityPointLight.xhtml (see debug log, hm, only in firefox) with check in VolumeData: https://x3dom-issue808.glitch.me/opacityPointLight_needNormals.xhtml

There is an official example with OpacityMapVolumeStyle and PointLight: https://www.web3d.org/x3d/content/examples/Basic/VolumeRendering/BasicVentricles.html

Perhaps the PointLight is left over from the segmented example: https://www.web3d.org/x3d/content/examples/Basic/VolumeRendering/SegmentedVentricles.html

The lighting in the spec: http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/volume.html#Lighting

Not sure how that applies to OpacityMapVolumeStyle. So one option may be to completely ignore lights, eg. not include the loop over lights in the shader ?

H3DViewer supports volume rendering best, freeWrl 4.0 also does as well as InstantReality. They generally have a 'brighter' default rendering.

Here is my current test matrix for nrrd support:

https://x3d-volexamples.glitch.me/ https://x3d-volexamples.glitch.me/BasicVentricles_controls.xhtml