Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycles : Crash with interactive shader updates on subdiv meshes #4913

Open
murraystevenson opened this issue Oct 14, 2022 · 6 comments
Open

Comments

@murraystevenson
Copy link
Contributor

Description

Editing shader parameters on a subdiv mesh while interactively rendering can crash Cycles.

Steps to reproduce

  1. Open the scene below
  2. Switch to the Cycles viewport.
  3. Turn on full shading.
  4. Use the virtual slider to rapidly edit the shader's emission.r parameter.
  5. Enable the MeshType node.
  6. Use the virtual slider to again rapidly edit the shader's emission.r parameter.
  7. Cycles should quickly crash.

Debug log

Click to Expand

import Gaffer
import GafferCycles
import GafferScene
import IECore
import imath

Gaffer.Metadata.registerValue( parent, "serialiser:milestoneVersion", 1, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:majorVersion", 2, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:minorVersion", 0, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:patchVersion", 0, persistent=False )

__children = {}

__children["Sphere"] = GafferScene.Sphere( "Sphere" )
parent.addChild( __children["Sphere"] )
__children["Sphere"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["MeshType"] = GafferScene.MeshType( "MeshType" )
parent.addChild( __children["MeshType"] )
__children["MeshType"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["PathFilter"] = GafferScene.PathFilter( "PathFilter" )
parent.addChild( __children["PathFilter"] )
__children["PathFilter"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["principled_bsdf"] = GafferCycles.CyclesShader( "principled_bsdf" )
parent.addChild( __children["principled_bsdf"] )
__children["principled_bsdf"].loadShader( "principled_bsdf" )
__children["principled_bsdf"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["ShaderAssignment"] = GafferScene.ShaderAssignment( "ShaderAssignment" )
parent.addChild( __children["ShaderAssignment"] )
__children["ShaderAssignment"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["Sphere"]["__uiPosition"].setValue( imath.V2f( -9.03114128, 27.5871067 ) )
__children["MeshType"]["enabled"].setValue( False )
__children["MeshType"]["in"].setInput( __children["Sphere"]["out"] )
__children["MeshType"]["filter"].setInput( __children["PathFilter"]["out"] )
__children["MeshType"]["meshType"].setValue( 'catmullClark' )
__children["MeshType"]["__uiPosition"].setValue( imath.V2f( -9.03028107, 19.4230461 ) )
__children["PathFilter"]["paths"].setValue( IECore.StringVectorData( [ '/sphere' ] ) )
__children["PathFilter"]["__uiPosition"].setValue( imath.V2f( 3.96971893, 25.5050774 ) )
__children["principled_bsdf"]["__uiPosition"].setValue( imath.V2f( -30.9004307, 11.2589846 ) )
__children["ShaderAssignment"]["in"].setInput( __children["MeshType"]["out"] )
__children["ShaderAssignment"]["filter"].setInput( __children["PathFilter"]["out"] )
__children["ShaderAssignment"]["shader"].setInput( __children["principled_bsdf"]["out"]["BSDF"] )
__children["ShaderAssignment"]["__uiPosition"].setValue( imath.V2f( -9.03028107, 11.2589836 ) )


del __children


@boberfly
Copy link
Collaborator

boberfly commented Nov 2, 2022

Hey @murraystevenson

I've not been too happy with Cycles' subdivision code in-general and found that it isn't very reliable at all and need to revert to using MeshType - linear to get stability back.

One thing I'm going to propose back to the Cycles devs is to just use Embree's subdivision code. They probably won't accept it as it'll be CPU-only initially but by the reports of the Intel devs, the next Embree release will allow GPU support and not just for their Arc line of GPUs but other vendors as well. No idea how this plays with OptiX though but this should be something that Blender should solve.

The other option is we just use OpenSubdiv under the hood and call it a day?

@johnhaddon
Copy link
Member

I've not been too happy with Cycles' subdivision code in-general and found that it isn't very reliable at all and need to revert to using MeshType - linear to get stability back.

Is this true in general for Cycles users outside of Gaffer? Do they all avoid Cycles' adaptive subdivision and use Blender's pre-render uniform subdivision instead?

@boberfly
Copy link
Collaborator

boberfly commented Nov 6, 2022

I've not been too happy with Cycles' subdivision code in-general and found that it isn't very reliable at all and need to revert to using MeshType - linear to get stability back.

Is this true in general for Cycles users outside of Gaffer? Do they all avoid Cycles' adaptive subdivision and use Blender's pre-render uniform subdivision instead?

Good question - I am only going by what @skwerner was telling me that is notorious for being buggy in Blender when using it live from the viewport and I think motion blur but my memory is fuzzy on the details.

@boberfly
Copy link
Collaborator

boberfly commented Dec 4, 2022

Here's the tracker for adaptive subdivision, seems like it hasn't got much attention:
https://developer.blender.org/T53901

johnhaddon added a commit to johnhaddon/dependencies that referenced this issue Feb 7, 2023
This isn't especially necessary as far as we know, but I thought it was worth being on the latest patch version while we're still trying to track down the odd [Cycles crash](GafferHQ/gaffer#4913). Alas in this case it did not help.
johnhaddon added a commit to johnhaddon/dependencies that referenced this issue Feb 7, 2023
This isn't stricly necessary, but it seems worth getting the latest bug fixes while we are still hunting the cause of GafferHQ/gaffer#4913. Alas, it does not help.
johnhaddon added a commit to johnhaddon/dependencies that referenced this issue Feb 9, 2023
This isn't especially necessary as far as we know, but I thought it was worth being on the latest patch version while we're still trying to track down the odd [Cycles crash](GafferHQ/gaffer#4913). Alas in this case it did not help.
johnhaddon added a commit to johnhaddon/dependencies that referenced this issue Feb 9, 2023
This isn't stricly necessary, but it seems worth getting the latest bug fixes while we are still hunting the cause of GafferHQ/gaffer#4913. Alas, it does not help.
@johnhaddon
Copy link
Member

Some more details :

  • The crash appears to be in Cycles, somewhere in the BVH build. We don't really want to be doing a BVH build just for a parameter change.
  • If instead of changing emission above, you change the sphere radius, then it doesn't crash. Even though changing the radius is presumably also triggering a BVH build.

Not sure what this means, but to my mind it makes it more likely that the problem is on our side.

@johnhaddon
Copy link
Member

Well, the crash is sometimes in the BVH build. Sometimes it is in OSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants