3D graphics using arrays?

Discuss game development design and post your game ideas

Post » Thu Mar 16, 2017 10:46 pm

@R0j0hound. Yes a bit like that. But not really, as the position of a voxel is inferred based upon its position relative to other voxels. So we're don't really want to go the voxel route as it's too complex. My approach is indexing rgb values only in a grid, so we can get a 2d representation of a point cloud by searching the index, pixel by pixel.

We only need an rgb value.

How we search the index is where we can optimize a lot.

Maybe some simple steps like this for the screen space index search could look like this ...pixel by pixel.
1. is there any bounding box (index) in this pixel space.
if no . carry on to next pixel, repeat step 1.
if yes. get the name and the scale of the index. now we know which index to search. go to step two.
2. search in z until we hit a point. (maybe we can do it like a ray caster/incremental or just search cell by cell)
if no point is hit, carry on with next pixel. go to step 1.
if we find a cell with an rgb value. Set this pixel to rgb value. Done,
Proceed with next pixel. repeat step 1.

Worst case scenario we need to repeat this the amount of pixels (resolution we want to render) for 100x100 would be 10.000 times.

if we can render regular sprites we can render this... how fast we can search screen space and set rgb value is what matters. just like a regular 2d sprite moving across the screen we only need to draw one rgb value per pixel. we need to find the rgb value and draw it as quick as possible.

possible? what do you think
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Fri Mar 17, 2017 9:59 am

I took a closer look at your example and group the events so i could see which was most cpu intensive.

* The movement of all the points was by far the heaviest part at around 55% cpu usage. That's probably because they are moved individually...
* The tilemap rendering was using around 35% cpu with draw calls of about 5% cpu.
* Not using tilemap rendering z sorting was about 18% cpu, but draw calls at 35% cpu.

I know these numbers are not always 100% accurate, but it gives us a hint of where to improve.

The reason i got so high framerate before by only rotating in one axis, was because i rotated all the points as one entity. I did not need to calculate any new positions for them. I pinned them to a dummy sprite, and rotated the dummy sprite instead. Maybe somehow this could be done for each axis?
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Fri Mar 17, 2017 6:29 pm

In your proposed algorithm step 1 requires sorting all the points into those bounding boxes, then in step 2 those would need to be sorted again by z. It would perhaps work well I you pre-calculated all of that but then you'd be stuck at one view angle.

The reason i got so high framerate before by only rotating in one axis, was because i rotated all the points as one entity. I did not need to calculate any new positions for them. I pinned them to a dummy sprite, and rotated the dummy sprite instead. Maybe somehow this could be done for each axis?

That would only work for an xy rotation, if I understand it correctly.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Sat Mar 18, 2017 2:49 am

@R0j0hound here is an updated capx with my latest tweaks and explanations. I'm trying to shortlist the amount of data we need to show. Currently only the for each loop is the major slowdown. Is there any way to limit that? what would be nice in this case right now, would be a plugin you could feed the array data, and handles the for each loops, and renders. If you look at the capx, you will understand what I'm talking about. Commented in capx also.

https://www.dropbox.com/s/e9it73xfhqjfuib/shortlisting.capx?dl=0
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Sat Mar 18, 2017 6:37 pm

That pretty much just reduces the point count from 3991 to 328 which would give a speed increase. The model could always be made with a lower point count, and having the points uniformly spaced like that probably is preferred to the random sampling.
That all could be done beforehand, and just use the rotation method we already have.

Edit:
I haven't done much work on the capx lately. I've been playing around with doing it in c and basic OpenGL to see the speed difference. 2% cpu vs 35% and it looks like I'm getting 60fps. Hmm, that was refreshing. Might try webgl and JavaScript next.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Mar 21, 2017 8:50 am

@R0j0hound. That sounds cool. Sorry i can't help you out in that case, I'm not much of a coder.

I'm quite curious what the cpu and fps would be if you fill the entire screen with 1 point per pixel. Basically put a screen size box of points, distributed evenly, and have the rendering disregard any points that is not closest to "camera". That's just curiosity, what kind of load you would get.

To explain little bit my reason for this whole thread, is that I've always missed a way to put simple 3D object in 2D games made in construct 2, without having to rely on something like Q3D plugin, when it's just small objects here and there. A way to load simple objects like coins, cards, UI elements, powerups, or whatever, because i want them rendered inline in small viewports (like your tilemap approach) so you can sort them Z-index wize along with regular 2D sprites. I don't know if it's possible or not, but that's what got me investigating what could be done, and so far, converting small objects to point cloud, seemed like a quite good approach, but maybe polygons are faster if you're using webgl/javascript, no idea. Instead of using tilemap, maybe something canvas or paster would be better?
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Tue Mar 21, 2017 9:25 am

I'll just cross post this for now:
is-possible-a-3d-viewport-like-sketchfab-for-c3_p1109202?&sid=4faaaca5a582f3c1da02e2e986c2d373#p1109202

The approach is to render 3d with webgl to some other canvas and then copy it over to overwrite an object's existing texture. That's the cleanest way I've found so far to make it inline with other sprites.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Mar 21, 2017 10:08 am

I checked your post in the other thread and replied there. Fantastic work! If there is any easy way to turn this in to an easy plugin/behaviour for the C2 usebase, I'm happy to assist in any way I can, with tutorials, icons, artwork, models, and demo scenes.

With background in 3D art, I can give some input of what designers might find useful in terms of simple settings.

From what i saw so far, the only thing i would like to set is

Light: angle / intensity / color maybe such things / ambience
Model: Orientation.

I don't know if any other animation support is included in the js, but for now, just simple objects like this is fine. Very useful for some level 3D level art, coins, powerups, UI elements etc etc...

The next thing to wish for is some simple animation support for characters, but this is already way more than I hoped for...
Follow my progress on Twitter
or in this thread Archer Devlog
B
35
S
15
G
17
Posts: 944
Reputation: 12,210

Post » Tue Mar 21, 2017 4:26 pm

A plugin would probably be the last step because that locks in a interface design and is more time consuming to develop from a few extra steps required.

The code is mostly just raw webgl so it's pretty low level. Which means I'd have to build some way to have animation support. Probably means I'd have to make a loader for some file format with animation information.
B
91
S
31
G
103
Posts: 5,235
Reputation: 67,756

Post » Tue Mar 21, 2017 5:02 pm

tunepunk wrote:I don't know if any other animation support is included in the js, but for now, just simple objects like this is fine. Very useful for some level 3D level art, coins, powerups, UI elements etc etc...


This would be great for displaying things like field arrows as well. Awesome work, guys!
www.simbucket.com - HTML5 Science Simulations / https://www.airconsole.com/#!play=com.n ... obotrumble - Robot Rumble on AirConsole
B
46
S
12
G
20
Posts: 363
Reputation: 14,299

Previous

Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: No registered users and 0 guests