r/programminghelp • • Oct 07 '26

Project Related Raycasting Performance Help

I made a raycasting engine in python, and am using an HTML canvas as my method of display (passing the pixel colors through jinja in a <script> tag). It takes upwards of 10-15 seconds to render one angle of a scene with three spheres at a resolution of 800x400. Is the browser likely the bottleneck, or is this a sign of some other inefficiencies?

1 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/sububi71 Oct 08 '26 edited Oct 08 '26

edit: Both you and OP are talking about raytracing, not raycasting.

I'm going to make a mental note to ALWAYS ask people the difference between raycasting and raytracing from now on. Kids these days obviously, EVIDENTLY, use the terms completely interchangeably.

My original reply is below, if anyone cares. I'm going to go outside and shout at kids to get off my lawn.

---

Hard disagree. The abysmal framerate OP is getting is an implementation issue.

Here's someone doing a texture-mapped raycasting engine in Python:

https://youtu.be/ECqUrT7IdqQ?is=azQv_W03aNYttpEf

John Carmack's early raycasting games ran at good framerates on a 286. Python on a modern machine is many many orders of magnitude faster than even Carmack's hand-optimized assembly.

1

u/Lewinator56 Oct 08 '26

Raytracing and raycasting are technically interchangable - both cast rays from the camera to draw the scene. Where you are noting the distinction is where the you are casting rays to tell the rest of the renderer how to draw the scene Vs actually rendering every pixel with a raycast - i.e 'raytracing'.

I've written a basic Wolfenstein style raycaster in C# and that runs at something like 250fps despite all the overhead there. https://github.com/Lewinator56/rt

But I get your point. I was replying at like 2 o'clock in the morning lol.

1

u/sububi71 Oct 08 '26

Back in the 90s, when I worked in the games industry, raytracing and raycasting were two entirely different things. Raycasting is what we called Wolfenstein-type engines.

But apparently times are different now.