Hi all. I’m new here. I thought I would try making a 3d renderer for Arcade, and here’s what I came up with:
Controls:
Joystick: Move camera
A: Cycle the lighting model (None, Flat, Dither)
B: Toggle wireframe overdraw
The renderer has an optional depth buffer, but using it causes an out-of-memory error (err 22) on my PyGamer! I’m trying to think of a clever way to solve that. The depth buffer can be disabled in engine.ts, in case you wanted to try running this on your device.
Not a surprise, but it runs really slooow on device, even with just one object in the scene. Flat shading mode speeds it up a little. Dither mode (pictured) is pretty expensive.
One aspect of this experiment I found particularly interesting was having to implement sine and cosine for the fixed-point Fx8 type. I ended up using a quarter-arc lookup table (64 entries), mapping to a 256-angle unit circle. I probably should mention in a code comment that angles are not in radians OR degrees! They’re in “Fx8ians”, I guess :).
Oh nice I will check those out, thanks. On device the renderer seems to be pixel-bound. Multiple cubes rotate at a nice clip as long as I zoom way out.
I looked at michal’s 3d raycasting demo, very cool! The screen.blitRow has obvious perf benefits. I wasn’t able to easily adopt it because my renderer doesn’t write to an off-screen image. I wonder if doing that would improve performance though. I think I will try that later.
In the meantime, I made a tweak that noticeably improved performance: instead of writing each pixel to the screen individually, I create an Image for the scan line (an n-by-1 image) and write the pixels to that. Then I drawTransparentImage to copy the scan line to the screen. Much better performance both in the simulator and on device.
michal’s 3d raycasting demo has much better input handling than my clunky solution. I will be adopting that :).
Overall it was a delightful experience. I was surprised at how much I could do with it. Having a debugger was very helpful. There were a few areas I think could use refinement, but overall fantastic:
Debugger feedback:
The functionality in place was sufficient for me to quickly find bugs that would have been much more difficult otherwise. I was grateful to have the debugger!
The thing that tripped me up most: When you switch source files in the explorer, it resets the sim. This becomes a problem when working in the debugger. When I switch to another source file, or step into a function in another source file, it restarts the debug session.
I would like to be able to hover on a variable to see its value.
Sometimes I can’t expand a member variable in the watch panel. e.g., I can’t expand this.camera.
Editor feedback:
Amazing editing experience overall.
It can be difficult to find the location of a syntax error. A very clear indicator shows in the explorer, but within the file I have to hunt for the tiny red squiggle. It would be great if the line itself had a clear indicator. Maybe the line number could be highlighted, something like:
GitHub integration:
Top notch! Absolutely incredible!
I think I found an edge case: I was using a fancy variable name to represent an angle in a linear algebra routine. The variable name was let θ = . This caused a SHA hash error when Arcade tried to sync the repo.
Debugger variables now have hover text, and if you click on them it will expand and let you copy the current value
We’ve got a new error list that Hristo, an intern on the team, has been working on, to help find syntax errors (and locate runtime errors). I’ll note that we did recently increase the debounce time for error checking so the red squiggles / error list won’t pop up quite as fast at the moment.
(also if you haven’t used beta yet, you should check out the github integration there - significant changes, including automatically building a gh pages site for you with the test code e.g. https://jwunderl.github.io/pxt-fireworks/)
Ah yes it was an accessor that I couldn’t expand! That makes sense. I’ll try adding //% callInDebugger. Beta debug features look like really nice improvements.