pipliz / cpuvox Goto Github PK
View Code? Open in Web Editor NEWA C# implementation of voxlap-style rendering, using Unity and their Burst compiler
License: MIT License
A C# implementation of voxlap-style rendering, using Unity and their Burst compiler
License: MIT License
Hello! I've been working on my own raycaster very similar to this one, and I figured out some ideas to make cache hit rate and utilization much better, and thought they might help.
1 - If you store colors and rle segments separately, you won't pay the cost of pulling the colors into the cache, if it turns out that all of the column segments are not actually visible on-screen. I highly recommend this, because it means more runs will be in cache.
2 - When traversing the world, the most common case of traversal is probably an equal step in x and y directions. This means that if you store your world arrays contiguous in one access, like this
01234567
89ABCDEF
If you turn so your view goes across the rows, every grid sample will require a new cache line fetch!. So, I would recommend a simple tiling scheme, just 2x2 or 4x4 tiles should help utilize cache line fetches of the map data better. (If column rle segments and colors are stored together, this is likely not as effective)
If instead of doing (y*width)+x
, or (x*height)+y
indexing, you mix the bits of both axes, you can get some nice tiling
YYXXyx for example, will give you
01 45
23 67
89 CD
AB EF
The logical conclusion of a setup like this is full morton coding e.g. XyXyXyXy
, there are diminishing returns above simple tiling, but it also might be worth a shot.
3 - This might not be applicable for your renderer, but it helped me to store a separate "column header" type data structure, which only has the heights of the top and bottom filled voxels in the column, and the number of runs. This allows me to pack as much important culling information (is the top below the screen? is the bottom above the screen? etc) into cache as possible. So, I have 3 main world arrays, column_headers, column_runs, and column_colors.
Hope these ideas help! My raycaster doesn't do lod or a lot of the fancy stuff yours does quite yet, but they improved performance for me by over 2x.
Player.log
Crash on loading a model, both in Editor but also using the Released version.
After what appears to be a random amount of time things just Freeze.
Happens in both Editor and Build, no Crash log or anything, Editor log appears to just Cut off without saying anything is wrong.
CPU Usage seems to continue going, however the editor or game itself just stops responding.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.