Graphic3d_TOSM_PBR No working the same between 7.5.0 to 7.6.0

Hello,
I can't toggle anymore between Graphic3d_TOSM_PBR and Graphic3d_TOSM_FRAGMENT by simply changing value Graphic3d_RenderingMode::ShadingModel and updating the view 3d (V3d_View::Redraw() ), has something change between 7.5.0 and 7.6.0 in that regards?

In 7.6.0, if I start my application with Graphic3d_TOSM_PBR active it work, but I can't toggle off Graphic3d_TOSM_PBR. If I start my application with Graphic3d_TOSM_FRAGMENT I can't toggle Graphic3d_TOSM_PBR.

In the attached picture you can see rendering in 7.5.0 (left) and in 7.6.0 (right)

Best regards,
François.

Attachments: 
Kirill Gavrilov's picture

So what are the question / steps to reproduce?

Francois Lauzon's picture

Sorry the question wasn't post initially, now it is.

Francois Lauzon's picture

Ok, I just found what I need to do now, I have to call V3d_View::Update() instead of just V3d_View::Redraw().
Now I can toggle on/off.

Kirill Gavrilov's picture

V3d_View::Update() is for handling a legacy V3d_View::ComputedMode() - it should be irrelevant to shading model changes and V3d_View::Redraw() should be enough. So observed disparity looks weird and unexpected. I guess you are setting Shading Model to V3d_View::SetShadingModel()?

Francois Lauzon's picture

You're right, V3d_View::Redraw() is enough if done properly!

What I was doing (and it was working in 7.5.0) was:
1. first getting Graphic3d_RenderingParams from the V3d_View
2. use V3d_View::SetShadingModel()
3. update rendering params and settings them back V3d_View::ChangeRenderingParams()=newParams;
4. V3d_View::Redraw()

I notice that Graphic3d_RenderingParams also has information about the ShadingModel so I guess the change wasn't applied.

Now I reordered the steps and everything is working:
1. use V3d_View::SetShadingModel()
2. getting Graphic3d_RenderingParams from the V3d_View (with the updated Graphic3d_RenderingParams::ShadingModel)
3. update rendering params and settings them back V3d_View::ChangeRenderingParams()=newParams;
4. V3d_View::Redraw()

Thanks,
François.

Kirill Gavrilov's picture

I see now how it might become wrong. Indeed, in OCCT 7.6.0 shading model has been moved to Graphic3d_RenderingParams::ShadingModel property, so that V3d_View::SetShadingModel() setter has been preserved for backward compatibility.

As you already modify Graphic3d_RenderingParams, it is better setting shading model there to avoid ambiguity in logic.

Francois Lauzon's picture

In that case I needed to call V3d_View::Update() to make it work.

Kirill Gavrilov's picture

Why is that? Instead of

1. use V3d_View::SetShadingModel()
2. getting Graphic3d_RenderingParams from the V3d_View (with the updated Graphic3d_RenderingParams::ShadingModel)
3. update rendering params and settings them back V3d_View::ChangeRenderingParams()=newParams;
4. V3d_View::Redraw()

Just do

1. getting Graphic3d_RenderingParams from the V3d_View
2. set Graphic3d_RenderingParams::ShadingModel to required state
3. update other rendering params and settings them back V3d_View::ChangeRenderingParams()=newParams;
4. V3d_View::Redraw()

That would be exactly the same thing as V3d_View::SetShadingModel() does - there is no extra logic in it, just changing a single field Graphic3d_RenderingParams::ShadingModel:

void Graphic3d_CView::SetShadingModel (Graphic3d_TypeOfShadingModel theModel)
{
  if (theModel == Graphic3d_TypeOfShadingModel_DEFAULT)
  {
    throw Standard_ProgramError ("Graphic3d_CView::SetShadingModel() - attempt to set invalid Shading Model!");
  }

  myRenderParams.ShadingModel = theModel;
}

I don't know why you prefer making a copy of entire structure Graphic3d_RenderingParams in your code - you may just take a reference V3d_View::ChangeRenderingParams() from the beginning to avoid mistakes.

Francois Lauzon's picture

You're right, by using Graphic3d_RenderingParams a along and just using redraw it is working.
Thanks for all the clarification Kirill,
François.