Skip to content

Commit c60d2b8

Browse files
committed
Fixes for adaptive subdivision. Looks like normal maps on adaptive subdivided meshes doesn't work: https://developer.blender.org/T49159
1 parent dbddb52 commit c60d2b8

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/GafferCycles/CyclesAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ CyclesAttributes::CyclesAttributes( const std::string &name )
6161
attributes->addChild( new Gaffer::NameValuePlug( "ccl:is_shadow_catcher", new IECore::BoolData( false ), false, "isShadowCatcher" ) );
6262

6363
// Subdivision parameters
64-
attributes->addChild( new Gaffer::NameValuePlug( "ccl:max_level", new IECore::IntData( 12 ), false, "maxLevel" ) );
64+
attributes->addChild( new Gaffer::NameValuePlug( "ccl:max_level", new IECore::IntData( 1 ), false, "maxLevel" ) );
6565
attributes->addChild( new Gaffer::NameValuePlug( "ccl:dicing_rate", new IECore::FloatData( 1.0f ), false, "dicingScale" ) );
6666

6767
// Color

src/GafferCycles/IECoreCyclesPreview/MeshAlgo.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,21 +609,36 @@ ccl::Mesh *convertCommon( const IECoreScene::MeshPrimitive *mesh )
609609

610610
// TODO: Maybe move this to attibutes so it can be shared between meshes?
611611
if( ( subdivision ) && ( cmesh->subdivision_type != ccl::Mesh::SUBDIVISION_NONE ) && ( !cmesh->subd_params ) )
612+
{
612613
cmesh->subd_params = new ccl::SubdParams( cmesh );
614+
cmesh->subd_params->test_steps = 1;
615+
cmesh->subd_params->split_threshold = 1;
616+
cmesh->subd_params->dicing_rate = 1.0f;
617+
cmesh->subd_params->max_level = 1;
618+
cmesh->subd_params->camera = NULL;
619+
}
613620

614621
// Primitive Variables are Attributes in Cycles
615622
ccl::AttributeSet& attributes = (subdivision) ? cmesh->subd_attributes : cmesh->attributes;
616623

617624
// Convert Normals
618625
PrimitiveVariable::Interpolation nInterpolation = PrimitiveVariable::Invalid;
619-
if( !triangles )
626+
if( ( !triangles ) && ( mesh->interpolation() == "catmullClark" ) )
627+
{
628+
if( const V3fVectorData *normals = normal( mesh, nInterpolation ) )
629+
{
630+
ccl::Attribute *attr_N = attributes.add( nInterpolation == PrimitiveVariable::Uniform ? ccl::ATTR_STD_FACE_NORMAL : ccl::ATTR_STD_VERTEX_NORMAL, ccl::ustring("N") );
631+
convertN( mesh, normals, attr_N, nInterpolation );
632+
}
633+
}
634+
else if( !triangles )
620635
{
621636
if( const V3fVectorData *normals = normal( trimesh.get(), nInterpolation ) )
622637
{
623638
ccl::Attribute *attr_N = attributes.add( nInterpolation == PrimitiveVariable::Uniform ? ccl::ATTR_STD_FACE_NORMAL : ccl::ATTR_STD_VERTEX_NORMAL, ccl::ustring("N") );
624639
convertN( trimesh.get(), normals, attr_N, nInterpolation );
625640
}
626-
else if( mesh->interpolation() != "catmullClark" )
641+
else
627642
{
628643
IECoreScene::MeshNormalsOpPtr normalOp = new IECoreScene::MeshNormalsOp();
629644
normalOp->inputParameter()->setValue( trimesh );

src/GafferCycles/IECoreCyclesPreview/Renderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ class CyclesAttributes : public IECoreScenePreview::Renderer::AttributesInterfac
12151215
m_visibility( ~0 ),
12161216
m_useHoldout( false ),
12171217
m_isShadowCatcher( false ),
1218-
m_maxLevel( 12 ),
1218+
m_maxLevel( 1 ),
12191219
m_dicingRate( 1.0f ),
12201220
m_color( Color3f( 0.0f ) ),
12211221
m_dupliGenerated( V3f( 0.0f ) ),

0 commit comments

Comments
 (0)