by phantombeta » Mon Jul 25, 2022 6:08 pm
Graf Zahl wrote:ZScript may be too slow to do textures that are programmatically generated per pixel. Even in the best of cases it may be too slow even with JIT due to all the range checks
The range checks really aren't as bad as you'd think. IMO the only thing missing right now is a fast way to blit a texture. To prove this point, I've made a proof of concept PK3. It's the same PSX Doom fire I did a while ago, but drawing to a 320x96 canvas texture using 1x1 squares through Shape2D.
(For efficiency, it generates the tri coords and indices at initialization, then only changes the texture coords to blit the texture)
VM time as reported by "stat vm" barely rises, and the framerate drop is low. And if you disable rendering the Shape2D, you'll actually notice the framerate drop is caused by actually rendering those 1x1 squares, which means proper, efficient pixel blitting for canvas textures would solve this issue.
CVars:
- OGNNTH2_Enabled toggles everything on and off (off by default)
- OGNNTH2_Update toggles the PSX fire simulation (on by default)
- OGNNTH2_Render toggles blitting to the screen (on by default. It only disables actually rendering the Shape2D, the texture coordinates are still generated and added to the Shape2D)
Major Cooke wrote:Right, but I'm curious if I could see a workable example? I.e. i'm not sure if that belongs in drawing functions like RenderOverlay or otherwise.
I believe it does, yes. Think of it essentially as an offscreen version of the Screen API.
- Attachments
-
OGNNTH2.PK3
- (5.42 KiB) Downloaded 81 times
[quote="Graf Zahl"]ZScript may be too slow to do textures that are programmatically generated per pixel. Even in the best of cases it may be too slow even with JIT due to all the range checks[/quote]
The range checks really aren't as bad as you'd think. IMO the only thing missing right now is a fast way to blit a texture. To prove this point, I've made a proof of concept PK3. It's the same PSX Doom fire I did a while ago, but drawing to a 320x96 canvas texture using 1x1 squares through Shape2D.
(For efficiency, it generates the tri coords and indices at initialization, then only changes the texture coords to blit the texture)
VM time as reported by "stat vm" barely rises, and the framerate drop is low. And if you disable rendering the Shape2D, you'll actually notice the framerate drop is caused by actually rendering those 1x1 squares, which means proper, efficient pixel blitting for canvas textures would solve this issue.
CVars:
[list]
[*]OGNNTH2_Enabled toggles everything on and off (off by default)
[*]OGNNTH2_Update toggles the PSX fire simulation (on by default)
[*]OGNNTH2_Render toggles blitting to the screen (on by default. It only disables actually rendering the Shape2D, the texture coordinates are still generated and added to the Shape2D)[/list]
[quote="Major Cooke"]Right, but I'm curious if I could see a workable example? I.e. i'm not sure if that belongs in drawing functions like RenderOverlay or otherwise.[/quote]
I believe it does, yes. Think of it essentially as an offscreen version of the Screen API.