Support for not clearing 3D screen between renders

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Support for not clearing 3D screen between renders

Post by Axeman »

Blitz3D has a command called 'CameraClsMode' that lets you set which graphics buffers will be cleared between render frames. It would be great if PureBasic also supported the ability to disable and enable clearing the color and other buffers.

Ogre3D seems to support this feature via the 'Viewport > setClearEveryFrame()' command, but this doesn't appear to be available in Purebasic. It would be useful if it was supported, as I have a project in mind that requires it.

In some cases, it can be handy to turn off clearing the screen as it is usually completely overwritten by new data anyway. Disabling screen-clearing also allows for some interesting effects, such as the 3D maze extrusion effect that I've used in this experimental video: https://www.youtube.com/watch?v=lfAm3ZBtAl4

---

To revisit this request, I'm doing a lot of generative art projects to upload onto OpenSea.io at the moment, and some of that art involves overdraw techniques that require the functionality I've requested here.

Here's an example from an art project that I'm working on that uses PureBasic's 2D sprite system. The 2D system is no good for this though, as it uses integer scaling - which doesn't give me enough layers to remove visible striation artifacts.

https://www.reddit.com/r/generative/com ... ated_with/
https://i.redd.it/z6x81s00h9781.jpg
Last edited by Axeman on Fri Dec 24, 2021 2:07 pm, edited 1 time in total.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Support for not clearing 3D screen between renders

Post by #NULL »

Maybe I don't understand, but just do not call ClearScreen(). I have done this for some effects. Is that what you are looking for?
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Re: Support for not clearing 3D screen between renders

Post by Axeman »

I'm talking about 3D rendering, not 2D.
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Re: Support for not clearing 3D screen between renders

Post by Axeman »

To revisit this request, I'm doing a lot of generative art projects on OpenSea.io at the moment, and some of that art involves overdraw techniques that require the functionality I've requested here.

Here's an example from an art project that I'm working on that uses PureBasic's 2D sprite system. The 2D system is no good for this though, as it uses integer scaling - which doesn't give me enough layers to remove visible striation artifacts.

https://www.reddit.com/r/generative/com ... ated_with/
https://i.redd.it/z6x81s00h9781.jpg
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Support for not clearing 3D screen between renders

Post by #NULL »

If you don't need high performance maybe a hack is sufficient, like grabbing and double rerendering the screen.
A simple demo would be for example examples/3d/Bridge.pb with RenderWorld() replaced with this code:

Code: Select all

      GrabSprite(0, 0, 0, ScreenWidth(), ScreenHeight())
      RenderWorld()
      GrabSprite(1, 0, 0, ScreenWidth(), ScreenHeight(), #PB_Sprite_AlphaBlending)
      DisplaySprite(0, 0, 0)
      DisplayTransparentSprite(1, 0, 0, 50)
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Support for not clearing 3D screen between renders

Post by #NULL »

With vector drawing on a canvas you can have subpixel movement (and partial clearing as well):

Code: Select all

EnableExplicit
Define ww, wh, style, win, canvas, event, quit
Define draw

ww=800
wh=600
style | #PB_Window_ScreenCentered
style | #PB_Window_SystemMenu
style | #PB_Window_MinimizeGadget

win = OpenWindow(#PB_Any, 50, 100, ww, wh, "", style)
AddKeyboardShortcut(win, #PB_Shortcut_Escape, 10)
AddWindowTimer(win, 0, 50)
canvas = CanvasGadget(#PB_Any, 0, 0, ww, wh, #PB_Canvas_Keyboard)
SetActiveGadget(canvas)

Repeat
  Repeat
    event = WaitWindowEvent(5)
    Select event
      Case #PB_Event_CloseWindow
        quit = #True
      Case #PB_Event_Menu
        Select EventMenu()
          Case 10
            quit = #True
        EndSelect
      Case #PB_Event_Timer
        Select EventTimer()
          Case 0
            draw = #True
        EndSelect
      Case #PB_Event_Gadget
        Select EventGadget()
          Case canvas
            Select EventType()
              Case #PB_EventType_MouseMove
            EndSelect
        EndSelect
    EndSelect
  Until Not event
  
  If draw
    draw = #False
    Define.d x, y, a
    a = a + 0.002 + 0.04 * a * a
    a = a * Bool(a < (2 * #PI))
    If StartVectorDrawing(CanvasVectorOutput(canvas))
      VectorSourceColor($06ffffff)
      FillVectorOutput()
      MovePathCursor(50, 50)
      x = ww/2 + 120 * Cos(a)
      y = wh/2 + 120 * Sin(a)
      
      AddPathCircle(x, y, 30, 0, 360, #PB_Path_Relative)
      VectorSourceColor($446666ff)
      StrokePath(1)
      
      MovePathCursor(50, 50)
      AddPathCircle(x, y, 30, 0, 360, #PB_Path_Relative)
      VectorSourceColor($22666ff)
      StrokePath(4)
      
      MovePathCursor(50, 50)
      AddPathCircle(x, y, 30, 0, 360, #PB_Path_Relative)
      VectorSourceColor($046666ff)
      StrokePath(8)
      
      StopVectorDrawing()
    EndIf
  EndIf
  
Until quit
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Re: Support for not clearing 3D screen between renders

Post by Axeman »

#NULL wrote: Fri Dec 24, 2021 7:02 pm With vector drawing on a canvas you can have subpixel movement (and partial clearing as well):
In the experiments I've run, the vector drawing library takes twice as long to render the same number of frames though. The images I've generated using that method also end up being too white, though that could probably be fixed with a bit of shading. For these generative art projects I generally need to generate at least a thousand images, and I'm probably going to increase that number (I need a lot of extra images to do airdrops on OpenSea for promotion).

3D graphics libraries also have a lot of extra features that come in handy for the type of projects that I'm currently doing. Camera fog to more efficiently apply distance shading, for example.

I appreciate the replies, but I'm not really looking for workaround suggestions here. I can come up with plenty of ways to get the job done myself. Just not by using the Ogre 3D library that's included with PureBasic precisely for the purpose of the exact type of thing that I'm trying to do.

As I mentioned in my first post, Ogre 3D supports the functionality I'm requesting. All that I'm suggesting is that the functionality be exposed in the PureBasic version of the Ogre3D library.

Currently, I'm looking at the Raylib library that Danilo has imported into PureBasic. Since it's an immediate-mode library, it should be what I need for this type of rendering work.
Post Reply