f3d
f3d copied to clipboard
Add an option to control opacity curve for volume rendering
Is your feature request related to a problem? Please describe.
F3D supports volume rendering of volumic mesh, with a color map and opacity curve.
The colop map can be controlled but the opacity curve is only a linear curve, that can be inverted with --volume-inverse.
It would be nice to have more control on the opacity curve.
Describe the solution you'd like
Add a CLI option to control the opacity map, eg:
--volume-opacity-map=value,opacity,value2,opacity2 and
--volume-opacity-file=/path/to/opacity_map.png
Similar to the --colormap and --colormap-file options.
Additional context Unable to achieve rendering like this in F3D:
Original issue
Hi
Thanks for the good software.
Is there a way to turn off the above? As my understanding, it is related to the shading, right? I could not find anywhere in the code where to turn off shading.
For my data, I dont want to see the reflection from other surfaces because they changed the surface color of my objects. I tried modifying roughness and metallic, but I saw no changes.
Regards, Lam
Hi,
This is possible as long as you use F3D >= 3.0 with the roughness. metallic also has an effect.
./bin/f3d ../../f3d/src/testing/data/WaterBottle.glb
./bin/f3d ../../f3d/src/testing/data/WaterBottle.glb --roughness=0
Closing this as there is no issues to fix :)
By the way you can ask such questions on our discord: https://discord.f3d.app
Thanks for answering.
Unfortunately, that did not address the reflection from surrounding objects. See below, the top sphere should be completely white, not orange. The screenshot was made with --roughness=0 and version 3.0
This is not a reflection, you are using volume rendering with the component 0 Tiff Scalars array.
The scalar value is just higher in the up sphere.
If you color with another component you will get another rendering:
./bin/f3d ~/data/tmp/3D\ Spheres.tif -v --coloring-component=2
Thanks for checking. Sorry my explanation was bad. Let me explain it in details.
I created these 4 spheres to show that in my case (volume rendering), even after roughness=0, the color of one object (in this case, the rightmost white sphere) is contaminated with others (the white became orange-ish from the orange/red color of the other 3 spheres).
Data: 3D grey-value TIFF file. Top sphere: 150, right sphere: 255, the other two: 75. Please use this new attached data. My old file above was not grey 8-bit but RGB.
What I want: the color of the right sphere (255) should be completely white, without reflection from others. Am I misunderstanding anything in volume rendering?
Please note roughness has no effect on volume rendering at all.
I'm afraid what you are seeing has nothing to do with lighting but with the way interpolation and volume rendering works in VTK. In short, even though you are defining hard frontiers in your data from one point to another ( 0 -> 255), there is interpolation between values when the data is being recovered. On the frontier, VTK consider that the data goes from 0 to 255 in a linear way, and the volume rendering shows that.
The usual workaround is to use the opacity function with hard edges as well to hide this, however this opacity function cannot be controlled in F3D, it can only be inverted.
There is much finer control in ParaView, let me demonstrate:
Here we see the same redering as F3D exactly, as you can see on the right, the opacity function is just a line:
If I modify the curve to have hard edges I can get this:
Or even this:
Although the last one is not perfect, because the lower peak of visibility actually have a small impact on the higher ones.
So what you see is just an expected results of the volume rendering.
There is one issue we can fix in F3D though, which is the possibility to specificy the opacity curve for volume rendering, which would let you get the result I shared above in F3D. Is that what you want to be able to do ?
Yes, thank you very much for your clarification. Now I know that I need the opacity curve for volume rendering. Is it possible to specify the opacity curve similar to providing a colormap file in F3D?
Thanks a lot.
Is it possible to specify the opacity curve similar to providing a colormap file in F3D?
I'm afraid not yet. I can reopen this issue so that it becomes something along the lines of:
"Add an option to provide opacity curve for volume rendering"
Maybe it will be adressed in the coming months. If you are a developer, you can add it yourself!
Does that sound good to you ?
Thanks, that sounds good for me. Unfortunately, I'm not a C++ developer (yet).
I've updated the issue
I have some experience with volume rendering, i can start looking into this.