- Graphics::Rect2D scissorBox = {useScissorBox.x, useScissorBox.y, uint32_t(useScissorBox.width), uint32_t(useScissorBox.height)};
- commandBuffer.SetScissor(scissorBox);
+
+ Graphics::Viewport graphicsViewport = ViewportFromClippingBox(Uint16Pair{0, 0}, mViewportRectangle, 0);
+ commandBuffer.SetScissor(Rect2DFromClippingBox(useScissorBox, orientation, graphicsViewport));
+ }
+ }
+ else
+ {
+ // If there is render callback on the Renderer we need to calculate the scissor box and provide it to the
+ // callback so it may be clipped
+ if(item.mRenderer->GetRenderCallback())
+ {
+ // store clipping box inside the render callback input structure
+ auto& input = item.mRenderer->GetRenderCallbackInput();
+ input.clippingBox = ClippingBox(RenderItem::CalculateViewportSpaceAABB(item.mModelViewMatrix, Vector3::ZERO, item.mSize, mViewportRectangle.width, mViewportRectangle.height));