GPipe-Core icon indicating copy to clipboard operation
GPipe-Core copied to clipboard

Multiple actions in one `Render` monad

Open SwiftsNamesake opened this issue 7 years ago • 4 comments

Forgive me if this is covered by your tutorials, but it seems as though calling the same shader twice inside the same render call results in weird behaviour.

I'm trying to render a textured quad on top of another quad (that covers the entire viewport), but doing so in a single pass doesn't work. The following code results in the smaller quad being invisible and the fullsize quad texture 'wraps' around near the right edge, such that pixels by the edge are rendered in the centre of the image and pixels in that same area region are invisible.

I'm using separate uniform buffers for the two calls.

I'll post the implementation of renderHUD and Surface.render if necessary.

-- |
-- TODO | - This needs to be more flexible
--        - No hard-coded values
render :: App os -> AppT os ()
render app = GPipe.render $ do
  clearWindowColor (app^.window) $ V4 1 1 1 1
  clearWindowDepth (app^.window) $ 1.0
  
  -- Render the canvas
  Surface.render (app^.easel.canvas.surface) app
  
  -- Render the UI
  renderHUD app

Doing two passes works as expected.

render :: App os -> AppT os ()
render app = do
  GPipe.render $ do
    clearWindowColor (app^.window) $ V4 1 1 1 1
    clearWindowDepth (app^.window) $ 1.0

    -- Render the canvas
    Surface.render (app^.easel.canvas.surface) app

  GPipe.render $ do
    -- Render the UI
    renderHUD app

Apologies again if this has already been covered and thanks for a terrific library.

SwiftsNamesake avatar Aug 14 '17 22:08 SwiftsNamesake

Pinging @tobbebex

SwiftsNamesake avatar Aug 31 '17 08:08 SwiftsNamesake

Hi, something is clearly wrong, but I think I would need the entire source code to be able to debug this. Could you provide that?

tobbebex avatar Sep 23 '17 14:09 tobbebex

For any issues like this, it would be great if you run your app through RenderDoc (https://renderdoc.org/) and send me the trace.

tobbebex avatar Sep 23 '17 15:09 tobbebex

I’m a bit late to the party, but I’m facing the same kind of problem with the following code:

render $ do
  clearWindowColor win 0.5
  clearWindowDepth win 1 -- Far plane

  -- A
  primArray <- makePrimArray
  shader $ ShaderEnvironment primArray (Back, ViewPort 0 size, DepthRange 0 1)

-- B + A works without this separate render, but A + B requires it.
render $ do

  -- B
  gridPrimArray <- makeGridPrimArray
  gridShader $ GridShaderEnvironment gridPrimArray (FrontAndBack, ViewPort 0 size, DepthRange 0 1)

Full code: Test3.hs.txt

Chatanga avatar Mar 04 '19 19:03 Chatanga