Immediate Mode Doesn't Work with Pixel Perfect Camera

Avatar
  • updated
  • Unity's Fault

If I disable my 2D Pixel Perfect Camera component, then I see my immediate mode shapes appear correctly. When I enable Pixel Perfect Camera, the immediate mode shapes disappear.


Non-immediate mode shapes render correctly in all scenarios - this issue is only with immediate mode shapes.

I originally tried using Unity's GL.Lines method and experienced the same problem (I raised a bug with them). I was hoping Shapes would solve my problem. Is the issue with Unity itself?

Reporting a bug? please specify Unity version:
2021.1.0b6 (4f6b2ade48ff)
Reporting a bug? please specify Shapes version:
3.0.0
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Unity's Fault

this is likely an issue with the way the pixel perfect camera works - so it seems to be a Unity bug yeah :c

it seems to:
• cache the buffer at ResolveColor
• then Shapes draws (Shapes Draw Command)
• then it reapplies the old ResolveColor state in Camera.ImageEffects.DrawDynamic, so anything that was drawn in between gets discarded.

I imagine GL.Lines has the same issue because it happens between these steps too :(





Edit: Actually, this is a specific issue when called at the camera event BeforeImageEffects, if you instead use AfterForwardAlpha it seems to work :)

using( Draw.Command( cam, CameraEvent.AfterForwardAlpha ) ) {
    // ...
}

(this is still a Unity bug though, before image effects should absolutely work, but it doesn't)

Avatar
Freya Holmér creator
  • Answer
  • Unity's Fault

this is likely an issue with the way the pixel perfect camera works - so it seems to be a Unity bug yeah :c

it seems to:
• cache the buffer at ResolveColor
• then Shapes draws (Shapes Draw Command)
• then it reapplies the old ResolveColor state in Camera.ImageEffects.DrawDynamic, so anything that was drawn in between gets discarded.

I imagine GL.Lines has the same issue because it happens between these steps too :(





Edit: Actually, this is a specific issue when called at the camera event BeforeImageEffects, if you instead use AfterForwardAlpha it seems to work :)

using( Draw.Command( cam, CameraEvent.AfterForwardAlpha ) ) {
    // ...
}

(this is still a Unity bug though, before image effects should absolutely work, but it doesn't)

Avatar
marcus r

Using the AfterForwardAlpha event works brilliantly. You're a legend, thanks Freya.