GafferHQ / gaffer

Gaffer is a node-based application for lookdev, lighting and automation
http://www.gafferhq.org
BSD 3-Clause "New" or "Revised" License
943 stars 205 forks source link

VDB volume transparency using raytraced viewport #4783

Open lucienfostier opened 2 years ago

lucienfostier commented 2 years ago

Version: Gaffer 1.0.2.1-linux (e.g. 0.47.0.0-linux) Third-party tools: List any third-party tools in use (e.g. Arnold, Tractor) Third-party modules: List any third-party Gaffer modules in use (e.g. proprietary plugins)

Description

Am I missing something or the volume rendering transparency has an issue with the raytraced viewport using Arnold

Steps to reproduce

You should download the following vdb file:

https://artifacts.aswf.io/io/aswf/openvdb/models/explosion.vdb/1.0.0/explosion.vdb-1.0.0.zip

Click to Expand

``` import Gaffer import GafferArnold import GafferOSL import GafferScene import IECore import imath Gaffer.Metadata.registerValue( parent, "serialiser:milestoneVersion", 1, persistent=False ) Gaffer.Metadata.registerValue( parent, "serialiser:majorVersion", 0, persistent=False ) Gaffer.Metadata.registerValue( parent, "serialiser:minorVersion", 2, persistent=False ) Gaffer.Metadata.registerValue( parent, "serialiser:patchVersion", 1, persistent=False ) __children = {} __children["SceneReader"] = GafferScene.SceneReader( "SceneReader" ) parent.addChild( __children["SceneReader"] ) __children["SceneReader"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["ShaderAssignment3"] = GafferScene.ShaderAssignment( "ShaderAssignment3" ) parent.addChild( __children["ShaderAssignment3"] ) __children["ShaderAssignment3"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["StandardVolume"] = GafferArnold.ArnoldShader( "StandardVolume" ) parent.addChild( __children["StandardVolume"] ) __children["StandardVolume"].loadShader( "standard_volume" ) __children["StandardVolume"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Group2"] = GafferScene.Group( "Group2" ) parent.addChild( __children["Group2"] ) __children["Group2"]["in"].addChild( GafferScene.ScenePlug( "in1", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Group2"]["in"].addChild( GafferScene.ScenePlug( "in2", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Group2"]["in"].addChild( GafferScene.ScenePlug( "in3", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Group2"]["in"].addChild( GafferScene.ScenePlug( "in4", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Group2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["DistantLight1"] = GafferArnold.ArnoldLight( "DistantLight1" ) parent.addChild( __children["DistantLight1"] ) __children["DistantLight1"].loadShader( "distant_light" ) __children["DistantLight1"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Plane1"] = GafferScene.Plane( "Plane1" ) parent.addChild( __children["Plane1"] ) __children["Plane1"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Transform"] = GafferScene.Transform( "Transform" ) parent.addChild( __children["Transform"] ) __children["Transform"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["Dot"] = Gaffer.Dot( "Dot" ) parent.addChild( __children["Dot"] ) __children["Dot"].setup( GafferScene.FilterPlug( "in", defaultValue = 0, minValue = 0, maxValue = 7, flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.AcceptsDependencyCycles, ) ) __children["Dot"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["ShaderAssignment4"] = GafferScene.ShaderAssignment( "ShaderAssignment4" ) parent.addChild( __children["ShaderAssignment4"] ) __children["ShaderAssignment4"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["PathFilter2"] = GafferScene.PathFilter( "PathFilter2" ) parent.addChild( __children["PathFilter2"] ) __children["PathFilter2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["StandardSurface2"] = GafferArnold.ArnoldShader( "StandardSurface2" ) parent.addChild( __children["StandardSurface2"] ) __children["StandardSurface2"].loadShader( "standard_surface" ) __children["StandardSurface2"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["PathFilter3"] = GafferScene.PathFilter( "PathFilter3" ) parent.addChild( __children["PathFilter3"] ) __children["PathFilter3"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) ) __children["SceneReader"]["fileName"].setValue( '/home/lucienf/Downloads/explosion.vdb-1.0.0/explosion.vdb' ) __children["SceneReader"]["transform"]["rotate"].setValue( imath.V3f( 0, -86.4064255, 0 ) ) __children["SceneReader"]["__uiPosition"].setValue( imath.V2f( -29.6163883, -126.518898 ) ) __children["ShaderAssignment3"]["in"].setInput( __children["Transform"]["out"] ) __children["ShaderAssignment3"]["filter"].setInput( __children["Dot"]["out"] ) __children["ShaderAssignment3"]["shader"].setInput( __children["StandardVolume"]["out"] ) __children["ShaderAssignment3"]["__uiPosition"].setValue( imath.V2f( -29.6163883, -138.929474 ) ) __children["StandardVolume"]["parameters"]["density"].setValue( 10.0 ) __children["StandardVolume"]["parameters"]["scatter"].setValue( 100.0 ) __children["StandardVolume"]["parameters"]["scatter_color"].setValue( imath.Color3f( 0.5, 0.120000005, 0.120000005 ) ) __children["StandardVolume"]["parameters"]["scatter_color_channel"].setValue( 'density' ) __children["StandardVolume"]["__uiPosition"].setValue( imath.V2f( -47.5845718, -132.371429 ) ) __children["Group2"]["in"][0].setInput( __children["ShaderAssignment3"]["out"] ) __children["Group2"]["in"][1].setInput( __children["DistantLight1"]["out"] ) __children["Group2"]["in"][3].setInput( __children["ShaderAssignment4"]["out"] ) __children["Group2"]["__uiPosition"].setValue( imath.V2f( -10.5079784, -171.123505 ) ) __children["DistantLight1"]["name"].setValue( 'distantLight' ) __children["DistantLight1"]["transform"]["translate"].setValue( imath.V3f( 1, 0, 0 ) ) __children["DistantLight1"]["transform"]["rotate"].setValue( imath.V3f( -79.7880173, 44.3048859, -52.619751 ) ) __children["DistantLight1"]["parameters"]["exposure"].setValue( 2.0999999046325684 ) __children["DistantLight1"]["__uiPosition"].setValue( imath.V2f( -13.5079784, -150.657944 ) ) __children["Plane1"]["transform"]["rotate"].setValue( imath.V3f( -33, 0, 0 ) ) __children["Plane1"]["dimensions"]["x"].setValue( 10.0 ) __children["Plane1"]["dimensions"]["y"].setInput( __children["Plane1"]["dimensions"]["x"] ) __children["Plane1"]["__uiPosition"].setValue( imath.V2f( 29.20854, -133.072037 ) ) __children["Transform"]["in"].setInput( __children["SceneReader"]["out"] ) __children["Transform"]["filter"].setInput( __children["Dot"]["out"] ) __children["Transform"]["transform"]["scale"]["x"].setValue( 0.009999999776482582 ) __children["Transform"]["transform"]["scale"]["y"].setInput( __children["Transform"]["transform"]["scale"]["x"] ) __children["Transform"]["transform"]["scale"]["z"].setInput( __children["Transform"]["transform"]["scale"]["x"] ) __children["Transform"]["__uiPosition"].setValue( imath.V2f( -29.6163883, -133.265427 ) ) __children["Dot"]["in"].setInput( __children["PathFilter3"]["out"] ) __children["Dot"]["__uiPosition"].setValue( imath.V2f( -12.091136, -131.38945 ) ) __children["ShaderAssignment4"]["in"].setInput( __children["Plane1"]["out"] ) __children["ShaderAssignment4"]["filter"].setInput( __children["PathFilter2"]["out"] ) __children["ShaderAssignment4"]["shader"].setInput( __children["StandardSurface2"]["out"] ) __children["ShaderAssignment4"]["__uiPosition"].setValue( imath.V2f( 27.6904945, -149.078354 ) ) __children["PathFilter2"]["paths"].setValue( IECore.StringVectorData( [ '*' ] ) ) __children["PathFilter2"]["__uiPosition"].setValue( imath.V2f( 48.1907463, -142.327728 ) ) __children["StandardSurface2"]["__uiPosition"].setValue( imath.V2f( 5.94045544, -149.078354 ) ) __children["PathFilter3"]["paths"].setValue( IECore.StringVectorData( [ '*' ] ) ) __children["PathFilter3"]["__uiPosition"].setValue( imath.V2f( -12.091136, -119.094452 ) ) del __children ```

https://user-images.githubusercontent.com/770272/183586029-cec4a1b1-e19a-4524-968f-4a08e1b0e949.mp4

johnhaddon commented 2 years ago

I don't think you're missing anything - this is a known problem. I think the alpha from the volume is actually OK, but Arnold doesn't output a depth for it at all, which means it disappears when we use the depth buffer to integrate the Arnold and the GL views. When you add the plane in behind, the plane appears in the depth buffer and everything starts to work.

We might be able to work around this to some extent by allowing an infinite-depth pixel from Arnold to beat an infinite-depth pixel from OpenGL. And there is also a second Arnold AOV which I believe provides only the depth from volumes. But in an ideal world Arnold would provide a single depth AOV suitable for this purpose.

lucienfostier commented 2 years ago

Thanks for the explaination!

Is there a chance it would be working better with Cycles?

johnhaddon commented 2 years ago

It's certainly possible that it would work better with Cycles, but I don't know at this point.