Trying to add a custom rendering in JumpyJet


#1

To learn Xenko, I try to add a custom rendering in Jympyjet sample.

First I changed the configuration of GraphicsCompositor: CameraRender’s child is a SceneRenderingCollection, so that I can add my own Renderer there, beside JumpyJetRenderer

Then I create my script, with super basic drawing:

Then I added an entity to the scene that contains my script.

My problem :
My custom rendering (MJScript.Draw) is drawn BEHIND JumpyJetRenderer’s drawing. I can see it only if I remove all the background drawing of JumpyJetRenderer.

What do I do wrong?


#2

There is no answer, is it too trivial (not for me) or too hard?
Not well explained?


#3

The reason your renderer is rendering “behind” the JumpyJetRenderer is because the default depth for the SpriteBatch.Draw methods is 0. 0 being the closest to the “camera”/“screen” the bigger the number the further back it is. The JumpyJetRenderer appears to user depth 0,1, and 2. which means you can’t get in front of it. I won’t get into how depth stencils work. But you have several options, two of which you could just copy & paste:

  • Change the JumpyJetRenderer so the depth is further back. Have a look at the Pal0Depth etc. constants.
  • Change your renderer so it clears the depth buffer. Meaning nothing previously drawn (this frame) will be “in front”.
rdc.CommandList.Clear(rdc.CommandList.DepthStencilBuffer, DepthStencilClearOptions.DepthBuffer);
  • Change your renderer so the spriteBatch “ignores” depth.
spriteBatch.Begin(rdc.GraphicsContext, depthStencilState: DepthStencilStates.None);
  • Change your composition so it takes care of the depth for you. You can do “layering”. I have only done this for built in render features. Not sure best way to go about it for your current situation. Above options probably easier.