@@ -340,36 +340,41 @@ bool vtkF3DMetaImporter::Update()
340340
341341 // convert to PBR materials if needed
342342 // this should be moved elsewhere, see https://github.com/f3d-app/f3d/issues/2995
343- if (!genericImporter && actor->GetProperty ()->GetInterpolation () != VTK_PBR &&
344- actor->GetProperty ()->GetLighting ())
343+ if (!genericImporter && actor->GetProperty ()->GetInterpolation () != VTK_PBR )
345344 {
346- actor->GetProperty ()->SetInterpolationToPBR ();
347-
348- // Convert to linear space
349- auto toLinear = [](double c) { return std::pow (c, 2.2 ); };
350- double diffuseColor[3 ];
351- actor->GetProperty ()->GetColor (diffuseColor);
352- actor->GetProperty ()->SetColor (
353- toLinear (diffuseColor[0 ]), toLinear (diffuseColor[1 ]), toLinear (diffuseColor[2 ]));
354-
355- // restore diffuse/specular to 1 and ambient to 0
356- actor->GetProperty ()->SetSpecular (1.0 );
357- actor->GetProperty ()->SetDiffuse (1.0 );
358- actor->GetProperty ()->SetAmbient (0.0 );
359-
360- // texture diffuse is now base color
345+ // get texture
361346 vtkSmartPointer<vtkTexture> diffuseTex = actor->GetTexture ();
362347 if (!diffuseTex)
363348 {
364349 diffuseTex = actor->GetProperty ()->GetTexture (" diffuseTex" );
365350 }
366351 if (diffuseTex)
367352 {
368- actor->SetTexture (nullptr );
369353 diffuseTex->UseSRGBColorSpaceOn ();
354+ }
355+
356+ if (actor->GetProperty ()->GetLighting ())
357+ {
358+ actor->GetProperty ()->SetInterpolationToPBR ();
359+
360+ // Convert to linear space
361+ auto toLinear = [](double c) { return std::pow (c, 2.2 ); };
362+ double diffuseColor[3 ];
363+ actor->GetProperty ()->GetColor (diffuseColor);
364+ actor->GetProperty ()->SetColor (
365+ toLinear (diffuseColor[0 ]), toLinear (diffuseColor[1 ]), toLinear (diffuseColor[2 ]));
366+
367+ // restore diffuse/specular to 1 and ambient to 0
368+ actor->GetProperty ()->SetSpecular (1.0 );
369+ actor->GetProperty ()->SetDiffuse (1.0 );
370+ actor->GetProperty ()->SetAmbient (0.0 );
370371
371- actor->GetProperty ()->SetColor (1.0 , 1.0 , 1.0 );
372- actor->GetProperty ()->SetBaseColorTexture (diffuseTex);
372+ if (diffuseTex)
373+ {
374+ actor->SetTexture (nullptr );
375+ actor->GetProperty ()->SetColor (1.0 , 1.0 , 1.0 );
376+ actor->GetProperty ()->SetBaseColorTexture (diffuseTex);
377+ }
373378 }
374379 }
375380
0 commit comments