actor->SetBackfacePropertyを設定する。
//#include <vtkParametricMobius.h> //#include <vtkParametricFunctionSource.h> // メビウス vtkNew<vtkParametricMobius> mobius; mobius->SetRadius(5.0); const double halfWidth = 2.0; mobius->SetMinimumV(-halfWidth); mobius->SetMaximumV(+halfWidth); vtkNew<vtkParametricFunctionSource> parametricSource; parametricSource->SetParametricFunction(mobius); parametricSource->SetUResolution(100); parametricSource->SetVResolution(30); parametricSource->Update(); vtkNew<vtkPolyDataMapper> mapper; mapper->SetInputConnection(parametricSource->GetOutputPort()); vtkNew<vtkActor> actor; actor->SetMapper(mapper);
// 表裏色設定 actor->GetProperty()->SetColor(1.0, 0.0, 0.0); // 表 vtkNew<vtkProperty> backProp; backProp->SetColor(0.0, 1.0, 0.0); // 裏 actor->SetBackfaceProperty(backProp);

フラグメントシェーダを置換する方法でもできる。
// カスタムシェーダ適用 actor->GetProperty()->ShadingOn(); actor->GetProperty()->SetInterpolationToPhong(); vtkShaderProperty* shaderProperty = actor->GetShaderProperty(); // フラグメントシェーダにコードを追加 shaderProperty->AddFragmentShaderReplacement( "//VTK::Light::Impl", // 挿入位置(照明計算の後) false, // 前のコードを置換 R"( vec3 faceTint2 = gl_FrontFacing ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0); fragOutput0 = vec4(faceTint2, 1.0) * fragOutput0; )", false );