Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Vogtinator on November 26, 2013, 01:11:43 pm

Title: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 26, 2013, 01:11:43 pm
Hi,

I started this program a long while ago and it never really advanced. But now I'm making progress again!
It's basically a little library (but not intended to be a library to link with) which handles the basic stuff you need for 3D:
-Rotation
-Translation ;D
-Scaling
-Colors  :hyper:
-Drawing triangles and quads
-Perspective
-Z-Buffering
-Backface culling
-Bad wireframe mode
-Matrix stack (glPushMatrix, glPopMatrix)
-Textures O.O
-sin and cos LUT for the fixed point datatype with highest possible accuracy (degrees)
-OpenGL immediate-mode like API
-Written in C++ (operator overloading) but C-style API if needed

At first I tried to implement it with float, but that was ridiculously slow and laggy. Especially the z-buffering was painful to watch..
But after I implemented fixed point arithmetic things changed: The attached demo runs at ~100fps (1 degree rotation per frame) in the emulator and a bit slower on a real calc. I was curious how fast it really was, so I tried loading some .obj files and it was smooth until 2000 triangles. I'm sure it can be optimized further, it doesn't use a single line of assembler yet.

I tried to port glxgears but a quick and dirty port had some issues with the blue gear.

Known issues:
-No triangle-based clipping: pixel based is a bit slower (depends on the objects on screen) and if you're near a triangle, it may look weird or even crash
-Bad integer division algorithm (gcc's own): division through a small number takes ages
-Drawing triangles is still a bit slow, two increments, one multiplication and several comparisions per pixel (without textures)
-glRotatef not yet implemented
-Sometimes it tries to divide through zero and it hangs, I don't know why  >:(
-Textures lack perspective (difficult to optimize)
-Viewport is fixed: bottom: y=0 top: y=239 left: x=0 right: x=320, in OpenGL it's most times -1-1, so a scaling factor is needed

But nevertheless, I'm going to implement a simple 3D game (no, not minecraft) with this lib, but I don't know what kind of game:
- 3D Tetris (boring..)
- Motor race in 3D (how should the cars and the environment look like, also: collision detection)
- 3D snake (even more boring..)

Edit: Ok, it seems like I made a minecraft game nevertheless...
Latest release of crafti: v1.2 (https://www.omnimaga.org/ti-nspire-projects/ngl-a-fast-(enough)-3d-engine-for-the-nspire/msg404386/#msg404386) GitHub (http://github.com/Vogtinator/crafti)
Source code and tutorial for nGL are on GitHub as well (http://github.com/Vogtinator/nGL)

Demo controls:
-touchpad: camera rotation
-8-4-6-2: camera position
-x: rotate the four cubes

Do you think this is useful or will it stay an experiment forever?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 26, 2013, 01:15:58 pm
O.O this is aaawesome !!! I hope it'll be fast enough to have actual games out of that :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TheMachine02 on November 26, 2013, 01:17:28 pm
You made me wish to have a nspire CX with ndless. Super great job  :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Levak on November 26, 2013, 01:22:26 pm
Are you serious ? x)
I started nAk3D two months ago with an openGL like api !
Yours is obviously finished. ^^
Whats strange, is that I started using fixed point numbers and had a headache when multiplying matrices (int overflows) and then went to floating point and didn't seemed to lost any performances.

The only difference with nAk3D is that it uses nGC and an heap sort face algorithm instead or your zBuffer.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 26, 2013, 01:31:16 pm
Are you serious ? x)
I started nAk3D two months ago with an openGL like api !
Yours is obviously finished. ^^
I started nGL some days before nCraft..

Quote
Whats strange, is that I started using fixed point numbers and had a headache when multiplying matrices (int overflows) and then went to floating point and didn't seemed to lost any performances.
Weird. I'm using int_fast32_t as storage and the lowest 8 bits as fractional part. (~0.004 accuracy).
Also weird that you didn't lose any performance. For me it was a significant difference (the CPU doesn't have a FPU)

Quote
The only difference with nAk3D is that it uses nGC and an heap sort face algorithm instead or your zBuffer.
Z-Buffer has some advantages: constant performance, overlapping triangles and you can maybe use the depth image for e.g. lighting.
And the most obvious one: It's very easy to implement.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 26, 2013, 01:33:27 pm
Are you serious ? x)
I started nAk3D two months ago with an openGL like api !
Yours is obviously finished. ^^
I started nGL some days before nCraft..
What ? nCraft is by Chockosta ...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 26, 2013, 01:34:59 pm
Yeah, right. I started nGL some days before Chockosta published nCraft here.
The same that happened to Levak now :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 26, 2013, 01:35:31 pm
Oh okay, sorry :P

So this is a long work indeed ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: SpiroH on November 26, 2013, 01:39:33 pm
This looks like a real good job! Anxiously awaiting a simple 3D game. BTW, i don't mind if we start with one of the boring ones 3D Tetris, 3D Snake, etc.:P
How compatible is nGL with openGL? How difficult would it be to port simple openGL demos to npsire?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 26, 2013, 01:57:17 pm
That depends entirely on the features it uses, if it's only immediate mode or vertex arrays/VBOs a simple abstraction could be enough.
Then there's the problem with the viewport, nGL doesn't have a function to define the viewport or the frustrum yet.
The accuracy of my fixed-point type is also too bad for most programs which use a 1 unit = 1 meter base. Sometimes a glScale3f is sufficient, but if it isn't, you'll have to scale manually or increase the accuracy of the fixed-point type (which may lead to strange errors if it overflows).
Textures aren't bound by ids anymore and other major features are missing (lighting, materials, transparency) mostly for performance reasons.

tl;dr: It depends.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Levak on November 26, 2013, 05:53:16 pm
nGL doesn't have a function to define the viewport or the frustrum yet.
I've seen http://www.scratchapixel.com/lessons/3d-advanced-lessons/perspective-and-orthographic-projection-matrix/opengl-perspective-projection-matrix/ a couple days ago that works well.
the entire tutorial did learn me a lot of things actually :)

Quote
The accuracy of my fixed-point type is also too bad for most programs which use a 1 unit = 1 meter base
I experimented the same problem, too large numbers explodes integer capacity when matrices are involved.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on November 27, 2013, 01:10:49 am
I love how fast this seems to be and the texture details. I can't wait to see how well this runs with many more things on the screen.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 28, 2013, 03:47:51 pm
So, I fixed a few bugs in nGL (fewer crashes) and converted my snake game (I made exactly one year ago) to 3D.
No special features, just plain snake.
You can still move around and look.
The apple is just a cube with apple texture (I found on the internet), I couldn't find a suitable 3D model of an apple and I can't use blender.
Every block on the screen is drawn and textured completely, the game isn't optimized at all (walls between two wall blocks) but still runs smooth.
Sorry, but I'm more programmer than game designer and I just couldn't do it any better...

Controls: 8-6-4-2: Move snake
                WASD: Move around (for testing with nspire_emu)
                touchpad: Look around
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on November 28, 2013, 03:49:37 pm
O.O This looks pretty epic.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on November 28, 2013, 03:56:05 pm
This looks nice. It makes me want to have an nspire.

Can it handle large triangles as well as smaller ones?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 28, 2013, 04:35:32 pm
Simple but awesome proof-of-concept O.O

I feel like I'll be doing something to see how powerful it is ...
/me is planning things, be ready people
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 28, 2013, 04:36:29 pm
Not really, it needs three division per horizontal line (z, u and v) and the pixel() function checks whether the pixel is visible (clipping and z-buffer). It basically scales linear to height, but I'll improve that once I implement triangle clipping.

Edit: If you're reading this and getting confused, this is a reply to the second last post :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 28, 2013, 04:37:29 pm
By the way, what attachment should I download to have the latest version of the nGL lib ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 28, 2013, 04:39:56 pm
Just the snake3d_something.tar.gz. the only snake specific parts are the textures and main.cpp.
If you want to I can give you a tool to convert images (png, gif, jpeg, tiff...) to header files with filled TEXTURE structs.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 28, 2013, 04:40:24 pm
Yeah I might want to use that :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 28, 2013, 04:44:38 pm
Beware: It's written in C++ (with Qt), source code and binary for x86_64 linux attached. It's sort of hacked together (doesn't even show whether the file exists), but it should work.
./ConvertImg test.png >> textures.h and then #include "textures.h" and use the texture with glBindTexture(&test);
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on November 28, 2013, 04:50:25 pm
And if I use Windows ? <_<
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Levak on November 28, 2013, 05:13:28 pm
And if I use Windows ? <_<
Then use drapes.

edit : More seriously, Qt development tools exist for Windows, just google it and compile it yourself.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on December 19, 2013, 03:02:03 am
So, I fixed a few bugs in nGL (fewer crashes) and converted my snake game (I made exactly one year ago) to 3D.
No special features, just plain snake.
You can still move around and look.
The apple is just a cube with apple texture (I found on the internet), I couldn't find a suitable 3D model of an apple and I can't use blender.
Every block on the screen is drawn and textured completely, the game isn't optimized at all (walls between two wall blocks) but still runs smooth.
Sorry, but I'm more programmer than game designer and I just couldn't do it any better...

Controls: 8-6-4-2: Move snake
                WASD: Move around (for testing with nspire_emu)
                touchpad: Look around
(http://www.omnimaga.org/index.php?action=dlattach;topic=17596.0;attach=16452;image)

Nice HP Prime game! Oh wait nvm it's Nspire :P (it just reminded me a bit of the 3D thing I made, except it was actually pseudo 3D in my case)

I like how this library is turning out so far. :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on December 24, 2013, 08:30:17 pm
UPDATE!  ;D

I made some progress on nGL and made another demo (which is again, not intended to be "played"): crafti!

Changes:

Todo:

It looks a lot better on the emulator and on calc than these gifs (byzanz-record is crap):
(http://img.ourl.ca/crafti_colors.gif)
(The emulator runs at 90% speed here, I accidentially hit F9)
(http://img.ourl.ca/crafti_textures.gif)
The textures used aren't mine this time, terrain.png came from http://www.planetminecraft.com/texture_pack/fancycraft-by-jjjas0n-64x64-version-100.
Also, the controls (same as nGL in the first post) are a bit weird to use on a PC so the twitches you see are just my fingers finding the keys.

It's a bit slower on calc than on the emulator, I suspect it's the touchpad polling every frame, but if that get's a real issue, I'll take care of that.
If you want to use nGL, grab gl.cpp, gl.h, fastmath.h, fastmath.cpp, fix.h and don't forget to read gl.h and #define SAFE_MODE in gl.h!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Levak on December 24, 2013, 08:37:08 pm
It's a bit slower on calc than on the emulator, I suspect it's the touchpad polling every frame, but if that get's a real issue, I'll take care of that.
If you want to use nGL, grab gl.cpp, gl.h, fastmath.h, fastmath.cpp, fix.h and don't forget to read gl.h and #define SAFE_MODE in gl.h!
I notived that on my nAk3d project (dropped down due to your way better GL implementation :D ).
This is indeed due to pooling, touchpad or keypad, both are time critical for something running on 30fps.
For example, my first attempts ran on emulator at 200fps, but only 16 fps on calc. I removed keypad pooling and it then raised to 120fps.
notice : This problem is not visible on emulator due to not emulating mapped memory access delays.

I then managed to create a keypad pooling without using an interruption handler. It uses the ndless code of sleep.c that setup an arm co-processor to wakeup the arm processor when a certain time has arrived. This let me cleverly set my keypad pooling without spamming at each frame.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Sorunome on December 24, 2013, 08:39:58 pm
Wow, this is insanley fast&smooth *.*
Great job! :thumbsup:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on December 24, 2013, 08:50:11 pm
Quote
I then managed to create a keypad pooling without using an interruption handler. It uses the ndless code of sleep.c that setup an arm co-processor to wakeup the arm processor when a certain time has arrived. This let me cleverly set my keypad pooling without spamming at each frame.
Or I register a function as a keypad interrupt handler which sets some bits of keys currently pressed to 1.
I'll have to implement interrupt support for the FPS counter (timers :/) anyway...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TIfanx1999 on December 24, 2013, 09:46:42 pm
This is looking pretty impressive. Nice work Vogtinator! :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on December 24, 2013, 11:41:44 pm
The Nspire has timers you can use to calculate framerate/frametime.

http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900D0000_-_Second_timer
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Xeda112358 on December 25, 2013, 01:01:37 am
Wow, this looks fantastic! Are you able to make a 3D snake that is in a cube instead of a plane? The snake could always go in one direction (away from the screen?) and the player just rotates the view of the box in order to steer the snake. Just an idea ^^
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on December 25, 2013, 12:50:46 pm
You mean controls similiar to a rubik's cube?
(Except rotating the individual rings of course)

Edit: FPS counter works now. 100+fps in wireframe mode,  50 in color mode, 30 with textures and 25 with interpolated colors.
But I get some issues with the keypad/touchpad interrupts. If I enable IRQ 16, it just freezes on the real calculator, it works on the emulator.
I acknowledge by writing ~0 to 900e0008 and 900e0044. Can someone give me a clue what might be wrong here?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on December 25, 2013, 11:10:46 pm
Now that I think about it, 3D snake would be too easy.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on December 26, 2013, 02:48:55 pm
Now that I think about it, 3D snake would be too easy.
Depends. At first yeah, you are doing it on purpose if you hit something. But when you start being long, you don't see where your tail is when it is not on the face your head is on ;)
And it can be even worse if there are walls and you don't know where.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on December 26, 2013, 02:51:27 pm
Since a regular snake is a bent 1D object in a 2D world, I wonder how one could control the analog, a bent 2D object in a 3D world.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on December 26, 2013, 03:37:00 pm
Well it's written nowhere that you have to do +1 on both numbers ;)
It would be a bent object in a 3D world yes, but still a 1D object.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on December 26, 2013, 03:46:09 pm
Just speculating there. Another simple game you could try writing is a 3D, as in 6DOF, maze.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Xeda112358 on December 26, 2013, 04:53:54 pm
The way I make snake games, is I have a buffer of coordinates and to increment the snake, I erase the tail, shift the buffer down, and add a new head at a coordinate computed by the direction you are turning.

You *could* do a snake game where the arena is stationary, the snake always moves forward, and can turn left/right/up/down. However, the controls would get very confusing, especially if you turn the snake upside down. Instead, it would be much easier and probably more fun and cool looking if you rotated the arena and kept the snake oriented the same. Of course, you would have to redraw every element of the snake each time, but that looks like it would be trivial with this engine. To visualise, the head would always be centered in the screen, facing away from the camera, looking in the direction the camera is looking. When you turn left/right/up/down, you could use a different sprite for those directions, but still centered. Then, you just change the camera angle. Incrementing the snake would have to be done based on the current view angles, and you would have to increment it with the camera.

You could just call it a dragon and pretend you were riding one and steering it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on December 28, 2013, 08:23:09 am
Or something like http://www.heavygames.com/snake3d/playgame.asp?
With or without transparency (I'm confident in the nspire's performance ;) )?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on December 31, 2013, 01:54:30 am
One idea I had for a 3D Snake was in the space and with the ability to go in every direction (360° vertically and horizontally), but it would need multiple fruits to eat at once, else a radar would be needed to avoid spending 10 minutes trying to find the next fruit.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on December 31, 2013, 09:15:53 am
That would get really confusing, especially the controls :/
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on January 04, 2014, 05:56:12 pm
True, although I guess if there were many apples to eat it wouldn't be too bad. The problem would probably be coding movement since you could move in every direction.

Anyway, when posting this, I totally missed the other screenshots on the previous page or they were not showing up:

UPDATE!  ;D

I made some progress on nGL and made another demo (which is again, not intended to be "played"): crafti!

Changes:
  • Faster! A lot faster, actually. I can't tell any numbers, but with large triangles it went from slow to smooth :hyper:
  • Interpolating colors between vertices, which is actually slower than textured rendering
  • Prefixed functions with ngl (for example nglInit)
  • Something like vertex arrays (nglAddVertices)
  • Wireframed rendering
  • Doesn't crash anymore
  • Some documentation
  • Clipping! (X: Per pixel Y: Per line Z: Per triangle)

Todo:
  • Colored textures (non-interpolated)
  • Compressed textures (zlib). nGL doesn't lose performance with higher-resolution images, they just get too big in raw format
  • Make a real, playable, good looking game which uses nGL
  • FPS counter

It looks a lot better on the emulator and on calc than these gifs (byzanz-record is crap):
(http://img.ourl.ca/crafti_colors.gif)
(The emulator runs at 90% speed here, I accidentially hit F9)
(http://img.ourl.ca/crafti_textures.gif)
The textures used aren't mine this time, terrain.png came from http://www.planetminecraft.com/texture_pack/fancycraft-by-jjjas0n-64x64-version-100.
Also, the controls (same as nGL in the first post) are a bit weird to use on a PC so the twitches you see are just my fingers finding the keys.

It's a bit slower on calc than on the emulator, I suspect it's the touchpad polling every frame, but if that get's a real issue, I'll take care of that.
If you want to use nGL, grab gl.cpp, gl.h, fastmath.h, fastmath.cpp, fix.h and don't forget to read gl.h and #define SAFE_MODE in gl.h!

Do you think this engine would be powerful enough for a Minecraft game? O.O Chockosta made one in Lua with no textures but it ran at 10 FPS at 230 MHz, even if it only rendered stuff within a three tiles radius. O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: The_King on January 04, 2014, 05:58:35 pm
hmm if this is successful mine craft 3d will be easy enough
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on January 04, 2014, 06:28:49 pm
Quote
Do you think this engine would be powerful enough for a Minecraft game?  Chockosta made one in Lua with no textures but it ran at 10 FPS at 230 MHz, even if it only rendered stuff within a three tiles radius.
"crafti" runs at > 20 fps with textures and ~50 without, so it should be possible to play with.
I'm currently working on a game using nGL, but it's not ready yet.
However, I could also imagine some kind of "Portal" game with real portals (move camera to other portal, render into buffer, bind buffer to texture, render portal with texture) which would certainly run fast enough if the level geometry isn't too complex.
Chockosta didn't code ncraft in lua (That would be a PITA, really) he did in in C, but with floats. It would run much faster if he would use fixed-point math like nGL does. Also, nCraft is more optimized to render blocks (culling etc.) so it could turn out even slightly faster than nGL now.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on January 04, 2014, 08:05:48 pm
Oh wait I thought that it was in Lua. I guess I forgot. >.<
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Eiyeron on January 16, 2014, 03:16:47 pm
Oh Go-Armok, that's incredible! :o
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on January 21, 2014, 03:40:11 pm
Seriously though, "we all" want MineCraft, you have an engine that could support it, you are looking for an idea.

So, I mean, why not MineCraft ?

Of course, you probably won't make the whole game in one week, but nothing prevents you from first making a world editor where the player would be flying and would dispose of infinite blocks (kind of like the Creative mode) to place anywhere. This would already be enough for people to have fun, see how they shared their creations (http://ourl.ca/17098) even if there was no goal in nCraft. And then, if you feel like it, you could add player gravity. Then if you still feel like it, you could add mobs. Etc.

Of course, I don't want to tell you what to do, but once again, people want MineCraft, you have an engine that could support it and you are looking for an idea :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on January 21, 2014, 03:49:12 pm
crafti has the fundamental things (chunks, block properties etc.) already built-in, so it shouldn't be too hard to make a game out of it.
There are still some problems in nGL, though, the missing z-clipping causes some weird glitches in some situations.
When I have some time (or want to procrastinate  ;) ) I'll fix those issues (and remove buggy keypad IRQs again) and implement some block modifying stuff.
Should I go the ray-box intersection route or the color coding route?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on January 21, 2014, 03:56:50 pm
Ray-box would be the best IMO ; since everything in Minecraft can be leveled down to a single bounding box without losing precision, it could be good to have specific code for that.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on January 21, 2014, 04:23:28 pm
Definitely raycasting. Since everything is cubes, digital differential analysis will be perfect.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on January 21, 2014, 04:27:46 pm
This is too specific to be in nGL ... and Minecraft with raycasting ? -___-
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on January 21, 2014, 04:46:04 pm
Minecraft with raycasting would probably be way to slow. It would require a ray for every pixel on the screen, which would be slow. IIRC Minecraft 4K uses a technique similar to raycasting to render it's world, and it is very limited (world size of 64x64x64) and runs at a decreased resolution (856x480 pixels, but at half resolution) on a computer.
You can always try, but as polygon-based graphics and not voxel-based graphics are the current standard for 3D computer graphics, I don't think a raycasting-based voxel renderer would be feasable.

You may be able to 'cheat' a bit with polygons tough, as when rendering blocks all the faces are parallel.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on January 21, 2014, 07:32:10 pm
Sorry, I meant raycasting for block picking. Not for rendering. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 15, 2014, 02:53:27 pm
It's weekend so I had a little bit time for some improvements:
crafti 0.2 with nGL 0.4.
New features: Basic light system in crafti and z-clipping in nGL

(http://img.ourl.ca/crafti_0.2.gif)
In the screenshot it renders 80 fps at the beginning and ~100 at the end when only the 9 dirt blocks are visible.
Lighting is only supported if textures are disabled, as it would require 3 multiplications per pixel.

I guess I'll have to implement something like minecraft now ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 15, 2014, 08:33:10 pm
Wow, a Minecraft clone using this engine would rule! O.O How does it handle a 512x512x64 map?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: XiiDraco on February 15, 2014, 09:23:48 pm
O_o just now saw this... So friggin awesome  O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 16, 2014, 12:53:02 am
I noticed the edges of the polygons were shimmering. Is that because you are using integer coordinates for drawing?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 16, 2014, 08:25:07 am
I'm using fixed-point (1/256 accuracy) so it could be.
But I assume the things you saw were caused by a mixture of my .gif recorder and normal aliasing.

Edit:
Quote
Wow, a Minecraft clone using this engine would rule!  How does it handle a 512x512x64 map?
Not at all, I tried it. 16*16 chunks of 16*16*16 blocks = 1 FPS...

4*4 chunks is the maximum usable size (~8fps), too many triangles
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on February 16, 2014, 10:14:46 am
I'm using fixed-point (1/256 accuracy) so it could be.
But I assume the things you saw were caused by a mixture of my .gif recorder and normal aliasing.

Edit:
Quote
Wow, a Minecraft clone using this engine would rule!  How does it handle a 512x512x64 map?
Not at all, I tried it. 16*16 chunks of 16*16*16 blocks = 1 FPS...

4*4 chunks is the maximum usable size (~8fps), too many triangles
How do you render them? If you render every block individually, you waste a lot of time drawing invisible parts. Even a computer can't handle this. You need to generate meshes which contain only the sides of the block  that are exposed to air (or to any non-solid block if you include any). Then you should notice a huge performance increase. (The real minecraft does this)
If you already do this, then you may want to look into other ways of hidden surface removal. I think you mentionned earlier that you use a Z-buffer? For a world made out of blocks, this isn't really nessicary, as they are very easy to Z-order. If you plan on including mobs as well, it gets a little  bit harder, but it should be possible as well. This should also increase the performance because it cuts down on per-pixel operations. (The real minecraft doesn't do this, but on a computer, you have graphics hardware that is designed to do per-pixel calculations efficiently, which the nspire doesn't have)
If you already do both of them, then I'm out of ideas to increase the performance.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 16, 2014, 10:52:48 am
Aw too bad it runs much slower with 16x16x16. Does it mean a Minecraft clone using this would actually be slower than nCraft?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 16, 2014, 12:18:54 pm
I'm rendering chunks only if the geometry changed into a VERTEX buffer.
If the geometry didn't change, I do the following:
Code: [Select]
glBegin(GL_QUADS);
nglAddVertices(buffer, buffer_length);
glEnd();
To generate the VERTEX array, I simply iterate through all AIR blocks and render the corresponding sides of adjacent blocks.
z-sorting is IMO slower than a z-buffer in this case, as it would require sorting every face every frame.
I tried to implement it and it looks weird (read: full of bugs) and wasn't much faster (15 fps vs 11)

To get a maximum performance minecraft game, it would be best to use my GLFix in nCraft, as it's more specialised for blocks than nGL.
Currently I have no class World which handles the faces between chunks (they get rendered always) and below them which you can't see.
So don't worry, there is still much room for performance improvements. It could be faster if I cache the transformed vertices instead of the whole untransformed chunk.
That'd mean much less matrix-vertex multiplications but iterating over each block.

Quote
Aw too bad it runs much slower with 16x16x16. Does it mean a Minecraft clone using this would actually be slower than nCraft?
I don't know the visible range of nCraft, but if it's < 32, crafti is as fast with textures as nCraft is without.

Edit: Found a trivial optimization I thought the compiler was smart enough to do itself but it didn't.
Results with 2*2 16*16*16 chunks and no world optimizations yet:
TEXTURE_SUPPORT: ~16fps
No TEXTURE_SUPPORT: ~30fps
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 16, 2014, 01:22:08 pm
Oh ok I thought it ran slow regardless of the viewing range. I think in nCraft it's about 5 blocks away and if you want to view further, you have to press a key which renders the frame in 4-5 seconds.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 16, 2014, 05:47:14 pm
Here is a recent build of crafti. Can anyone tell me whether it's fast enough (fps-wise, not movement-wise)?
I'm fully aware of the artifacts..
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 16, 2014, 06:03:13 pm
I'll give this a try, assuming it actually runs (I am unsure if I have the latest Ndless version and I am never able to send an OS file to my calc with less than 666% battery charge)

This is nCraft view depth and speed btw (I think I used Nover before running it and it ran at 242 MHz)

Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 17, 2014, 03:24:45 pm
Ok, newer version:
3*3 16*16*16 chunks: 48*48 viewing distance with ~32 fps when walking around.
I also resolved some artifacts, but there are still some perspective projection issues (jagged edges)
I'll post the source code and screen capture after I fixed those.

Edit: I just HAD to upload my first animation (runs at 60 fps BTW):
(http://img.ourl.ca/crafti_steve.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on February 17, 2014, 03:31:00 pm
Does this require a specific (as in "not too old") revision of Ndless ? Because I can run nCraft but not crafti ("not supported").
And yeah, I have a really old revision :P

edit Indeed, works with r914.
However, I only figured out part of the controls, and my calc froze at some point O.O

Great job other than that :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 17, 2014, 05:02:20 pm
Oh, I got ninja'd while editing...

Quote
Does this require a specific (as in "not too old") revision of Ndless ? Because I can run nCraft but not crafti ("not supported").
And yeah, I have a really old revision

edit Indeed, works with r914.
crafti uses c++ which supposedly needs bFLT to work correctly...

Quote
However, I only figured out part of the controls, and my calc froze at some point
Are you sure it froze and didn't just display the sky? I haven't had a freeze in a while, only crashes until I (hopefully) fixed them :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on February 17, 2014, 05:12:24 pm
Oooooh that's awsum man :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on February 18, 2014, 12:32:57 am
Oh man, that looks so amazing, it's beyond words! I'm a huge Minecraft fan.  Make a Minecraft! :D Anyway, it looks soooo great!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on February 18, 2014, 12:37:42 am
Quote
However, I only figured out part of the controls, and my calc froze at some point
Are you sure it froze and didn't just display the sky? I haven't had a freeze in a while, only crashes until I (hopefully) fixed them :)
The D-Pad and the number keys stopped responding. It's possible I made it crash myself though because I tried all the keys.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TheMachine02 on February 18, 2014, 09:27:52 am
Sound like there was very good progress here. Good job for this first animation, it's look sooo greeaattt  :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 18, 2014, 03:54:43 pm
Very great Vogtinator! O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: XiiDraco on February 19, 2014, 01:34:12 am
I'm just... astonished.... I think I might go try and find a mini usb cable so I can start using my Nspire again just because of this...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Sorunome on February 19, 2014, 02:54:56 am
Wow, that is looking awesome! O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 19, 2014, 04:25:59 pm
I tried to fix the depth issues and had to use floats (or int_fast64_t which is equally slow to divide somehow) which is slower (depends on vertex count)
Which version is better? Or should I keep both?
(http://img.ourl.ca/crafti_better.gif) (http://img.ourl.ca/crafti_worse.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on February 19, 2014, 04:30:24 pm
I think it's best to use the fastest version. The artifacts are not that visible and the graphics are amazing either way considering this is a calc game.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 19, 2014, 04:35:54 pm
Here's a version where the miscalculations are more clearly visible:
If it's further away the depth resolution decreases, in this .gif it's moving away with CONSTANT speed, so
the small "breaks" in movement are just differences beyond the precision.
(http://img.ourl.ca/crafti_worse-1.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on February 19, 2014, 04:46:08 pm
Correct me if I'm wrong, but it looks like it starts happening at a reasonably large distance. You can make a decision based on the following statements:
 - Will the finished game have a view distance big enough for the artifacts to be visible?
 - Will the environment be very open so that there are nearly no nearby structures covering the ones further away?
 - Do you have enough leftover speed to switch to the more accurate version and program in the other things you want?
And if it's not hard to do, maybe you can make it an option, kinda like the fast/fancy graphics option of Minecraft.
But personally, I don't find it too disturbing. Many older games relied heavily on LOD's, which gave comparable artifacts when moving at a significant speed.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 22, 2014, 07:03:53 pm
It's weekend again, so some more progress:

With textures it's smooth now also with some more blocks visible (~25 fps):
(http://i.imgur.com/RX4HMdy.gif)

I had to use imgur for that one as I couldn't upload it to img.ourl.ca.
The file was probably too large and every file I try to upload now (name doesn't matter)
doesn't get uploaded and it shows "crafti_world.gif" (the old file name!) was uploaded successfully and a 404 NOT FOUND next to it...

Without textures we can expand the viewable distance a bit further and we get to ~11 fps:
(http://img.ourl.ca/crafti_world2.gif)

But for comparision fps-wise with the same distance as with textures above (~40 fps):
(http://img.ourl.ca/crafti_world3.gif)

Known bugs:
-Weird lines if textures enabled
-Sometimes a triangle hitting the right screen border shows random data if textures enabled
-Sometimes it displays garbage if perfectly aligned to Z axis
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on February 22, 2014, 07:20:48 pm
The weird lines on the texture-enabled screenshot seems to be the result of inaccuracies when calculating the texel that belongs to a pixel, which causes it to read texels outside of the texture on the edges of triangles.
I assume that you're using 16*16 textures, right? Then make sure that the u and v coordinates never go above 15 (set them to 15 when they reach 16), or below 0 (only when they are signed), before doing the texel lookup and it should be fixed.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 22, 2014, 07:24:57 pm
I know where the lines are coming from and it's not exactly that.
It's a bit harder to fix though, because simply testing the coordinates EVERY PIXEL would be to slow.
But I kind-of know what I can do in this case.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on February 22, 2014, 07:28:29 pm
You are using fixed-points, right? Well, then you can kinda cheat a bit by setting the coordinates to e.g. 0.1 and 15.9 instead of 0 and 16. It's just as fast as the previous code, but after experimenting a bit with the values, you can get rid of the lines witouth visuall distorting the texture.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 23, 2014, 12:51:49 am
Since these textures are repeated, it would actually make more sense to wrap the texture coordinates. It would have to be tested per-pixel, however it should be fairly fast (as long as textures are a power of two size), just a bitwise AND on each coordinate value. For a minecraft engine, this would also open up the ability to simplify meshes in large, flat areas of the same block.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on February 23, 2014, 03:58:31 am
I tried to fix the depth issues and had to use floats (or int_fast64_t which is equally slow to divide somehow) which is slower (depends on vertex count)
Which version is better? Or should I keep both?
(http://img.ourl.ca/crafti_better.gif) (http://img.ourl.ca/crafti_worse.gif)
I'd say go for the fastest. It' only disturbing when blocks are really far.

And nice progress :D
I'd say that you should include both mode (with and without textures) in the final version so that we can make beautiful screenshots with textures and build quickly too ;)
(not that it is slow with textures, but it is faster without so if we want to make quick changes, we might want a quick way).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 23, 2014, 06:18:16 am
Quote
You are using fixed-points, right? Well, then you can kinda cheat a bit by setting the coordinates to e.g. 0.1 and 15.9 instead of 0 and 16. It's just as fast as the previous code, but after experimenting a bit with the values, you can get rid of the lines witouth visuall distorting the texture.
I'm doing that already. I have a nice SAFE_MODE #define which tells me if something is read out-of-bounds and it was triggered with OpenGL like texture coords (0 - 1 on the edges) vs. nGL coords (0-1 - 1px on the edge pixels). As the lines are a unique color (for each texture) I don't think it's some out-of-bounds read (texture atlas, see below).

Quote
Since these textures are repeated, it would actually make more sense to wrap the texture coordinates. It would have to be tested per-pixel, however it should be fairly fast (as long as textures are a power of two size), just a bitwise AND on each coordinate value. For a minecraft engine, this would also open up the ability to simplify meshes in large, flat areas of the same block.
The problem here is that I'm using a texture atlas.
As I preprocess every Chunk and basically just have to iterate over a array of vertices, I'd have to determine which texture to bind for every triangle.
That'd be horribly slow.
The problem is rather a rounding issue, as with fixed-point x / y = z can be true, but z * y = x doesn't have to be.
Or maybe I'm just completely wrong. Who knows. I'll have to fix those bugs anyway...

Quote
I'd say go for the fastest. It' only disturbing when blocks are really far.
Actually, with the improved indexed-rendering I'd have to do less floating-point calculations so it's not that slow.
Still 18 fps if textures enabled.

BTW: Who told me that floats wouldn't be much slower than fixed-point? It was you, Levak, wasn't it?


Quote
I'd say that you should include both mode (with and without textures) in the final version so that we can make beautiful screenshots with textures and build quickly too
(not that it is slow with textures, but it is faster without so if we want to make quick changes, we might want a quick way).
That'd mean switching without recompiling, the problem here is that I enable and disable textures by #define ing TEXTURE_SUPPORT
and an if EVERY PIXEL would be horribly slow. So:
- Code duplication (Copy nglDrawTriangle)
- Ugly preprocessor usage: Move nglDrawTriangle into a header file and #include it with various #define s.

Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 23, 2014, 12:51:10 pm
Quote
Since these textures are repeated, it would actually make more sense to wrap the texture coordinates. It would have to be tested per-pixel, however it should be fairly fast (as long as textures are a power of two size), just a bitwise AND on each coordinate value. For a minecraft engine, this would also open up the ability to simplify meshes in large, flat areas of the same block.
The problem here is that I'm using a texture atlas.
As I preprocess every Chunk and basically just have to iterate over a array of vertices, I'd have to determine which texture to bind for every triangle.
That'd be horribly slow.
The problem is rather a rounding issue, as with fixed-point x / y = z can be true, but z * y = x doesn't have to be.
Or maybe I'm just completely wrong. Who knows. I'll have to fix those bugs anyway...
Why not do it like array textures in OpenGL?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 23, 2014, 12:55:29 pm
Why should I?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 23, 2014, 03:14:38 pm
It avoids all the problems of texture atlases while still being a fast way to access multiple textures. You bind to one texture, and then because the format and size of the different textures in the array are the same, you only need to select the appropriate location for the texture data, which can be done by storing an integer ID with every triangle. All the pixels from one texture will be together, increasing cache coherency as well.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 23, 2014, 03:50:17 pm
Quote
It avoids all the problems of texture atlases
Which problems? Without texture atlasses I would have the same problems as I have no.

Quote
You bind to one texture, and then because the format and size of the different textures in the array are the same, you only need to select the appropriate location for the texture data, which can be done by storing an integer ID with every triangle.
That's the problem. I'd have to switch the texture (even if it's just a id or pointer) every triangle and ALSO have UV-coordinates.
Of course it's nicer from the application's point of view.

Quote
All the pixels from one texture will be together, increasing cache coherency as well.
What about texture atlasses?

Edit: I built a quick hack into the engine:
(http://img.ourl.ca/crafti_nice_tex.png)
The remaining artifacts are a mixture of inaccuracies and rounding errors.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on February 23, 2014, 04:26:00 pm
Wow that looks awesome O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 23, 2014, 11:08:36 pm
The problem with the texture atlases is that you can't wrap the coordinates, which will eliminate all the out-of-texture-bounds artifacts you are getting. An optimization to the switching textures problem would be to group the triangles with each texture together.
Consider the following atlas:
AABB
AABB
CCDD
CCDD
It would get stored as AABBAABBCCDDCCDD. An array would get stored AAAABBBBCCCCDDDD - all the information for each individual texture is together in memory. I don't actually know how big the cache is in the Nspire's CPU and whether it would make a difference, but it can't hurt.

Another thing that might help is to set GCC to the highest optimization level if you haven't already.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 24, 2014, 08:57:00 am
Quote
The problem with the texture atlases is that you can't wrap the coordinates, which will eliminate all the out-of-texture-bounds artifacts you are getting
No, it won't. It would just look different!

Quote
Consider the following atlas:
AABB
AABB
CCDD
CCDD
It would get stored as AABBAABBCCDDCCDD. An array would get stored AAAABBBBCCCCDDDD - all the information for each individual texture is together in memory.
Could work, but wouldn't make a huge difference. 2*16*16 = 512 Byte, no problem for the cache to store multiple textures.

Quote
Another thing that might help is to set GCC to the highest optimization level if you haven't already.
My flags: -O3 -Wall -W -marm -ffast-math -mcpu=arm926ej-s -fno-math-errno -fno-tree-vectorize -fomit-frame-pointer -fno-exceptions
any suggestions?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on February 24, 2014, 01:48:16 pm
It's weekend again, so some more progress:
  • Replaced terrain.png with original terrain.png from Minecraft (Copyright Mojang AB)
  • Trees
  • Infinite world generation (The trees are the only thing changing for now)
  • Faster startup (cos uses sin_lut)
  • Faster

With textures it's smooth now also with some more blocks visible (~25 fps):
(http://i.imgur.com/RX4HMdy.gif)

I had to use imgur for that one as I couldn't upload it to img.ourl.ca.
The file was probably too large and every file I try to upload now (name doesn't matter)
doesn't get uploaded and it shows "crafti_world.gif" (the old file name!) was uploaded successfully and a 404 NOT FOUND next to it...

Without textures we can expand the viewable distance a bit further and we get to ~11 fps:
(http://img.ourl.ca/crafti_world2.gif)

But for comparision fps-wise with the same distance as with textures above (~40 fps):
(http://img.ourl.ca/crafti_world3.gif)

Known bugs:
-Weird lines if textures enabled
-Sometimes a triangle hitting the right screen border shows random data if textures enabled
-Sometimes it displays garbage if perfectly aligned to Z axis
Woah, if you or someone else can pull off a Minecraft game running this fast, this will be an HUGE milestone for the TI-Nspire and I bet this would be quite popular too. I am particularly amazed at how fast it runs even with textures and such viewing distances. The non-textured version with short view distance still looks very nice too, though. O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: fb39ca4 on February 25, 2014, 01:16:33 am
Ok, looks like you have already turned them on.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Keoni29 on February 25, 2014, 11:16:55 am
Is this demo optimized for cubes or will it run as fast when it's smooth terrain with the same amount of vertices?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 25, 2014, 12:29:03 pm
Quote
Is this demo optimized for cubes
Kind-of. I generate a list of Positions (x,y,z) and a list of IndexedVertices (a reference to a position, a color and uv-coordinates).
As it's likely that a position is used multiple times (flat area: each position 4 times), I don't have to transform it more than once.

But as "transformation" also includes perspective, I can't do z-clipping before perspective projection, which is bad
as divisions / 0 or a really small value can happen. And they do happen if I increase the cube size or the camera is in a bad spot.
I'll have to fix this, although it may get slower. I don't know what dominates here, the few "perspective divide"s I don't have to do because of z-clipping
or the "perspective divide"s I will have to do because of z-clipping (If you know what I mean)

Quote
will it run as fast when it's smooth terrain with the same amount of vertices?
It depends on how much triangles are visible. The "benchmarks" I performed earlier in this thread were totally wrong as my line drawing is slooooowwww.
Even slower than triangles. I don't now how I did that...

Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on February 27, 2014, 03:01:11 pm
It is really great! But it only makes my calculator crash... =/
It is a TI-Nspire CX CAS. Crashes when I launch it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 27, 2014, 03:03:04 pm
That's weird. Which version of ndless and crafti are you using?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pbfy0 on February 27, 2014, 04:43:35 pm
I'd like to try this, but it also causes my calculator to crash.
I have a nspire CX CAS and i'm using ndless 3.1 r914 and crafti 0.3. I'm using Nlaunchy to dual boot with OS 3.6, if that matters.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 27, 2014, 04:51:36 pm
I'm testing on the emulator under the exact same conditions. My calc currently runs on OS 3.6 and switching just takes so long...
Could you try this version?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pbfy0 on February 27, 2014, 05:00:37 pm
No, it still crashes. Sorry.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 27, 2014, 05:02:25 pm
You don't have to apologize ;)
I'll try it on my calc tomorrow.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on February 28, 2014, 09:33:36 am
Sorry, it crashed because I had ndless r877. With the r914, it works, but after a short trip, the calculator crashed. I don't have nLaunch. I'm using crafti 0.3.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ExtendeD on February 28, 2014, 10:00:46 am
Maybe adding some assert_ndless_rev() would prevent crashes on old Ndless versions?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on February 28, 2014, 10:46:32 am
I went through the code again and found a call to vprintf in my substitute to the irq-disabling printf...
I'll upload when I'm done with a better clipping algorithm and nicer perspective calculations.
Both should result in fewer artifacts and crashes, if they were related to drawing across the screen borders and thus overwriting some innocent memory which didn't seem to hurt the emulator.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 03, 2014, 08:13:23 pm
It's carnival here in germany and therefore holidays  :D
I got around to nGL and crafti and played around with the graphics pipeline to split projection and transformation.
This fixes the division/near-zero error and therefore most artifacts but it got a lot slower as I cannot cache any vertices for projection as easily as before.
1 and 3 change the block type you'll put down (actually changing, adding isn't implemented yet).
Moving around works exactly like before but now collision detection makes it impossible to move into blocks now :P
I haven't tested the current version on my calculator (it works in nspire_emu, ndless r914 without crashes) and I'll upload it when I confirmed that it doesn't only work on virtualized calculators.
(http://i.imgur.com/Ba3F2MK.gif)
TODO:
-Looking around by touching the touchpad, not by clicking
-Fix remaining bugs
-Add blocks
-GUI
-Save and load world
-Optimize!

Edit: It works on my calc. The FPS counter doesn't like to be used simultaneously with the keypad, so I had to disable it for now.
I also disabled Z_CLIPPING so triangles will be completely discarded if only partially visible. I appreciate any kind of feedback!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on March 04, 2014, 01:28:15 pm
Perfect, now, there isn't any crash on my calc! Just a point: I have the impression to fly one block over the floor. By the way: did the system light disappear?  Blocks of the same color are undistinguishable. To have a further view, you could enable textures only for the close blocks. Why is the scenery built per big blocks and not normal blocks? (when we walk, a cube of blocks are built on the same time).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 04, 2014, 01:36:42 pm
I'm splitting the world into chunks (16x16x16 blocks) which makes things much easier.
As I mentioned earlier, I cannot color textured triangles, as it would require 3 multiplications per pixel.
I could create a second texture and preprocess it, but that would either increase startup time, memory footprint or executable size.
The speed difference between textured blocks and untextured blocks is so insignificant, that a simple if(texture != nullptr) would slow things down more than simply enabling textures the whole time. I could, of course copy the function and split it into nglDrawTexturedTriangle and nglDrawTriangle, but that's code duplication.
What do you think?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on March 04, 2014, 02:19:07 pm
I think a filled triangle should not be as fast as a textured triangle... Because a textured triangle works with a per-pixel basis, and a filled triangle with a per-line basis. You must be doing something wrong in your triangle filling.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 04, 2014, 02:44:31 pm
The inner loop of nglDrawTexture is:
Code: [Select]
for(int x = x1; x <= x2; x += 1, ++z_buf, ++screen_buf)
{
    if(__builtin_expect(*z_buf > z, true))
    {
        *z_buf = z;
        #ifdef TEXTURE_SUPPORT
            *screen_buf = texture->bitmap[u.floor() + v.floor()*texture->width];
        #else
            *screen_buf = low->c;
        #endif
    }
    #ifdef TEXTURE_SUPPORT
        u += du;
        v += dv;
    #endif
    z += dz;
}

Another conditional branch per pixel would ruin the performance.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 06, 2014, 05:34:46 pm
It took a bit longer this time, I had to trace a really weird bug down to an overflow in the backface culling function  :banghead:
The first playable release of crafti! :w00t:
(http://img.ourl.ca/PICT0978_640p.JPG)
Changes:Please tell me what you think!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: annoyingcalc on March 06, 2014, 09:54:48 pm
Wow, this is so much better than nCraft!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on March 08, 2014, 08:41:54 am
The use of the touchpad like a mouse is really a great idea! :o
The problem of the splitting into 16x16x16 pixels is that the variation of the length of view can have a factor of 2... Why not split into 8x8x8?

I can't wait to be able to save! :p
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on March 08, 2014, 12:21:57 pm
What are your settings for nover to play this?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 08, 2014, 12:42:48 pm
Quote
What are your settings for nover to play this?

You don't need nover at all, in fact, it would make it even slower as crafti's performance is more dependant on memory speed than CPU frequency.
As you would have to decrease the AHB freq., it also decreases SDRAM speed. I didn't measure anything as the fps timer doesn't work reliably yet.

Quote
The use of the touchpad like a mouse is really a great idea!
The problem of the splitting into 16x16x16 pixels is that the variation of the length of view can have a factor of 2... Why not split into 8x8x8?

It's easier to have those chunks only on one layer. As 8 blocks maximum height isn't enough, it would mean stacking chunks on top of each other.
That complicates the terrain generation (currently two sine waves) and it would degrade performance a bit as more blocks are neighbors of other chunks,
which means calculating the global block position, finding the corresponding chunk and calculating the local block position in the chunk for every block of the chunk's edges. Chunk loading is also horribly slow (light calculations, notifying the chunks around it, building the mesh) so it would be quite noticable when you're walking around. But I'll try it, I need to find the perfect size first before I implement saving.

Quote
I can't wait to be able to save! :p

Don't worry, I already started implementing it, only a matter of some weeks  ;D
I'll also try to improve terrain generation and create a nice menu and inventory/HUD.
Should I go the creative-mode way or rather survival-mode?

Edit: Implemented loading and saving. You can also make a file extension association in your ndless.cfg.tns (untested). Please tell me whether it works for you! The default filename is /documents/ndless/crafti.map.tns
 
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on March 09, 2014, 08:24:57 am
The file association works! Could you add a loading bar when we quit the program when it saves the world?

Now, if I could suggest something: make the different same nature blocks distinguishable.

Thanks a lot for your work. :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 09, 2014, 10:07:35 am
Quote
The file association works! Could you add a loading bar when we quit the program when it saves the world?
The next thing I do will be a nice menu. A "saving bar" is unnecessary in my opinion (and difficult to implement as loading/saving isn't async).

Quote
Now, if I could suggest something: make the different same nature blocks distinguishable.
How? Exactly how I did it when textures are disabled? (color *= 0.8f)
Or two different texture packs?
Both versions would increase loading time (before you can see anything) as I either have to precalculate the textures or load another one.
Or should I seperate textures from the main executable which also makes "texture packs" possible?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on March 09, 2014, 10:59:24 am
A "saving bar" is unnecessary in my opinion (and difficult to implement as loading/saving isn't async).
It enables the user to know that it is normal that nothing happens and to know how much times he has to wait. If it is difficult to know the time needed to save, you could just display on the screen "saving...".

Quote
How? Exactly how I did it when textures are disabled? (color *= 0.8f)
Or two different texture packs?
Both versions would increase loading time (before you can see anything) as I either have to precalculate the textures or load another one.
Or should I seperate textures from the main executable which also makes "texture packs" possible?
Not like when textures were disabled but put a different luminosity for each side (the same for all tops, the same for all east-oriented faces etc.). But yes for color*=0.8f. Since the loading time is currently really short, I think the better solution is the precalculation.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 09, 2014, 05:33:45 pm
The next version is ready!
New features compared to v0.5:
- Loading and saving (If you exit with ESC it's saved automatically)
- File association (configure with ndless.cfg.tns) for worlds
- Blocks can have a different texture on each side
- More blocks: redstone ore, iron ore, gold ore, diamond ore, sponge, dark planks, bright planks, tnt, furnace, crafting table, bookshelf
- A menu you can open with the menu key (8+2: Choose option 5: Select)
- An "inventory" with all available blocks (period key)

Animated screenshot of nspire_emu:
(http://i.imgur.com/jq4svm6.gif)
Disclaimer: It's a gif, so some colors look really awful. The menu transparency looks better than it does here.

If you want to compare the speed of nspire_emu vs. hardware, open the menu on your calculator!

A "saving bar" is unnecessary in my opinion (and difficult to implement as loading/saving isn't async).
It enables the user to know that it is normal that nothing happens and to know how much times he has to wait. If it is difficult to know the time needed to save, you could just display on the screen "saving...".
It doesn't take a noticable amount of time to load and save. The delay you experienced was the call to refresh_osscr() which isn't really necessary, so I removed it.

Quote
Quote
How? Exactly how I did it when textures are disabled? (color *= 0.8f)
Or two different texture packs?
Both versions would increase loading time (before you can see anything) as I either have to precalculate the textures or load another one.
Or should I seperate textures from the main executable which also makes "texture packs" possible?
Not like when textures were disabled but put a different luminosity for each side (the same for all tops, the same for all east-oriented faces etc.). But yes for color*=0.8f. Since the loading time is currently really short, I think the better solution is the precalculation.
But that would mean on a "wall"-like structure you couldn't see where you put a block. Checkerboard ((x + y + z) % 2 == 0) would make more sense, I think.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on March 09, 2014, 06:05:29 pm
Good progress so far!
Could this eventually turn into a full version of minecraft, (with a random map generator, animals, ground 10+ blocks deep) or is the Nspire processor too slow? :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 09, 2014, 06:53:11 pm
Wow, if it wasn't for the weird sky, someone could almost think it's the real game O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Spenceboy98 on March 09, 2014, 06:56:08 pm
Is there no .tns in the .tar.gz file? I can't seem to find it. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Piguy-3.14 on March 09, 2014, 08:05:13 pm
I feel stupid but you can download this right? I don't see a link anywhere... Update: never mind got it
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 10, 2014, 02:24:45 am
Yeah I just tried it and it's amazing. For some reasons, though, the speed on my calc is pretty much worse than in nCraft, although it's still much better considering there are textures and much deeper field of view. I am wondering if it could be because I am running an older hardware (revision B or C I think) or due to outdated Ndless version? I generally get between 2 and 8 FPS depending of how many blocks there are on the screen. My calc's AHB is setup to 66 MHz btw.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 10, 2014, 05:02:31 am
Quote
Is there no .tns in the .tar.gz file? I can't seem to find it.
It is in there, somewhere.

Quote
Yeah I just tried it and it's amazing. For some reasons, though, the speed on my calc is pretty much worse than in nCraft, although it's still much better considering there are textures and much deeper field of view. I am wondering if it could be because I am running an older hardware (revision B or C I think) or due to outdated Ndless version? I generally get between 2 and 8 FPS depending of how many blocks there are on the screen. My calc's AHB is setup to 66 MHz btw.
That shouldn't be the case, it runs much faster than nCraft (though slower than nspire_emu, which says 16-18) on my calc (~10fps, never below 5)
The hardware revision shouldn't make any difference.

BTW: Could it be that you have to login now to download files?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on March 10, 2014, 06:04:08 pm
It runs at about 10 fps laggily on my calc, 198mhz cpu and 66mhz ahb.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 10, 2014, 06:07:13 pm
That's about the same for me, but I think 10fps are enough, so I'm not doing any searches for optimizations anymore.
Any suggestions for new features?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on March 10, 2014, 06:18:14 pm
A random map generator with water and animals, and a deeper ground would be nice. I think it would be worth cutting a bit of the field of vision to make the ground deeper (like 10 blocks with ores) and have animals. There's also a bug where you can place a block where you are standing, and you can't move until you destroy it, and it gives you a glitchy image.


It runs at about 8fps at 132mhz and maybe around 12 at 198mhz, so it's probably worth overclocking the cpu to play(the ahb stays at 66mhz).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 09:45:30 am
I found a bug in the ndless program startup code (no static and global vars initialized) so I had to debug it first before working on crafti.
The fix didn't make it into the newest ndless-sdk at time, so if you try to compile it yourself, it will crash. I included a version with textures disabled, if you want to use it. But it looks really ugly. And yes, it should work with ndless 3.6 out-of-the-box. I didn't test the current version, though.

New features in v0.7:

The world generation is a lot slower than before, so while walking it will take some time. But once it's generated, you're able to walk without interruptions.
I also had to change the savefile format version, so older save files will not work with this version.

(http://img.ourl.ca/crafti_worldgen.png) (http://img.ourl.ca/crafti_ores.png) (http://img.ourl.ca/crafti_deeper.png)

TODO:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on March 16, 2014, 10:56:47 am
can you interact w/ blocks yet???

ps.this is amazing!!!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on March 16, 2014, 11:00:56 am
This looks soooo cool :D Is it compatible with monochrome calcs ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 11:06:28 am
No, and as I don't have one, I wouldn't be able to test it. (other than nspire_emu)
It should be fairly trivial to make it compatible, if you rewrite nglDisplay to convert the screen buffer and switch the display controller from 4-bit into 8-bit mode.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on March 16, 2014, 11:12:46 am
I like the new grass blocks! Great work!

You should maybe use a height of only 20 blocks because the world generation is really really slow.
Suggestion: not need to jump to climb on a simple block. It would enable to climb stairs without jumping.

The world generated may be too embossed.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on March 16, 2014, 11:25:34 am
can you use blocks like a crafting table or furnace yet?????
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 11:57:48 am
Quote
I like the new grass blocks! Great work!
I know I'm good at stealing minecraft's terrain.png.. But I'll have to change that sooner or later..

Quote
You should maybe use a height of only 20 blocks because the world generation is really really slow.
I know, but the height doesn't matter that much. It's more the smaller chunk size.
Quote
Suggestion: not need to jump to climb on a simple block. It would enable to climb stairs without jumping.
I find jumping better than just "glitching" on top of a block.

Quote
The world generated may be too embossed.
The generator has a maximum height of 0.7 times the world height.

Quote
can you use blocks like a crafting table or furnace yet??
No, what should they do? There is no inventory or items at all and all available blocks are accessible through "."
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 16, 2014, 12:03:28 pm
Yay for grass blocks! :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 02:40:26 pm
Bugfix release 0.7.1:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on March 16, 2014, 04:01:55 pm
How many bits does one block occupy in memory ? Because if you use 32 bits for each block, that is kind of a waste and that's a spot where you could save space, not only in the savegame, but also in the cache (which means a faster game overall :D)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on March 16, 2014, 04:04:01 pm
Consider that 32 bits leaves room for data storage for things like chests, redstone, spawners, etc.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on March 16, 2014, 04:08:52 pm
Well I don't think 32 bits are necessary for one block. Even 16 is a lot. Since there are less than 256 blocks, 8 bits is enough to know the type of a block, and the 8 remaining bytes can be used for some information (like the number of the chest if you placed several chests), but I don't think you really need 32 bits.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 04:22:40 pm
Currently I have a typedef uint8_t BLOCK in the code and the chunk data is a BLOCK[8][8][8] which is directly fread or fwritten into a file.
If I'll add a feature which requires some data storage for a block, I'll either make a BLOCK 16 bits wide or use a seperate array.
A seperate array will be faster and easier to handle than a interleaved array.
For blocks which require more storage, I'll store a unique ID in the extra 8 bits and reference it to the specific data.
But such things are far away now... Probably further away than the next nspire OS release blocking ndless...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on March 16, 2014, 04:31:58 pm
(can't find the button to remove my post -.-)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 16, 2014, 04:35:12 pm
(can't find the button to remove my post -.-)
Which post? I can't find the button on my posts earlier. I could swear it was there earlier this day...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on March 16, 2014, 04:36:56 pm
Well to remove the post you quoted and which was a test. I was sure I could delete it too, with a red cross button, but now I can't find it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 16, 2014, 09:09:07 pm
Bug report in the latest version: I keep getting stuck in blocks it seems because everytime I jump somewhere I can,t move anymore afterward until I destroyed the blocks under me.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Piguy-3.14 on March 16, 2014, 11:28:06 pm
:( this looks sooo cool but I can't get it bc it requires ndless and I can't figure out how to get it to work on my nspire. Can someone help I really want to try this game it looks pretty nice:)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on March 16, 2014, 11:39:07 pm
Check out the links on the front page for information on getting Ndless 3.6 going.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on March 17, 2014, 07:16:34 am
can you post the .tns file by its self so noobs like me can just download and send it to our calc?
thank you and good job!!!!!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on March 17, 2014, 09:25:23 am
Just extract the file with 7zip and craft.tns should be in there.
@DJ_O I had that glitch too, but it got fixed by making the field of vision a bit longer by pressing +. I think what's happening is you're jumping into a place before the calc has loaded it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 17, 2014, 11:42:54 am
Ah I see now. Yeah I kept it somewhat low so it doesn't take 3-4 seconds before the next chunk loads. The wait got a bit annoying compared to the older version. D:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on March 17, 2014, 11:51:35 am
Jup, that's an issue with chunk loading. If the view distance is at 1 (the current minimum) some adjacent chunks aren't loaded because I iterate through each chunk and do a if(dist <= sqrt(x*x + y*y + z*z)) to determine whether to render it. Did noone yet find the bug that a chunk isn't rendered if you stand on it and look in the wrong direction? :P

Quote
@DJ_O I had that glitch too, but it got fixed by making the field of vision a bit longer by pressing +. I think what's happening is you're jumping into a place before the calc has loaded it.
If you have any issues please let me know! Otherwise I may think it's not as important or it doesn't happen often.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on March 17, 2014, 12:10:06 pm
For me it pretty much happens everytime >.< (well, unless vision is set to high)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on March 17, 2014, 01:24:00 pm
It's really nice. I think the critter you should add first might actually be, if it's possible, a view of Steve himself. Or pigs; they're tasty. :)

I am unable to test it, so I don't know if smelting and crafting is in yet, but if not, it probably should be added as soon as possible.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 16, 2014, 09:53:28 am
Just a short update, I'm currently not developing crafti, I'm currently working on finishing newlib integration into ndless.
Then I'll finally be able to use the C++ stdlib fully, including iostream, fstream and such.
When it's ready I'll optimize world generation speed and speed in general. I think I may get another frame or two per second :)
Any other issues except those which are generator related?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on April 16, 2014, 11:28:27 am
A few graphics glitches, like sometimes you can see through blocks when viewed at a certain angle (happens a lot when you dig underground), but overall it's pretty good. Also, if you dig too deep you fall out of the world. Bedrock would help a bit.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on April 16, 2014, 02:59:58 pm
YEah I agree about bedrocks. Also do you think, grass, water and lava (including their flow/physics) would be hard to implement?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 17, 2014, 04:51:06 pm
Really, REALLY cool!

Could there be a readme file though please?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 17, 2014, 06:15:25 pm
Quote
Also do you think, grass, water and lava (including their flow/physics) would be hard to implement?
Grass flow? Do you mean grass spreading onto nearby dirt blocks?

Quote
Really, REALLY cool!
Thanks!

Quote
Could there be a readme file though please?
What should be in there? Instructions, controls, changelog, license?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on April 17, 2014, 09:09:22 pm
If the terrain generation is slow on the calculator, then maybe there could be an option to generate maps on a computer and then transfer them to your calc. Just an idea. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: willrandship on April 17, 2014, 10:12:20 pm
Having the standard library would help ndless development immensely. More power to you.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 18, 2014, 09:12:11 am
The readme should include instructions
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 18, 2014, 03:04:29 pm
Crafti is now on GitHub (http://github.com/Vogtinator/crafti).
Changes in v0.7.2:
- Faster world generation (should be fast enough now)
- Fixed bug if the maximum chunk distance was too small
- Other texture pack, wooden planks look a bit weird. If you can find a better one with a suitable license please tell me!
- Add README.md

Yeah, it's just a bugfix release, I'm now slowly integrating the new possibilities with full newlib+libstdc++ (e.g. fstream) and fixing bugs on the way.
There's a lot to clean up now, so progress may be a bit slow.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 18, 2014, 04:38:19 pm
Nice job! :)
Did you ever get elf2flt to speed up when linking against libstdc++? When I tried last time, it took forever and froze my computer.

Also: in the README, it says you're using something called PerlinNoise, which is licensed under the GPL. So shouldn't the whole program be GPL'd to comply with the license?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 18, 2014, 04:55:20 pm
Quote
Nice job!
Did you ever get elf2flt to speed up when linking against libstdc++? When I tried last time, it took forever and froze my computer.
Somehow the bug resolved itself with the last change to the libstdc++ compile flags (I think -fpic)

Quote
Also: in the README, it says you're using something called PerlinNoise, which is licensed under the GPL. So shouldn't the whole program be GPL'd to comply with the license?
It's basically CC-NC-SA except for the PerlinNoise class and the texture. The texture didn't contain a license so I didn't care.
I don't know whether CC-NC-SA exists or is compatible with the GPLv3, I'm not too familiar with licenses but I don't think it was that hard of a work to copy the offical PerlinNoise source and change the syntax a little. If you think that's an issue, I'll probably make it GPLv3.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 18, 2014, 05:24:30 pm
CC-NC-whatever isn't compatible with GPL.
The texture shouldn't matter because you aren't linking with it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 18, 2014, 05:56:32 pm
Quote
The texture shouldn't matter because it's just data.
So if anyone draws anything and publishes it, it's just data?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 18, 2014, 05:57:40 pm
What I mean is that it's not code that you're linking with, sorry if the wording was bad.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on April 18, 2014, 08:17:45 pm
n00b question alert!
The default textures seem very dark and moody. Can I make them more like the regular PC Minecraft textures.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 18, 2014, 08:23:39 pm
Yup, download the ConvertImg tool I posted here earlier, compile it using the Qt SDK, run it, replace the terrain.h file in the crafti directory and rebuild it.
Alternatively you can also send it to me. A texture loader is on my TODO list.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on April 19, 2014, 01:34:38 am
Quote
Also do you think, grass, water and lava (including their flow/physics) would be hard to implement?
Grass flow? Do you mean grass spreading onto nearby dirt blocks?
THat would be nice, although just at least having grass at all would already be cool as well (since now it's pretty much desertic lol)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 19, 2014, 07:23:15 am
Quote
Also do you think, grass, water and lava (including their flow/physics) would be hard to implement?
Grass flow? Do you mean grass spreading onto nearby dirt blocks?
THat would be nice, although just at least having grass at all would already be cool as well (since now it's pretty much desertic lol)
? I added grass blocks in 0.7 IIRC.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 19, 2014, 05:38:11 pm
It is fast now!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on April 19, 2014, 08:08:11 pm
When i try to compile using the source from Git, it says that nucleus.h is not found.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 19, 2014, 08:10:06 pm
You can either replace it by "os.h" or use my fork of ndless (http://github.com/Vogtinator/ndless)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 20, 2014, 04:23:34 pm
New feature release: v0.8!
New features:
- Crafti now uses block data (8 bits per block), which means your save files won't be compatible
- Torches in all directions (even upside-down)!
- Flowers!
- Mushrooms!
- Spider webs!
- Cake!
- Faster chunk culling!
- Ability to load external textures ("/documents/ndless/crafti.ppm.tns") in PPM format (24bit binary)
- A splash screen (From the internet, I only added the text "crafti")!
- Message "Loading" now shown when crafti is doing some heavy processing
- Disabled the mode with textures disabled, it was too ugly and slowed down the startup somewhat

Bugs fixed:
- Clock on screen

Known issues:
- With HD textures the block selection menu becomes unusable (but 1 and 3 still work)
- Front side of blocks is fixed (all furnaces face the XY-Plane)
- CLIP_PLANE too close
- Can rotate more than 90° horizontally, which turns the screen upside-down
(I'll probably fix all of them in v0.8.1, but that'll likely take a while)

Screenshots (BTW, hd textures don't make the game slower  ;) ):
(http://img.ourl.ca/crafti_splash.png)     (http://img.ourl.ca/crafti_hd_good.png)
(http://img.ourl.ca/crafti_torches.png)     (http://img.ourl.ca/crafti_block_list_v0.8.png)

What should I implement next?

And BTW, I'd be very glad if anyone could design a better menu or "Loading" message for me, I suck at art  ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 20, 2014, 04:26:07 pm
Holy snap that's totally epix. *.*
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 20, 2014, 08:31:22 pm
Oops, I just found a typo in the ppm loader: "0x11111" instead of "0b11111". The result is green all above the texture atlas...
I fixed it in the attachment above, that fix doesn't deserve a version number ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 20, 2014, 08:52:35 pm
I didn't follow development but the fact that you pulled off a textured voxel engine (even though without lighting) at a pretty decent speed is quite impressive.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 20, 2014, 10:49:26 pm
That looks really awesome! This is the first time I tried it on a real calc, and the speed is really decent. :)
I think it's a little weird that it says "loading" when exiting, though. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on April 21, 2014, 02:14:15 am
This is looking better and better :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on April 21, 2014, 02:17:00 am
Wow, very nice update ! Good work :D

What should I implement next?
A readme ? :P
Maybe even an ingame readme in case people forgot which was the key to do some specific action.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on April 21, 2014, 02:23:15 am
Indeed. When I tried the program I had to search through a dozen of pages of replies just to find the controls and I still felt I missed some.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 21, 2014, 11:52:27 am
Quote
I didn't follow development but the fact that you pulled off a textured voxel engine (even though without lighting) at a pretty decent speed is quite impressive.
I find lighting rather annoying. And what's the difference between a "voxel engine" and 3D triangles? AFAIK a voxel engine is optimized for different sizes of voxels and has a better storage and rendering algorithm (most of the time with octrees).

Quote
That looks really awesome! This is the first time I tried it on a real calc, and the speed is really decent. 
I think it's a little weird that it says "loading" when exiting, though.
I didn't want to make a second "Saving" image.. But I'll fix that when fonts are working!

Quote
Indeed. When I tried the program I had to search through a dozen of pages of replies just to find the controls and I still felt I missed some.
Quote
A readme ? 
Maybe even an ingame readme in case people forgot which was the key to do some specific action
Umm, README.md has been there since v0.7.2.
A ingame readme would be nice, but I'd have to add font rendering first.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 21, 2014, 12:33:33 pm
Quote
I didn't follow development but the fact that you pulled off a textured voxel engine (even though without lighting) at a pretty decent speed is quite impressive.
I find lighting rather annoying. And what's the difference between a "voxel engine" and 3D triangles? AFAIK a voxel engine is optimized for different sizes of voxels and has a better storage and rendering algorithm (most of the time with octrees).
Well I thought voxel engine = cube tilemap renderer but w/e. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TIfanx1999 on April 21, 2014, 01:14:07 pm
New feature release: v0.8!
New features:
- Crafti now uses block data (8 bits per block), which means your save files won't be compatible
- Torches in all directions (even upside-down)!
- Flowers!
- Mushrooms!
- Spider webs!
- Cake!
- Faster chunk culling!
- Ability to load external textures ("/documents/ndless/crafti.ppm.tns") in PPM format (24bit binary)
- A splash screen (From the internet, I only added the text "crafti")!
- Message "Loading" now shown when crafti is doing some heavy processing
- Disabled the mode with textures disabled, it was too ugly and slowed down the startup somewhat

Bugs fixed:
- Clock on screen

Known issues:
- With HD textures the block selection menu becomes unusable (but 1 and 3 still work)
- Front side of blocks is fixed (all furnaces face the XY-Plane)
- CLIP_PLANE too close
- Can rotate more than 90° horizontally, which turns the screen upside-down
(I'll probably fix all of them in v0.8.1, but that'll likely take a while)

Screenshots (BTW, hd textures don't make the game slower  ;) ):
(http://img.ourl.ca/crafti_splash.png)     (http://img.ourl.ca/crafti_hd_good.png)
(http://img.ourl.ca/crafti_torches.png)     (http://img.ourl.ca/crafti_block_list_v0.8.png)

What should I implement next?

And BTW, I'd be very glad if anyone could design a better menu or "Loading" message for me, I suck at art  ;D

My goodness, that looks fantastic! :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 21, 2014, 02:23:22 pm
For fonts, you can use nGC or Freetype (which works without any changes)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 21, 2014, 03:23:15 pm
Quote
My goodness, that looks fantastic!
Thanks  :)

Quote
For fonts, you can use nGC or Freetype (which works without any changes)
Does nGC support rendering into (raw) buffers with different width than the screen?

How big is Freetype? Doesn't it need a .ttf for rendering?

Writing a custom font rendering routine is easy, I only need two different font sizes, and I need real performance.
nGC uses the OS' font routines AFAIK which are slow and ugly, Freetype is probably slow as it's using splines, bezier-curves and such things.

I need speed because if I want to show text above a changing background, I'd have to render it every frame and transparency doesn't work with black fonts. I could probably find a workaround but rendering text into a buffer isn't exactly brilliant.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 21, 2014, 05:32:57 pm
I don't remember the details about freetype, but I can give you a sample program. It is fast, and not that big.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on April 21, 2014, 05:36:06 pm
Bug Report: when I try running crafti, my nspire crashes and burns.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 21, 2014, 05:46:34 pm
Quote
Bug Report: when I try running crafti, my nspire crashes and burns.
Do you need a fire extinguisher? You'd have to pay the shipping cost, though :P
JK, it only crashes for me if I use a HD texture pack and open the menu. It overflows the screen buffer.
If that's not the cause, could you tell me your ndless revision, and if you know how to trigger the crash, could you upload your savefile and tell me how to reproduce?

Quote
I don't remember the details about freetype, but I can give you a sample program. It is fast, and not that big.
Hm, could you compile freetype into a static lib and make a pull request on github.com/OlivierA/Ndless? I'm sure it'll be useful. You should also include the sample.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: tr1p1ea on April 21, 2014, 05:47:51 pm
Gotta say, this looks incredible! Liking the new texture update.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: annoyingcalc on April 21, 2014, 05:48:08 pm
Wow, I'm not sure what else to say.

This looks amazing.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 21, 2014, 06:32:54 pm
Writing a custom font rendering routine is easy, I only need two different font sizes, and I need real performance.
nGC uses the OS' font routines AFAIK which are slow and ugly, Freetype is probably slow as it's using splines, bezier-curves and such things..
Well it depends whether you use a vector or bitmap font anyway. ;) Of course the latter is faster but the former scales better. Also with bitmap fonts you'll most likely have to scale down, which is much slower than scaling up. So maybe there isn't that much of a difference.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 21, 2014, 06:51:58 pm
Quote
I don't remember the details about freetype, but I can give you a sample program. It is fast, and not that big.
Hm, could you compile freetype into a static lib and make a pull request on github.com/OlivierA/Ndless? I'm sure it'll be useful. You should also include the sample.

Sure, I can do that :)

EDIT: While Im working on that, I would like to report that I also got a random crash. I unfortunately did not keep the savefile.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 22, 2014, 04:25:47 pm
will mobs ever be implemented?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 22, 2014, 04:35:04 pm
I think it will make the game lag a lot. A full Minecraft clone for the Nspire would be pretty hard actually. :/
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 22, 2014, 04:57:26 pm
Very true. But imagine how cool that would be!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 22, 2014, 05:14:32 pm
Mobs shouldn't be a problem speed-wise, but the game is not ready for them yet. (Crafting is very unlikely to happen, even if it's in the name - "crafti")
I actually thought of including a bunny that lays eggs in crafti v0.8 as it's easter, but I didn't have the time left.
I'm currently working on caves, fixing the v0.8 bugs and a lot of internal restructuring and refactoring.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 22, 2014, 05:20:10 pm
Also for the bugs, is it just me or do textures right up against the player seem really weird, especially underground?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 22, 2014, 05:20:27 pm
Wait, mobs are possible ? O.O
Why no crafting though ? Maybe it could be implemented similar to what Jens K did with MC2D ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 22, 2014, 05:24:44 pm
Quote
Also for the bugs, is it just me or do textures right up against the player seem really weird, especially underground?
Jup, for speed purposes I ignore the depth for texture mapping.

Quote
Wait, mobs are possible ?
Compared to the rest they consist of a fairly small amount of triangles!

Quote
Why no crafting though ? Maybe it could be implemented similar to what Jens K did with MC2D ?
Crafting means recipes, items, more GUIs, a cursor etc.
And a button "craft 10 planks from this wood" is just like no crafting at all.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 22, 2014, 05:27:13 pm
Well I was more thinking about the AI behind the mobs. It should be decent to be interesting.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 22, 2014, 06:01:47 pm
I wouldn't call the AI of pigs in minecraft complicated. Sometimes they just stay at the same place, they rarely walk around.
If they want to, they jump a few times into the air, and that's it. Even water is more complicated :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 22, 2014, 07:32:54 pm
LOL indeed but there is pathfinding for mobs that are supposed to follow you and it works pretty well.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: XiiDraco on April 23, 2014, 01:09:10 am
Don't even get me started about the path finding for most games. It is insanely easy (and fun!) to do.

Mine craft uses a hybrid version of A* for 3D planes to do the following.

The method is based off of a node grid and a cost at the expense of each node. The more nodes used the shorter the distance. When path finding you run an algorithm that checks nearby nodes and gets the cost values of the paths of a couple of the most logical paths, it then chooses the one with the shortest cost and follows it.


http://www.policyalmanac.org/games/aStarTutorial.htm
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 24, 2014, 12:21:43 pm
All I can say is that this project is really good so far!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 25, 2014, 12:49:56 pm
I added a poll above. I'm currently fixing some bugs and school starts monday again here in germany, so it'll take a while.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on April 26, 2014, 08:01:46 pm
Ugh, I dislike it when I vote, then see the results and I'm the only one who voted that.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on April 26, 2014, 09:28:47 pm
Ugh, I dislike it when I vote, then see the results and I'm the only one who voted that.
Same, I voted for ********.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on April 27, 2014, 04:21:02 am
Lol, same for me, I am the only one to think that the inventory is what should be added first.
We are not voting for the president so I tell everyone what I voted for and why.

I voted for the inventory because I thought it would not take ages to code (unlike mobs, water and lava or redstone) and would improve gaming experience a lot. Of course mobs, water and lava or redstone are more important features, but I didn't want mobs before being able to quickly build a house with the help of the inventory to protect myself, and the same applies for redstone, I would not want to build a circuit without a convenient menu to choose what to place, and I thought that a "little" update with the inventory was possible before the huge update with mobs, water and lava or redstone.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 27, 2014, 12:34:46 pm
Quote
I voted for the inventory because I thought it would not take ages to code (unlike mobs, water and lava or redstone)
After the necessary refactoring, water, lava and redstone should be very easy. Inventory would mean creating more textures and a whole new API.

Meanwhile I fixed the GUI issues with external textures and rotation beyond your neck's capabilities.
I won't publish v0.8.1 yet, as I still have to implent rotation of normal blocks, which requires refactoring a lot.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on April 27, 2014, 03:18:30 pm
I won't publish v0.8.1 yet, as I still have to implent rotation of normal blocks, which requires refactoring a lot.
So, upside-down stairs? :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 27, 2014, 03:25:24 pm
I won't publish v0.8.1 yet, as I still have to implent rotation of normal blocks, which requires refactoring a lot.
So, upside-down stairs? :)
Maybe. Stairs aren't implemented yet, but that shouldn't be much work. I was referring to furnaces, crafting tables, bookshelves and pumpkins, actually. Stairs are "special blocks" as they don't consist of 6 axis-aligned quads with coords aligned to BLOCK_SIZE which is necessary for optimizations.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on April 27, 2014, 03:33:41 pm
I won't publish v0.8.1 yet, as I still have to implent rotation of normal blocks, which requires refactoring a lot.
So, upside-down stairs? :)
Maybe. Stairs aren't implemented yet, but that shouldn't be much work. I was referring to furnaces, crafting tables, bookshelves and pumpkins, actually. Stairs are "special blocks" as they don't consist of 6 axis-aligned quads with coords aligned to BLOCK_SIZE which is necessary for optimizations.
Wait...what do you mean by rotation then? Will the firery side of the furnace face you when you place, or is it something different?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 27, 2014, 05:13:09 pm
I won't publish v0.8.1 yet, as I still have to implent rotation of normal blocks, which requires refactoring a lot.
So, upside-down stairs? :)
Maybe. Stairs aren't implemented yet, but that shouldn't be much work. I was referring to furnaces, crafting tables, bookshelves and pumpkins, actually. Stairs are "special blocks" as they don't consist of 6 axis-aligned quads with coords aligned to BLOCK_SIZE which is necessary for optimizations.
Wait...what do you mean by rotation then? Will the firery side of the furnace face you when you place, or is it something different?
Exactly that! The torches do that already (dependent on the side of the block you place it on).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 27, 2014, 06:15:43 pm
Will sunlight/shadows ever be implemented, rather than the global illumination?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 27, 2014, 06:23:13 pm
Unlikely, that would require three additional multiplications per pixel. Day/night should be possible, though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 28, 2014, 09:41:18 am
Per pixel?

What rendering algorithm does nGl use? I was guessing a raster engine
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 28, 2014, 11:13:42 am
Jup, I would essentially have to do:
Code: [Select]
for(int x = x_start; x <= x_end; ++x)
{
COLOR c = texture->bitmap[u + v*texture->width];
RGB rgb = fromCOLOR(c);
r *= light;
g *= light;
b *= light;
c = fromRGB(rgb);
screen[x + y*width] = c;
}
For each horizontal line of every triangle visible. Maybe it's possible to premultiply the textures, but for 4 different levels of light that's already 2MB for a 512px texture. I don't know, maybe in a later version.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on April 28, 2014, 12:44:35 pm
Maybe it's possible to premultiply the textures, but for 4 different levels of light that's already 2MB for a 512px texture. I don't know, maybe in a later version.

I was going to suggest exactly this. Keep in mind that (I believe) a lot of people are happy with the original 16px textures, and with those you could have copies of one texture for all 16 light levels in only 8KB. Of course, if you implemented this for all block types it would start to add up, but it would still only be about 2MB for basically every block in current Minecraft, which includes far more block textures than you'd need with the current set of blocks supported.

Also, hi. :P I normally don't tread outside of 83+/84+ threads, but this is the one thread that I make an exception for and keep track of because your work on this is awesome. Out of curiosity because I don't have an Nspire and couldn't see the statistics anywhere in recent posts, what's the performance of this like relative to the draw distance?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on April 28, 2014, 05:00:18 pm
If you mean draw distance as in how many chunks far you can see, then I'd say it's about 15fps with 3 chunks (or however many blocks are in one +/1) rendering distance(overclocked to 198MHz).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 28, 2014, 05:43:27 pm
Quote
I was going to suggest exactly this. Keep in mind that (I believe) a lot of people are happy with the original 16px textures, and with those you could have copies of one texture for all 16 light levels in only 8KB. Of course, if you implemented this for all block types it would start to add up, but it would still only be about 2MB for basically every block in current Minecraft, which includes far more block textures than you'd need with the current set of blocks supported.
Considering that the CX has 64MB RAM and the OS runs on older models with 32MB, there's at least 32MB free (maybe badly fragmented), so that could actually work quite well (but slow down startup time significantly). I added it in the poll above.

Quote
Also, hi. :P I normally don't tread outside of 83+/84+ threads, but this is the one thread that I make an exception for and keep track of because your work on this is awesome.
Thanks, what an houor :D

Quote
Out of curiosity because I don't have an Nspire and couldn't see the statistics anywhere in recent posts, what's the performance of this like relative to the draw distance?
Quote
If you mean draw distance as in how many chunks far you can see, then I'd say it's about 15fps with 3 chunks (or however many blocks are in one +/1) rendering distance(overclocked to 198MHz).
That entirely depends on how many triangles are visible. If you have a flat area, it's not much slower, but with hills it slows down quite a lot.
For viewing distance I compute the distance to each chunk with sqrt, so it's not a cubic area, more like a sphere. Anyway, I made a few "benchmarks" with nspire_emu (fps counter makes crafti instable on real HW, which is also quite a bit slower):

(http://img.ourl.ca/crafti_2_28fps_normal.png)Normal distance, 28 fps    (http://img.ourl.ca/crafti_2_22fps_normal%2B1.png)Normal + 1, 22 fps
(http://img.ourl.ca/crafti_2_17fps_normal%2B2.png)Normal + 2, 17 fps    (http://img.ourl.ca/crafti_2_10fps_normal%2B5.png)Normal + 5, 10 fps
(http://img.ourl.ca/crafti_2_36fps_normal-1.png)Normal - 1, 36 fps    (http://img.ourl.ca/crafti_2_57fps_normal-2.png)Normal - 2, 57 fps
(http://img.ourl.ca/crafti_2_41fps_up%2B5.png)Looking up at Normal + 5, 41 fps

And yeah, I should probably make a video. GIFs are so damn ugly with just 256 colors but on the other hand it's quite annoying to record with a camcorder and play simultaneously.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on April 28, 2014, 06:12:11 pm
Quote
I was going to suggest exactly this. Keep in mind that (I believe) a lot of people are happy with the original 16px textures, and with those you could have copies of one texture for all 16 light levels in only 8KB. Of course, if you implemented this for all block types it would start to add up, but it would still only be about 2MB for basically every block in current Minecraft, which includes far more block textures than you'd need with the current set of blocks supported.
Considering that the CX has 64MB RAM and the OS runs on older models with 32MB, there's at least 32MB free (maybe badly fragmented), so that could actually work quite well (but slow down startup time significantly). I added it in the poll above.

Should we perhaps reset the poll, now that a new option has been added?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 28, 2014, 09:06:12 pm
Sorry for the delay, but here (https://github.com/OlivierA/Ndless/pull/4)'s the pull request. You can look at freetype_demo (https://github.com/Legimet/Ndless/tree/master/Ndless-SDK/_samples/freetype) in the samples directory.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 29, 2014, 08:44:28 am
Quote
Should we perhaps reset the poll, now that a new option has been added?
No, my intention is to remove an option from the poll after I implemented it and add considerable suggestions and possible features on-the-fly.
It shouldn't make a huge difference anyway, as lighting doesn't have an impact on gameplay at all (yet).

Sorry for the delay, but here (https://github.com/OlivierA/Ndless/pull/4)'s the pull request. You can look at freetype_demo (https://github.com/Legimet/Ndless/tree/master/Ndless-SDK/_samples/freetype) in the samples directory.
Looks good so far, but freetype seems to be a really big chunk of code with a complex API. Nevertheless I'll try it, once my fork gets up-to-date with upstream. Merging both can take a while, there are still two major issues (ndless_resources crashes and ndless_installer as well D: ).
I updated to GCC 4.9.0 by the way and the problem with elf2flt sucking all RAM out (if iostream is used) is there again :(
Also, I would suggest not copying freetype's source into the ndless tree, just the static lib with includes and a script to build it.
nSDL and nspireio are seperate libraries as well. Maybe we could use git's submodules?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on April 29, 2014, 11:03:23 am
What? I only copied the headers, static library, and a Makefile to build it (and similarly for zlib). git submodules sounds like a good idea, since we won't have to  have prebuilt stuff in the repo, and we can build the libs from source.

As for using freetype in crafti, just choose whatever works best. If you think FreeType is a good choice, just take a look at the sample, and put whatever font you use in a header file using "xxd -i" so people don't have to copy an extra file.

I updated to GCC 4.9.0 by the way and the problem with elf2flt sucking all RAM out (if iostream is used) is there again :(

What do you think about making our own tool to convert elf to bflt? I think everyone agrees by now that elff2flt is an unmaintained piece of crap.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 29, 2014, 11:14:51 am
Quote
What? I only copied the headers, static library, and a Makefile to build it (and similarly for zlib).
Oops, I didn't look at the content, just the amount of lines (>20.000) :/
BTW: You removed fdlibm without mentioning it in the commit message. That's not an issue, but it's better to document any (non-subtle) changes.

Quote
git submodules sounds like a good idea, since we won't have to have prebuilt stuff in the repo, and we can build the libs from source.
Yeah, compling nSDL, nspireio and the other two shouldn't take long.

I updated to GCC 4.9.0 by the way and the problem with elf2flt sucking all RAM out (if iostream is used) is there again :(

What do you think about making our own tool to convert elf to bflt? I think everyone agrees by now that elff2flt is an unmaintained piece of crap.
It definitely is. With libelfELFIO that should be possible, IIRC tangrs already tried something similiar.
But I'd rather invent a better-documented format, with support for generic sections with attributes (e.g. for exceptions).
Basically elf, but without requiring symbol information for relocation.

Quote
As for using freetype in crafti, just choose whatever works best. If you think FreeType is a good choice, just take a look at the sample, and put whatever font you use in a header file using "xxd -i" so people don't have to copy an extra file.
I'll try some solutions. I'll probably end up rendering a font table with freetype into a buffer and use it to directly blit to the screen buffer.
Or without freetype, prerendered using CBFG (http://www.codehead.co.uk/cbfg/).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on April 29, 2014, 11:37:17 am
Is this being compiled on a linux machine?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 29, 2014, 12:06:02 pm
Quote
Is this being compiled on a linux machine?
Yeah, I'm not using windows, even if I wanted to, I couldn't. I haven't got a license key anymore, let alone free space on my drive.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on April 29, 2014, 01:10:25 pm
Quote
Should we perhaps reset the poll, now that a new option has been added?
No, my intention is to remove an option from the poll after I implemented it and add considerable suggestions and possible features on-the-fly.
It shouldn't make a huge difference anyway, as lighting doesn't have an impact on gameplay at all (yet).

But now that lighting is in the poll, I want to vote for it, but I can't because I've already voted. Others might want to do the same.

There's also an option to allow people to change their votes without resetting the poll entirely, I just didn't like that idea as much because it wouldn't force people to re-evaluate their decision with the new option being present.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on April 29, 2014, 01:13:25 pm
As I created the poll there was a checkbox "Allow everyone to change their vote" which I enabled.
Bug? Anyway, I reseted it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on April 29, 2014, 06:17:01 pm
Alright, cool. Now to help make sure people get the message:

Due to the addition of a new option, the poll has been reset! If you previously voted, please re-examine the options and cast your vote again.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on April 29, 2014, 07:25:19 pm
Nice to see that I'm finally in the majority.  :3
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on April 30, 2014, 01:17:03 am
There isn't an "other" thingy. Whatever, I'll say it here : you should start by implementing the easier stuff and only leave the tricky features in the poll. Just a thought.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Levak on April 30, 2014, 02:10:28 am
Quote
For fonts, you can use nGC or Freetype (which works without any changes)
Does nGC support rendering into (raw) buffers with different width than the screen?

It maybe does, but never managed to do so. The OS simply uses a gui_gc_clipRect before gui_gc_blit_buffer in order to draw part of the 3D engine (splitted app for example).
gui_gc_blit_buffer is not that slow IIRC, Of course I never had the opportunity to test it with a real 3D buffer.

Two ways offer to you :
Code: [Select]
static char* screen_buffer[SCREEN_BYTES];
void draw()
{
  ngl(screen_buffer, scene);
  gui_gc_blit_buffer(gc, screen_buffer); /* syscall */
  gui_gc_drawString(gc, "H\0e\0l\0l\0o\0 \0W\0o\0r\0l\0d\0\0", 0, 10);
  gui_gc_blit_to_screen(gc); /* part of libndls */
}

Code: [Select]
static Gc text_gc;
void init()
{
  text_gc = gui_gc_copy(gc, 100, 100)
  gui_gc_setColorRGB(255, 255, 255);
  gui_gc_fillRect(0, 0, 100, 100);
  gui_gc_setColorRGB(0, 0, 0);
  gui_gc_drawString(text_gc, "H\0e\0l\0l\0o\0 \0W\0o\0r\0l\0d\0\0", 0, 10);
}

void draw()
{
  ngl(scene);
  gui_gc_blit_to_screen_region(text_gc, 0, 0, 100, 100); /* You can even redefine this function in order to handle alpha */
}

Quote
nGC uses the OS' font routines AFAIK which are slow and ugly
Slow because of syscalls, and in my second example the draw method doesn't use any syscall on time critical code.
Ugly ? Their code is mainly a top level API over Nucleus GRAFIX in order to define primitive like in Java's Graphic2D.
The only thing you need to bother with nGC is utf16 which is simpler to use with the String API.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 01, 2014, 05:06:31 pm
(Mostly) bugfix release v0.8.1:
New features:
 -Transparent leaves
 -Bedrock (y=0, indestructible)
 -Better AABBs for billboards (flowers, mushroom, torch) and cake
 -Oriented blocks

Bugfixes:
 -Can't break your neck anymore
 -A bit faster
 -Textures not 256x256 now fully work

Known issues:
-If you jump into a wall, you can slide along it without falling
-Graphical glitches
-Too many diamonds..

Refactoring took a long time, but it was worth it. I had to fix a bug in Ndless (I introduced...) so some crashes are now fixed.
I also hit a bug in GCC 4.9.0, but it should be faster now, as one of the major features in 4.9.0 is a optimized LTO.
I haven't tried it outside nspire_emu.
No screenshots, as there's nothing screenshot-worthy in this release.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 02, 2014, 01:10:21 am
I also hit a bug in GCC 4.9.0, but it should be faster now, as one of the major features in 4.9.0 is a optimized LTO.
What bug? I'm intrigued.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on May 02, 2014, 01:12:35 am
I have voted for water and lava :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 02, 2014, 11:06:43 am
I also hit a bug in GCC 4.9.0, but it should be faster now, as one of the major features in 4.9.0 is a optimized LTO.
What bug? I'm intrigued.
A segmentation fault: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61008 (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61008)

I have voted for water and lava :D
Well, with 7 votes this is probably going to be it. v0.9 will take a while, though. I want to fix most of the graphical glitches and add some more "stuff" I don't know yet.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on May 03, 2014, 10:44:15 am
Is there a way to make the movement controlled by pressing the arrow keys, and rotations controlled by the "touchpad", as in sliding your thumb across it instead of pressing?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 03, 2014, 10:47:58 am
I actually thought about that, but it doesn't make much sense IMHO. One hand for rotation and the other for movement.
And also that would make debugging absolutely impossible, as I couldn't rotate the camera on nspire_emu then.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on May 03, 2014, 01:52:40 pm
I also hit a bug in GCC 4.9.0, but it should be faster now, as one of the major features in 4.9.0 is a optimized LTO.

Once Lionel Debroux said that GCC versions x.y.0 are buggy, and when 4.8.0 was the latest GCC, I ran into a bug that gave an ICE when compiling Ndless :P
I reported the bug, and it was fixed in 4.8.1.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 03, 2014, 01:59:24 pm
The major time between 4.8.2 and 4.9.0 was testing, especially for regressions.. Obviously it was still too short.
I'm looking forward to find out what else it breaks.. I mean, it's just a normal constructor, I don't know any C++ projects without constructors...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on May 03, 2014, 02:14:41 pm
I am very interested in wondering if, because the iOS does not support Java, you are actually using mechanics similar (unknowingly) to those in the iOS version of Minecraft?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 03, 2014, 02:32:07 pm
The programming language has nothing to do with mechanics. But maybe it's just unclear to me what you meant.

BTW: Just found another bug in GCC 4.9.0: Compile anything with pointers with -fsanitize=address and it crashes if LTO is enabled:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61048
I don't know, maybe it's also present in 4.8.2.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on May 03, 2014, 02:34:19 pm
I actually thought about that, but it doesn't make much sense IMHO. One hand for rotation and the other for movement.
Well on PC, you have one hand on keys and the other one on the mouse.
Same on Android where you have one hand on a virtual D-Pad and the other one sliding around to look around.
I hear your argument about the emu though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on May 03, 2014, 04:26:40 pm
I also hit a bug in GCC 4.9.0, but it should be faster now, as one of the major features in 4.9.0 is a optimized LTO.

Once Lionel Debroux said that GCC versions x.y.0 are buggy, and when 4.8.0 was the latest GCC, I ran into a bug that gave an ICE when compiling Ndless :P
I reported the bug, and it was fixed in 4.8.1.
That's how GNU version numbering works. :P Major.minor.patch = overhaul.features.hotfix.
Title: Crafti v0.9
Post by: Vogtinator on May 06, 2014, 01:15:52 pm
New major release of crafti: v0.9!
I know, I only changed the minor version number >:D

A screenshot first, can you guess the changes?
(http://img.ourl.ca/crafti_v0.9.png)

New features:

Fixed bugs:

Known issues (compared to v0.8.1):
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on May 06, 2014, 02:25:33 pm
you forgot the readme :P
Awesome !
Glad to see you could make both the inventory and water+lava, among other things :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 06, 2014, 03:32:57 pm
So epic :D I hope you'll be able to port it to monochrome Nspires as well, or let someone do it for you (yes this is a proposal) ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 06, 2014, 04:25:34 pm
Quote
So epic  I hope you'll be able to port it to monochrome Nspires as well, or let someone do it for you (yes this is a proposal)
nGL is open source, so of course everybody can - if that "everybody" wants to.
It's only the matter of some code switching to 8-bit grayscale mode (there's no 4bit array in C, so that would be quite invasive), and a conversion routine that handles the displaying. And no - I won't do it. At least not this month.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 06, 2014, 10:29:44 pm
This is looking awesome. Keep up the good work!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on May 06, 2014, 11:19:23 pm
Really nice! I can,t wait to find time to try this new version. :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 07, 2014, 12:02:33 am
Also, don't forget to update your vote on the reset poll!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: XiiDraco on May 07, 2014, 12:22:51 am
Do you even know how happy I would be to be able to skrew around with redstone (and related material) on my Nspire?

I would cry. Tears for you. Bottle them. And then mail them. To you. So you. Could physically feel. My joy.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on May 07, 2014, 07:47:05 am
Quote
Other dimensions

[/size]4D Minecraft? *.*
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on May 07, 2014, 08:16:51 am
Its getting better and better man!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on May 07, 2014, 09:10:06 am
Quote
Other dimensions

[/size]4D Minecraft? *.*
LOL even though that would be awesome, in this case it's about the Nether and the End. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 07, 2014, 10:13:42 am
Hum, due to our impossibility to interpret 4D environments, I don't especially think that would be awesome :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 07, 2014, 10:18:04 am
It's interesting to think about extending the smooth randomly generated terrain to another dimension you can only see a slice of, though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on May 07, 2014, 10:18:42 am
The Universe is infinitely dimensioned. :P Also if you remember my explanation, Time is a plane. We only perceive it as a straight line though but that's still 4D that we can perceive although our eyes only provide three. ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on May 07, 2014, 04:47:10 pm
I think that a working crafting would be a essential part of the program!
and by the way this is AMAZiNG!!!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 10, 2014, 12:58:02 pm
I've got something unexpected for you: Monochrome crafti!
(http://img.ourl.ca/crafti_monochrome.png)    (http://img.ourl.ca/crafti_monochrome_blocks.png)

It also supports the clickpad. I added no new features, so please use v0.9 if you have a CX.
The red part dominates the pixel brightness, so water is black and lava bright, but everything should be recognizable.
I don't have a non-CX calc, so I couldn't test it on hardware, but it works in nspire_emu in clickpad mode. Touchpads should also work.
And BTW, I fixed some compiler errors if you were using nGL with SAFE_MODE without TEXTURE_SUPPORT. But AFAIK, nobody does.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 10, 2014, 02:21:02 pm
Unexpected, but much waited for ;D

Nice work, I'm definitely downloading it now !
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 10, 2014, 04:01:24 pm
Then please tell me if and how well it works! If it's not too bad I might add some texture preprocessing so it looks a bit better.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 10, 2014, 04:50:27 pm
I hope the blur isn't too bad; I tried nDoom on a friend's non-CX calc and it was really hard to tell what was happening.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 10, 2014, 04:54:35 pm
So everything works as far as I've tested things (Ndless 3.1 r914) ; the blur is indeed very annoying (but can get better if you fiddle with the contrast), and it would be cool if you could diffuse brightness equally according to the whole pixel and not only what seems to be the red channel. I'm pretty sure I saw a formula for converting RGB colors to an arbitrary gray level, but IIRC it implied 3 floating-point multiplication - I'm pretty sure you can deal with it with fixed-point though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 10, 2014, 04:56:30 pm
So it's okay to play with? If not I'll abandon monochrome crafti.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on May 10, 2014, 04:58:07 pm
I hope the blur isn't too bad; I tried nDoom on a friend's non-CX calc and it was really hard to tell what was happening.
Yeah I had this problem, although for me nDoom ran slightly slower than other platforms on the clickpad so that kinda solved my blurring issue. gbc4nspire, on the other hand, was completely unplayable with some games. Blame TI :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 10, 2014, 05:29:41 pm
This should look a bit better. There are some issues, but it works well overall.
Weirdly, even though I set 16-bit mode and each pixel is 16-bit wide, only the lowest 5 bits are used. So it wasn't red, but blue...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on May 10, 2014, 06:10:07 pm
A solution would be to make nGL support true monochrome rendering and convert textures to monochrome before needing them.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 10, 2014, 06:13:35 pm
nGL doesn't care about colors or such things, it just sets every COLOR on screen to a COLOR in a TEXTURE.
4-bit doesn't work in C and if I use 16 bit I wouldn't even have to change the definition of COLOR as uint16_t.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on May 10, 2014, 06:17:18 pm
Oh OK thanks for the info.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on May 11, 2014, 01:30:18 pm
How close would redstone/related stuff be?

Or even lighting?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 11, 2014, 01:32:54 pm
If you mean progress: I didn't even begin. I will when I have time, motivation and some other projects finished.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 13, 2014, 01:39:26 pm
Just a quick question: How much could I increase startup time?
In v1.0 I'll implement some more optimizations, but it'll result in a slower start.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 13, 2014, 01:44:08 pm
A slow start doesn't bother me since it'll improve the game overall.

What about being able to interrupt startup and emergency quit ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 13, 2014, 01:45:55 pm
That'd be possible by either writing some asynchronous worker functions, which is a total mess or keyboard interrupts which I never got to work.

So, not until I find a solution for keyboard IRQs.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 13, 2014, 02:17:48 pm
I was more thinking of putting key detects in the loops that precompute datas - the ones that occur when we see the "Crafti" title screen, that way you can detect emergency-quit.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 13, 2014, 02:20:25 pm
Most of the time it's doing a fread call, so hardly interruptible. But I'll insert a isKeyPressed(KEY_NSPIRE_ESC) in the middle somewhere.
Probably when "Loading" is shown first.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Eiyeron on May 13, 2014, 02:25:51 pm
Voginator, you should do coroutines based calculations. FOr HBE for instance all subroutines give the hand to another routine, even if they didn't reached their goal.

For your case, you could do something like this

Code: [Select]
LOOP
  Calculate a batch of things
  Draw
  Key update (the order of the actions doen't mind)
ENDLOOP
for the batch calculations, you could track the index or the loop counter.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 13, 2014, 02:58:20 pm
That's called game/render-loop and I'm using that already, combined with a state-machine.
But for cleanup, for instance, I'd need to return some value to inform the whole call stack up to main that the user requested a termination.
(I dislike atexit and there may be some problems with bFLT..).
Also, most are some calls to drawTexture, newTexture, loadTexture, resizeTexture and I don't want to just throw some if(!isKeyPressed) in there. Also the key press detection itself would take longer than the rest of the loop body.
A interrupt would be the most clean solution, but I'll not implement anything more than some additional isKeyPressed in between until I found a solution for keypad interrupt handler crashing occasionally.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on May 17, 2014, 06:21:26 am
Wow ! Those are good improvements! :o

Nonetheless, the game... laggs. Why does it lagg more with water and lava?

Feature requests:

I think the priority is the speed up all the "loading" during the game.

Quote
Just a quick question: How much could I increase startup time?
In v1.0 I'll implement some more optimizations, but it'll result in a slower start.

I think the speed during the game is much more important than the startup time. I think you can grow it up to 40 seconds (currently 22 seconds) if you add a loading bar.

Thanks for your work! Do you mind if I upload it on tiplanet?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 17, 2014, 07:15:36 am
Wow ! Those are good improvements! :o

Nonetheless, the game... laggs. Why does it lagg more with water and lava?
That's a bug I found yesterday by accident and I already fixed it ;) (Water was spreading to blocks even if there's already water)
And it will always be somewhat slower if water and lava are visible as blocks under water or lava still have to be drawn as you can dive.
(I COULD rerender the world if you're submerged, but that'd take some seconds, which would be very annoying if you're swimming just beneath the surface)
That's also the reason why I retained from natual water sources such as seas, oceans or underground lava.

Quote
Feature requests:
  • Be able to open the menu or quit the game even when there is the "loading" label.
I can insert a if(keyPressed(KEY_NSPIRE_ESC)) somewhere in the middle of the splash screen, that shouldn't be too bad.

Quote
  • Move on the items selector menu with the touchpad.
Ok, will do.

Quote
I think the priority is the speed up all the "loading" during the game.
That's terrain generation and it will probably not get much faster.. :( Unless I can find a better way to generate terrain.

Quote
Quote
Just a quick question: How much could I increase startup time?
In v1.0 I'll implement some more optimizations, but it'll result in a slower start.

I think the speed during the game is much more important than the startup time. I think you can grow it up to 40 seconds (currently 22 seconds) if you add a loading bar.
I hope I don't reach 40 seconds, but it's likely the framerate will increase by ~20-100% in some cases!

Quote
Thanks for your work! Do you mind if I upload it on tiplanet?
Not at all, if you put a link to the github release page or this thread, just so that everybody can find the latest release and source code.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on May 17, 2014, 07:21:39 am
I think the priority is the speed up all the "loading" during the game.
That's terrain generation and it will probably not get much faster.. :( Unless I can find a better way to generate terrain.
Wait, that means that if I stay on a "region" where everything is already generated, I don't have that loading anymore ?
Maybe you could add an option or something to waste 1 minute of time generating a "huge" map to save time later by not generating anything anymore ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 17, 2014, 07:32:09 am
I think the priority is the speed up all the "loading" during the game.
That's terrain generation and it will probably not get much faster.. :( Unless I can find a better way to generate terrain.
Wait, that means that if I stay on a "region" where everything is already generated, I don't have that loading anymore ?
Maybe you could add an option or something to waste 1 minute of time generating a "huge" map to save time later by not generating anything anymore ?
That's already implemented: Just increase the view range, wait until it's generated and decrease it again.
But of course I could generate a larger area first.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on May 18, 2014, 09:56:20 am
So are these worlds now infinite? There also seems to be an xray bug where if you're underground, you can walk up to a block and see all through it
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 18, 2014, 01:07:46 pm
Quote
So are these worlds now infinite?
No, not infinite, just 69905 blocks in X, Y, and Z-direction ;)
But there will be more and more glitches and artifacts the further you go.

Quote
There also seems to be an xray bug where if you're underground, you can walk up to a block and see all through it
I know, but I can't seem to find it  :mad:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on May 18, 2014, 05:27:24 pm
So are these worlds now infinite?
No, not infinite, just 69905 blocks in X, Y, and Z-direction ;)
But there will be more and more glitches and artifacts the further you go.
...
...
...
THE FAR LANDS
somebody call Kurt
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on May 19, 2014, 04:51:38 pm
Yaaay The Far Lands coded in already! Cool!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 24, 2014, 11:10:09 am
I downloaded the grayscale version and put it on my Nspire CAS (grayscale) touchpad. I get the splashscreen, then the UI for half a second, then it exits. It is in the root directory. I am using Ndless 3.6

Do you know why this is happening? If so, what's the fix?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 24, 2014, 01:03:20 pm
Quote
I downloaded the grayscale version and put it on my Nspire CAS (grayscale) touchpad. I get the splashscreen, then the UI for half a second, then it exits. It is in the root directory. I am using Ndless 3.6

Do you know why this is happening? If so, what's the fix?
Do you have a touchpad or not?
Does it work if you press (and hold) the ESC key?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 24, 2014, 05:48:20 pm
I have a touchpad, and yes it works when I hold ESC. That said, it crashes after a bit (still holding ESC) D:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 24, 2014, 06:05:07 pm
That's weird, so the touchpad has the same keymap as the CX model, but with inverted registers?
I don't know why it crashes, though. Probably it thinks all keys are pressed at the same time, but it shouldn't crash  ::)

Could you try the attached version? It's built from my current source tree, with many new bugs.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 24, 2014, 06:12:12 pm
That version just crashed on startup. Sorry D:

I think it may be Ndless 3.6/OS 3.6 that is the problem, since Matref had no issues, and he has OS 3.1/Ndless 3.1
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 24, 2014, 06:25:56 pm
Quote
That version just crashed on startup. Sorry D:
Could you try it again? Maybe there wasn't enough RAM available.

Quote
I think it may be Ndless 3.6/OS 3.6 that is the problem, since Matref had no issues, and he has OS 3.1/Ndless 3.1
That may be, but it works on CX CAS 3.6 (emulated) and CAS 3.1 (emulated clickpad) without any issues  ???
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 24, 2014, 06:49:19 pm
It works! Thank you very much!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TheMachine02 on May 27, 2014, 05:09:09 am
Soo.. I've just test it on real hardware, and I must say it rather super mega awesome  ;D
keep up the good work  :thumbsup:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 02, 2014, 03:48:21 pm
It's time for the newest, greatest, most stable and best release yet: v1.0!
Bad news first: No major no features, no redstone yet. But I'm working on it  ;)
I wanted this release to be stable and with all known bugs fixed, and redstone is the opposite...
I also focused on performance. Just try it out yourself, it's a big improvement!

But now the good news:
New features:Bugs fixed:
That's about it. It took much longer than expected, but I tried to fix every bug I found  <_<
And a short note at the end: I changed the savefile version again, so if your world doesn't open, you'll have to open and save it with v0.9 first.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on June 02, 2014, 04:00:06 pm
You are really amazing. :o The performances really increased and are now acceptable.

Just un point: why does the "fast mode" seem to be slower on my calc?

By the way, would it be possible to make the "loading" vanish while playing even though it reduces the speed? The loads would be progressive instead of all in the same time.

Anyway, it is really a great great work.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 02, 2014, 04:05:41 pm
Quote
Just un point: why does the "fast mode" seem to be slower on my calc?
Weird. For me it's almost a 100% improvement.. It can't be slower, though. Maybe you accidentially changed the max. distance?

Quote
By the way, would it be possible to make the "loading" vanish while playing even though it reduces the speed? The loads would be progressive instead of all in the same time.
Not really. I could generate 10MB of Chunks and use that, but it'd take 10 minutes to generate and also 10 minutes to load each time you want to play.
And I'm not sure what you mean by "even though it reduces the speed".

Anyway, I forgot to mention that crafti also became my official project at school, so crafti is now part of my abitur  ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on June 02, 2014, 04:13:01 pm
Weird. For me it's almost a 100% improvement.. It can't be slower, though. Maybe you accidentially changed the max. distance?
Actually, the "fast mode" is faster but involves much more "loading"...

Not really. I could generate 10MB of Chunks and use that, but it'd take 10 minutes to generate and also 10 minutes to load each time you want to play.
And I'm not sure what you mean by "even though it reduces the speed".
I was asking if instead of loading a block of map each time you need it, you could begin to load it progressively when we come close to it. This progressive load would reduce a bit the speed but would make the "loading" disappear.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 02, 2014, 04:16:43 pm
Weird. For me it's almost a 100% improvement.. It can't be slower, though. Maybe you accidentially changed the max. distance?
Actually, the "fast mode" is faster but involves much more "loading"...
That's just because of the higher FPS you also walk faster to the next unloaded chunks. You could turn the speed to "slow", I guess.

Quote
Not really. I could generate 10MB of Chunks and use that, but it'd take 10 minutes to generate and also 10 minutes to load each time you want to play.
And I'm not sure what you mean by "even though it reduces the speed".
I was asking if instead of loading a block of map each time you need it, you could begin to load it progressively when we come close to it. This progressive load would reduce a bit the speed but would make the "loading" disappear.
That's basically how it works now...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on June 02, 2014, 04:25:51 pm
That's just because of the higher FPS you also walk faster to the next unloaded chunks. You could turn the speed to "slow", I guess.
Ah ok, you could be right.  ;D

That's basically how it works now...
But... didn't you speak about "the next unloaded chunk"? I meant not to load chunk by chunk but progressively. Doen't the "waiting" mean the loading of an entire chunk which hasn't been loaded at all yet?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 02, 2014, 04:33:11 pm
Basically yes. It could also happen if the generation of the Chunk geometry takes too long.
While you walk, it determines the Chunks that would have to be loaded and loads it.
If they're not loaded when you reach it (the sum of chunks currently loading) exceeds a specified value, it shows the loading message instead of hanging.
To get something like this done smoothly is very hard (near to impossible) without proper multitasking.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: XiiDraco on June 02, 2014, 06:33:51 pm
Speaking of multitasking. You know what I think would be fun, and awesome but probably isn't likely or possible(or already has been done in which case I'm an idiot and stop reading this)? Threads for calcs. But the real question is do they have GPU's?


I'm way to lazy to check or ask if this is at all possible or whether or not it has or has not been done. This post is actually more of me showing my appreciation of the challenges of multi-threaded process/rendering.

Anyway, AWESOME game/engine/thingi Vog, I haven't been checking up on it for a while but it looks GREAT!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 02, 2014, 08:21:37 pm
Not really. I could generate 10MB of Chunks and use that, but it'd take 10 minutes to generate and also 10 minutes to load each time you want to play.
And I'm not sure what you mean by "even though it reduces the speed".
I was asking if instead of loading a block of map each time you need it, you could begin to load it progressively when we come close to it. This progressive load would reduce a bit the speed but would make the "loading" disappear.
That's basically how it works now...
Why, then, does it have to load all the generated chunks at start? Can't you just load selective parts of the file into memory, accessing like an array? (Guessing you don't have arbitrarily large block data yet, but you could still stick that at the end (found by a position dictated in the header of the save).)

Ninja edit: It looks awesome. :D Nice work.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on June 03, 2014, 12:17:22 am
Wow, this looks even better than the previous version! O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: jiagejiage on June 03, 2014, 06:19:33 am
大声笑!它支持TI-NSPIRE CAS号!
它的工作太棒了!虽然我喜欢原来的材料  .
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: aeTIos on June 03, 2014, 06:20:26 am
^spambot?
Edit: Turns out he's not :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 03, 2014, 06:21:09 am
Pretty sure of it.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Sorunome on June 03, 2014, 06:22:42 am
nope :P
Quote from: google translator
LOL! It supports TI-NSPIRE CAS number!
It worked great! While I prefer the original material.

Also, most of us don't speak chineese ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 03, 2014, 12:44:09 pm
Speaking of multitasking. You know what I think would be fun, and awesome but probably isn't likely or possible(or already has been done in which case I'm an idiot and stop reading this)? Threads for calcs.
Yes, it has already been done (https://github.com/tangrs/nspire-multithreading-poc), but it has much overhead.

Quote
But the real question is do they have GPU's?
That depends on your definition of GPU.. The LCD controller (PL110) can do some basic things itself, but nothing useful.

Quote
I'm way to lazy to check or ask if this is at all possible or whether or not it has or has not been done. This post is actually more of me showing my appreciation of the challenges of multi-threaded process/rendering.
Yep, that's really the case. Multithreading can be a PITA..

Quote
Anyway, AWESOME game/engine/thingi Vog, I haven't been checking up on it for a while but it looks GREAT!
Thanks!

Not really. I could generate 10MB of Chunks and use that, but it'd take 10 minutes to generate and also 10 minutes to load each time you want to play.
And I'm not sure what you mean by "even though it reduces the speed".
I was asking if instead of loading a block of map each time you need it, you could begin to load it progressively when we come close to it. This progressive load would reduce a bit the speed but would make the "loading" disappear.
That's basically how it works now...
Why, then, does it have to load all the generated chunks at start? Can't you just load selective parts of the file into memory, accessing like an array? (Guessing you don't have arbitrarily large block data yet, but you could still stick that at the end (found by a position dictated in the header of the save).)
File access is SLOW. Slower than generating chunks on-the-fly. That's why I just load every Chunk in the savefile directly at the splash screen..
Quote
Ninja edit: It looks awesome. :D Nice work.
Tee-eitch-ex!

大声笑!它支持TI-NSPIRE CAS号!
它的工作太棒了!虽然我喜欢原来的材料  .
Great to hear that it works on HW as well as on nspire_emu :D

Also, most of us don't speak chineese ;)
At my school the teachers can now take chinese lessons for free. God knows why, but my history teacher really annoys me.
Sometimes, when he walks into class he greets us with "Nǐ hǎo"  ._.

But BTT: I'm currently in the process of thinking about redstone, and I haven't found the best solution yet.
I thought about giving each block a bit, which indicates whether it's powered or not, and a tick() function for redstone-active stuff.
The problem is, that if a wire is between two blocks and you power one of them, the wire also powers the other block.
Now, if you turn the block off, the other block is still active and the wire lets it propagate to the other block. Now both blocks will stay powered forever :-\
Does anybody have an idea, which is simple, elegant and also fast?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on June 03, 2014, 01:08:03 pm
Maybe you could use two bits per block instead of one ? I don't know how many ibts you have available in each block, but if you have two, you can do that. Basically use them as the D and Q ports on a D flip-flop ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 03, 2014, 01:19:53 pm
Hmm, I guess that could work. Just another bit for indicating whether it's a power source. I wonder why I haven't thought of this earlier, thanks  ;)
A simple enum {
NOT_POWERED,
PASSIVELY_POWERED,
ACTIVELY_POWERED } should do it.
Sadly I just found out that the door block occupies the highest bit (1<<7, for top/bottom door part) which I wanted to use..
Is it ok if I break all doors (suddenly consisting out of two bottoms)?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on June 03, 2014, 01:41:41 pm
I guess it depends on what you mean. If it means "currently placed doors won't work, you have to (and can) remove them and place them back to fix it", I guess it is ok. If it means "forget about doors, they will not be part of that game", I guess it is less ok.
At worst, couldn't you do a smart but not intuitive enum that would make both powered blocks work and doors work ? Like, if your door is currently 01xxxxxxx, then do
10=passively powered
00=actively powered (not intuitive)
11=not powered
01=not powered either
This way, the door isn't powered and 01xxxxxx is still available for it ;)
And no one cares about that door not being powerable, I don't think doors are powerable in Minecraft. I think the best you can do is open them if the block next to them is powered.

Now that I think of it, even a more intuitive enum like
11=actively powered
10=passively powered
01=not powered
00=not powered either
could work...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 03, 2014, 01:56:58 pm
It's not that big of a problem ;)
Currently, BLOCK_WDATA is defined as uint16_t, the lowest 8 bits are the BLOCK (the ID),
the higher 8 bits could be used for anything.
Somewhere in crafti, there's the enum BLOCK_SIDE, which is used as the highest 8 bits of the door's BLOCK_WDATA.
To indicate whether it's the top or bottom half of a door, bit 7 is used.
For redstone power state, I'd use the top 2 bits (7 and 6) and I'd have to move the door part bit out of the way.
Then each door part would have it's part bit set to 0, which is bottom..

Edit: So that old doors won't confuse redstone circuits:
enum  REDSTONE_STATE {
NOT_POWERED=0b00,
PASSIVELY_POWERED=0b01,
NOT_POWERED_2=0b10,
ACTIVELY_POWERED=0b11,
}; or even better, a bitfield.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 03, 2014, 02:23:03 pm
Doors are openable in Minecraft. This allows automagically opening them. ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 03, 2014, 02:45:12 pm
I did a quick test: (http://img.ourl.ca/crafti_doorlol.png)
This monstrosity can only be opened with the real bottom part..
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on June 03, 2014, 03:49:22 pm
Why do you need bits for opened or closed doors? Can't you just make a block which is an opened door and an other one which is a closed one ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 03, 2014, 04:05:42 pm
Does it matter where the bit is? In the BLOCK_DATA or BLOCK (number)?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on June 03, 2014, 04:10:28 pm
So freaking cool. Keep up the amazing work man!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 04, 2014, 09:41:29 am
It's not that big of a problem ;)
Currently, BLOCK_WDATA is defined as uint16_t, the lowest 8 bits are the BLOCK (the ID),
the higher 8 bits could be used for anything.
Somewhere in crafti, there's the enum BLOCK_SIDE, which is used as the highest 8 bits of the door's BLOCK_WDATA.
To indicate whether it's the top or bottom half of a door, bit 7 is used.
For redstone power state, I'd use the top 2 bits (7 and 6) and I'd have to move the door part bit out of the way.
Then each door part would have it's part bit set to 0, which is bottom..

Edit: So that old doors won't confuse redstone circuits:
enum  REDSTONE_STATE {
NOT_POWERED=0b00,
PASSIVELY_POWERED=0b01,
NOT_POWERED_2=0b10,
ACTIVELY_POWERED=0b11,
}; or even better, a bitfield.
You could use the free 8 bits for power level.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 04, 2014, 10:04:56 am
Which 8 free bits?

Edit: First test of some basic redstone
(http://img.ourl.ca/crafti_redstone_test.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on June 04, 2014, 06:25:17 pm
can you imagine, redstone computers on your Nspire?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on June 04, 2014, 09:10:45 pm
can you imagine, redstone computers on your Nspire?
Better, a redstone calculator on your calculator O.O.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on June 05, 2014, 06:33:40 am
*mind blow*
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 05, 2014, 07:23:35 am
Yo dawg, so I heard u like calculators so I build a calculator in yo' calculator so you can calculate while you calculate.
/me runs
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 05, 2014, 09:50:11 am
Which 8 free bits?
It's not that big of a problem ;)
Currently, BLOCK_WDATA is defined as uint16_t, the lowest 8 bits are the BLOCK (the ID),
the higher 8 bits could be used for anything.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 05, 2014, 02:40:19 pm
They're not free for doors:
Quote
Somewhere in crafti, there's the enum BLOCK_SIDE, which is used as the highest 8 bits of the door's BLOCK_WDATA.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on June 05, 2014, 04:23:28 pm
What is BLOCK_SIDE, and why does it consume 8 bits?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 05, 2014, 04:30:57 pm
The BLOCK_WDATA type is used as block storage.
Each block can also have some additional data, e.g. the side a torch has been put on, the type of flower, orientation of a furnace, or in this case, the side a door has been put on. The 7th bit is now occupied by redstone (powering on/off).
BLOCK_SIDE is defined as
Code: [Select]
enum BLOCK_SIDE {
    BLOCK_FRONT=0,
    BLOCK_BACK,
    BLOCK_LEFT,
    BLOCK_RIGHT,
    BLOCK_TOP,
    BLOCK_BOTTOM
};
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 05, 2014, 05:44:12 pm
You could half the number of bits needed by using a 3 bit number for the block side. So for doors (assuming that one bit is whether to door is open) you still have 3 bits free.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 05, 2014, 09:15:07 pm
Couldn't you allocate 4 more bits for redstone state for each block? I don't think that would impact performance too badly.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 06, 2014, 02:10:58 am
I could allocate some more, but I thought (e)ndless redstone would work better and is less annoying.
It wouldn't make it slower at all, but a second array redstone_state[SIZE][SIZE][SIZE] would make more sense and is also easier for backwards-compatibility.
But I need neither of them, the most parts are already implemented ;)

Edit: BLOCK_SIDE is 3 bits wide, but some blocks need some more bits and I'd like to have it as flexible as possible.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on June 06, 2014, 02:50:37 am
For some reasons, Omnimaga search engine returns 0 results for OS 3.1 and 3.6 in this topic and I couldn't seem to figure out from the readme, so I'll ask the following question here: Will the latest version run on Ndless 3.1 or just 3.6?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 06, 2014, 03:05:23 am
Both! Both tested, but 3.6 not regularily. The only ndless functions I use are hwtype(), isKeyPressed and fopen/fread/fwrite/fclose.

Edit: I just reseted the votes, removed lighting (doesn't work together with face-combining) and added minecarts (why not?)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on June 06, 2014, 08:51:39 am
Edit: I just reseted the votes, removed lighting (doesn't work together with face-combining) and added minecarts (why not?)

I thought face combining was a fast rendering mode approach only? The standard rendering method still exists and would support lighting, no?

I'll vote for caves, but my real vote is still for lighting. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 06, 2014, 08:59:23 am
No, face-combining is always active, but I could make it optional (as well as lighting), but it's not really worth the hassle.
I mean, just for aesthethical purposes calculating multiple textures, giving each vertex a texture ptr, light computation etc. would be way to slow.
The startup time would approximately triple, if not more and the chunk geometry calculations would get slower as well, but they would cause a noticable slowdown in game, as each block change (door opened, block destroyed, redstone changed, water flows etc.) triggers a recalc of the chunk and possible the adjacent ones as well..
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 06, 2014, 10:14:37 am
I could allocate some more, but I thought (e)ndless redstone would work better and is less annoying.
With normal redstone, though, we can port "real" redstone devices easier.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on June 06, 2014, 12:15:20 pm
Both! Both tested, but 3.6 not regularily. The only ndless functions I use are hwtype(), isKeyPressed and fopen/fread/fwrite/fclose.

Edit: I just reseted the votes, removed lighting (doesn't work together with face-combining) and added minecarts (why not?)
ok cool to hear, because I didn't feel like upgrading to OS 3.6 yet. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: The_King on June 07, 2014, 12:50:53 am
V.

Are u planning on adding mobs into the game at any point because that will make the game a bit more interesting

but good job
 
:D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 07, 2014, 01:33:36 am
Yeah he said mobs would be easy but they'll come later I guess.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: mdr1 on June 07, 2014, 05:15:01 am
ok cool to hear, because I didn't feel like upgrading to OS 3.6 yet. :P
Lol, you are not at all alone to do so. :p

Vogtinator, you probably forgot my question:

Why do you need bits for opened or closed doors? Can't you just make a block which is an opened door and an other one which is a closed one ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 07, 2014, 06:14:52 am
I could allocate some more, but I thought (e)ndless redstone would work better and is less annoying.
With normal redstone, though, we can port "real" redstone devices easier.
Just the comparator, nothing more. And I don't think you'd build really complex machinery on crafti..
Anyway, I'll post a "redstone manual" to show how it will work. If you're familiar with minecraft's redstone, this shouldn't be a problem,
the differences are small and most minecraft redstone stuff will work directly.

V.

Are u planning on adding mobs into the game at any point because that will make the game a bit more interesting

but good job
 
:D

I am, just vote for mobs in the poll at the top. But currently it seems you're lucky :)

Vogtinator, you probably forgot my question:

Why do you need bits for opened or closed doors? Can't you just make a block which is an opened door and an other one which is a closed one ?
I answered it, directly below. It wouldn't make any sense NOT to use the BLOCK_DATA bits as that's basically their purpose.
And it wouldn't solve the compatibility issues either.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: 123outerme on June 10, 2014, 08:32:42 pm
Is there a way to test if an Nspire is CX or not (as in, any differences in screen dimensions, etc)? That way, based on that test, you can make the worlds smaller or larger.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on June 10, 2014, 09:15:27 pm
You could have them press a button at the beginning to choose and store it in a config.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 11, 2014, 08:19:13 am
The world size I refer to is the size of the discovered part. If you walk too far from the spawn point, it'll crash soon.
The right way to prevent this is to cancel if memory allocation fails, but in C++ this works only with exceptions, which don't work with bFLT yet.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 11, 2014, 01:26:05 pm
Couldn't this part be written in C then ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 11, 2014, 02:38:34 pm
How exactly would you use std::vector in C?
Also, push_back has no return value, an exception (std::bad_alloc, AFAIK) is thrown on malloc failure.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on June 11, 2014, 03:19:05 pm
Welp, I'm no C/C++ dev. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: kevinkore3 on June 11, 2014, 05:50:27 pm
The world size I refer to is the size of the discovered part. If you walk too far from the spawn point, it'll crash soon.
The right way to prevent this is to cancel if memory allocation fails, but in C++ this works only with exceptions, which don't work with bFLT yet.
Couldn't you use gotos once the world reached a certain size instead of exceptions?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 11, 2014, 05:53:25 pm
While I actually like gotos for such purposes, I'm not able to change the C++ standard and it's implementation.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on June 14, 2014, 07:07:24 am
Question: In the menu, how are we supposed to save? When choosing save I tried the Menu, dot, 5, esc and Enter keys and whichever worked doesn't appear to save properly. When I restart the game and  try to reload the map, it does nothing so I lose all my progress. ???
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: aeTIos on June 14, 2014, 07:46:35 am
How did I miss this? Mind = BLOWN. O.O
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 14, 2014, 03:58:51 pm
Quote
Question: In the menu, how are we supposed to save? When choosing save I tried the Menu, dot, 5, esc and Enter keys and whichever worked doesn't appear to save properly. When I restart the game and  try to reload the map, it does nothing so I lose all my progress.
Just press "menu" then either the touchpad or clickpad "click" or the 5 key. It should freeze for a short time and then close the menu.
Or just press Esc to "Save & Exit" in-game.
If it doesn't work, could you post your current crafti.map.tns if you have one?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on June 20, 2014, 03:44:11 pm
Just a quick update:
I'm currently busy on vacation and next week school starts again so I'm busy learning and other unnecessary duties.
Redstone is fully implemented, but some blocks are still missing, so it's not very useful yet.
However, I worked a bit on my ndless fork and got exceptions to work! It's a rather nice feature, to minimize possible crashes.
Also, it'll be using a new executable format which will load faster and maybe also make the game faster!
It'll take a while to implement it in both ndless 3.6 and 3.1 though, I don't want that it runs on 3.6 only.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on June 20, 2014, 05:34:49 pm
Just a quick update:
I'm currently busy on vacation and next week school starts again so I'm busy learning and other unnecessary duties.
Redstone is fully implemented, but some blocks are still missing, so it's not very useful yet.
However, I worked a bit on my ndless fork and got exceptions to work! It's a rather nice feature, to minimize possible crashes.
Also, it'll be using a new executable format which will load faster and maybe also make the game faster!
It'll take a while to implement it in both ndless 3.6 and 3.1 though, I don't want that it runs on 3.6 only.
AWESOME!!!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Adriweb on June 20, 2014, 06:40:22 pm
However, I worked a bit on my ndless fork and got exceptions to work! It's a rather nice feature, to minimize possible crashes.
Also, it'll be using a new executable format which will load faster and maybe also make the game faster!
It'll take a while to implement it in both ndless 3.6 and 3.1 though, I don't want that it runs on 3.6 only.
Nice !
is Extended aware of this ? (So that he can integrate it in the official repo)
Well, I suppose you should finish it first :P
Good that it runs on 3.6 already, I guess it's more of a priority than 3.1, these days.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 05, 2014, 03:32:16 pm
Small little teaser  :devil: :
(http://img.ourl.ca/teaser-1.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 05, 2014, 03:44:47 pm
Nice ! But what is that glass pane for ? :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 05, 2014, 03:48:01 pm
It's purpose is to show you which block you're looking at currently. I'm very bad at drawing, but good at avoiding work and thus reusing other's :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 05, 2014, 03:52:26 pm
Oh ok lol. XD
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ordelore on July 05, 2014, 07:39:15 pm
Thats a very nice bush you've got there :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: willrandship on July 06, 2014, 01:14:09 am
I'm curious: With nGL, would it be faster to render a variable-resolution texture in front of the camera than, say, doing a nearest-neighbor scaling in a 2D lib? I mean, all the GL will slow things down a bit, but the optimizations for texture handling may help make up for it. It would also allow for some effects that wouldn't be possible in 2D environments, and would allow you to restrict colorspaces as well.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 06, 2014, 08:58:30 am
nGL renders only triangles, so is much more flexible in drawing textures at an arbitrary scale, rotation, translation etc., but that comes at the cost of:
which wouldn't be necessary for simple 2D stuff. That's also the reason I wrote a basically seperate lib "texturetools.cpp" to do 2d transformations (basically blitting, scaling, font etc.) on TEXTUREs. And yes, it's faster than n2dlib ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 06, 2014, 09:54:33 am
nGL renders only triangles, so is much more flexible in drawing textures at an arbitrary scale, rotation, translation etc., but that comes at the cost of:
  • Clipping
  • Culling
  • Z-Buffer
  • Interpolation along X and Y-Axis (With textures: 3 divisions per scanline, without: 1)
which wouldn't be necessary for simple 2D stuff. That's also the reason I wrote a basically seperate lib "texturetools.cpp" to do 2d transformations (basically blitting, scaling, font etc.) on TEXTUREs. And yes, it's faster than n2dlib ;)
Well I personnally didn't know about your 2D lib until recently (after n2Dlib was started) but you should definitely have bragged :P told about it sooner. The goal of n2Dlib was not to make something new, just to make a lib that runs at the same speed on CXes and non-CXes (and also that used the same format for "sprites" as nSDL). And apparently, not only it's slower on CXes but it's not even fast on the fastest model -.-
So could you share a link to your 2D lib and to a documentation about it ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 06, 2014, 09:56:07 am
nGL renders only triangles, so is much more flexible in drawing textures at an arbitrary scale, rotation, translation etc., but that comes at the cost of:
  • Clipping
  • Culling
  • Z-Buffer
  • Interpolation along X and Y-Axis (With textures: 3 divisions per scanline, without: 1)
which wouldn't be necessary for simple 2D stuff. That's also the reason I wrote a basically seperate lib "texturetools.cpp" to do 2d transformations (basically blitting, scaling, font etc.) on TEXTUREs. And yes, it's faster than n2dlib ;)
Well I personnally didn't know about your 2D lib until recently (after n2Dlib was started) but you should definitely have bragged :P told about it sooner. The goal of n2Dlib was not to make something new, just to make a lib that runs at the same speed on CXes and non-CXes (and also that used the same format for "sprites" as nSDL). And apparently, not only it's slower on CXes but it's not even fast on the fastest model -.-
So could you share a link to your 2D lib and to a documentation about it ?
^ That.
/me wants
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 06, 2014, 10:11:35 am
Well, it only does crafti-relevant parts, so no 2d primitives, just texture operations, but the header files should be enough documentation:
texturetools.h (https://github.com/Vogtinator/crafti/blob/master/texturetools.h)
font.h (https://github.com/Vogtinator/crafti/blob/master/font.h)

Small example:
Code: [Select]
#include <libndls.h>

#include "texturetools.h"
#include "font.h"

int main()
{
    TEXTURE *screen = newTexture(SCREEN_WIDTH, SCREEN_HEIGHT);
    nglInit();
    nglSetBuffer(screen->bitmap);
    while(!isKeyPressed(KEY_NSPIRE_ESC))
    {
        //Draw
        glColor3f(0, 0, 0);
        glClear(GL_COLOR_BUFFER_BIT);

        drawString("Hi!\nThis is a small test!", 0xFFFF, *screen, 0, 0);

        nglDisplay();
    }
    nglUninit();
    deleteTexture(screen);
}

Edit: Forgot to #include <libndls.h>
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 06, 2014, 10:20:29 am
Okay so stop saying texturetools is faster than n2DLib : I just looked at your drawTexture routine, it's exactly the same as n2DLib's drawSprite. Also, in drawTextureOverlay (which is n2DLib's drawSpritePart equivalent) you do calculation for every pixel where I only do calculation once per call - so n2DLib is faster. I didn't dig up more than this for now.

EDIT : nevermind the statement about drawTextureOverlay, it's not what it does.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 06, 2014, 01:58:34 pm
Quote
Okay so stop saying texturetools is faster than n2DLib : I just looked at your drawTexture routine, it's exactly the same as n2DLib's drawSprite
It isn't (probably a typo, but drawTexture = drawSpritePart). I know, I probably sound like an asshole now (:-\), but I already told you how you could optimize it:
And there's still more to optimize. Partial loop unrolling as 2x16bit access is slower than 1x32bit for example.

To give you an example of a almost fully optimized function, I optimized drawTexture some more: https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151 (https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151)
GCC does some partial unrolling, but doesn't transform 2 16bit accesses (ldrh/strh) to 32bit access(ldr/str), although -Ofast should do something, should I report a bug?
Code: [Select]
    8e28: e15392b4 ldrh r9, [r3, #-36] ; 0xffffffdc
    8e2c: e14292b4 strh r9, [r2, #-36] ; 0xffffffdc
    8e30: e15392b2 ldrh r9, [r3, #-34] ; 0xffffffde
    8e34: e14292b2 strh r9, [r2, #-34] ; 0xffffffde

Some suggestions:
But now it's getting rather off-topic...

Edit: I didn't downvote you. I really like discussions both sides benefit from.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 06, 2014, 02:05:34 pm
  • Use a Texture struct rather than a unsigned short* for better readability.
Well, two of us come from Axe and care less about readability than about speed (even though it seems like we are not Nspire pros :P) or efficiency.

It isn't (probably a typo, but drawTexture = drawSpritePart). I know, I probably sound like an asshole now ( :/ ), but I already told you how you could optimize it.
Yes you are :P Not at all, on the contrary, as you said, you already told us how to improve, you are not just saying "you are stupid, I am the best" or something ;)
And thanks for telling again with a clear list, because iirc, last time you kind of briefly explained on IRC but not really clearly :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 06, 2014, 02:35:56 pm
  • Use a Texture struct rather than a unsigned short* for better readability.
Well, two of us come from Axe and care less about readability than about speed (even though it seems like we are not Nspire pros :P ) or efficiency.
It should compile to the same code. If not, it could be faster due to alignment if you use a "flexible array member" (StackOverflow question (http://stackoverflow.com/questions/2060974/dynamic-array-in-struct-c))
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: willrandship on July 06, 2014, 03:44:24 pm
So, if you used the 2d lib, as it's still initiating an nGL screen, does that mean you could render a 2D backdrop on a 3D area? That would have some interesting potential.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 06, 2014, 04:08:00 pm
Jup, I wanted to nGL to be as flexible as possible, but without neglecting performance.
I actually thought about rendering the block list to a TEXTURE and letting it "fly in" from up front. I could also render the inventory/quick-select to a ribbon in circle shape (forgot the word) and rotate it so that the currently selected slot points towards the cam (or in a \_/ shape, viewed from above)
The opposite direction is possible as well, e.g. mirrors, portals, side-by-side view - but I don't know how to integrate it into crafti easily.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 06, 2014, 07:27:35 pm
I think it might be a better idea to use a different texture for the selected block since I tend to get confused with actual glass windows and stuff. Would a square with nothing except an outline that slowly flashes between black and white be better?


Edit: I didn't downvote you. I really like discussions both sides benefit from.

I think the downvote might have been more because his post could be interpreted as an unnecessary reprimand (although not comparable to the name calling and all-caps yelling on IRC within the last few weeks, which was similar to something I and some others previously got banned for) and starting a pissing contest about which lib is better or not and doing so in someone else's lib thread.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 06, 2014, 08:06:38 pm
First, I know who downvoted me. No need to pretend not knowing, he-knows-I'm-talking-to-him. Second, I find it legitimate to be angry when people keep bashing my work and saying without any stats to prove it "yes my lib is faster than his lib". Moreover, I keep proving my lib is not slow, but people keep ignoring me and seeing it as the slowest thing of the universe, at the point that they'll take any other lib instead of it. So it's getting *a little bit* annoying. Of course, if someone does test and proves by a + b that Vogtinator's lib is faster than mine at an identical task, then no problem. But just stating it with no numbers of any kind is insulting.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 06, 2014, 08:24:43 pm
To be honest I didn't see anyone literally bashing your lib, other than implying it's either slower than the others (with no valid proof) or blaming it for nKaruga slowdowns on CX models (even though we all saw what happened with the transition from 84+SE to 84+CSE). I mean I didn't see anyone literally saying the lib is useless or that it sucks, just misinformed people who probably didn't mean it as an insult. Hence why I thought that the reaction was overboard. I'm not fine with the idea of downgrading someone else's work either.

Also, I was once told by a moderator that even if a n00b is being annoying or someone spams that it's against the rules to be agressive, so on Omni, if you question people's reading skills, tell members they have no brain, yell at them using cussing and all-caps or try to make them look stupid/inferior, then you cannot use any excuse to get away with it (the only way to get away with it is if you don't get caught). This is more an head-up, because in the past I got banned for being rude too (although not for very long) and you can see my rating ratio as an indicator.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 07, 2014, 01:29:12 am
  • Use a Texture struct rather than a unsigned short* for better readability.
Well, two of us come from Axe and care less about readability than about speed (even though it seems like we are not Nspire pros :P ) or efficiency.
It should compile to the same code. If not, it could be faster due to alignment if you use a "flexible array member" (StackOverflow question (http://stackoverflow.com/questions/2060974/dynamic-array-in-struct-c))
Well that answers the "speed problem", but not the "efficiency" one because to convert the tab into a struct, well there is a need for a function to convert the tab into a struct -.-
Not hard to do, not speed wasting, but not necessary either. Axe coders (or at least I :P ) like to know what they are doing and why it works instead of using functions that mean something in English but that don't mean anything to their eyes, like "initSprite" or I don't know what. It's like when you declare a Bitmap in Axe, you know what the first bytes represent and what the other ones represent ;)

Also, I was once told by a moderator that even if a n00b is being annoying or someone spams that it's against the rules to be agressive, so on Omni, if you question people's reading skills, tell members they have no brain, yell at them using cussing and all-caps or try to make them look stupid/inferior, then you cannot use any excuse to get away with it (the only way to get away with it is if you don't get caught). This is more an head-up, because in the past I got banned for being rude too (although not for very long) and you can see my rating ratio as an indicator.
I would not even say "on Omni" only. It's not constructive to be angry, whether on Omni or IRL or anywhere. When there is someone angry in a discussion, it only makes the other people angry. And when you tell people they have no brain, especially when you are the one to blame and not the others, it only makes them defend themselves about this free insult before contributing to the real discussion, and I would even say "instead of" instead of "before" because once they defended themselves they don't really want to discuss with you anymore.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 07, 2014, 06:23:32 am
Oh god, what did I do :o

Quote
and starting a pissing contest about which lib is better or not and doing so in someone else's lib thread.
Yeah, I didn't expect that.

Quote
I find it legitimate to be angry when people keep bashing my work and saying without any stats to prove it "yes my lib is faster than his lib".
You asked me on IRC TWICE how you could optimize it further, I answered you and you ignored it, except for the "unsigned int" as x/y part. I even provided a nice list of suggestions but you ignored it again. If you don't want to implement it, don't say that your lib is faster. Not using "-Ofast" or at least "-O2" is just ignorant.

And I wouldn't call a simple "And btw, it's faster than n2dlib ;) " bashing.

Quote
Moreover, I keep proving my lib is not slow, but people keep ignoring me
Which "people"?
Quote
and seeing it as the slowest thing of the universe, at the point that they'll take any other lib instead of it.
Your lib isn't slow in the meaning of "too slow". I never meant that. I just implied it could be much faster.

Quote
Of course, if someone does test and proves by a + b that Vogtinator's lib is faster than mine at an identical task, then no problem. But just stating it with no numbers of any kind is insulting.
Well, I don't need any benchmarks to compare multiple comparisions, branches and additions to a single increment.
You even have a "performance-bug" in your code I already pointed out multiple times. (BTW: The ARM926EJ-S has a hardware multiplier. "mla" should be faster than "x + y<<8 + y<<6", but generally the compiler knows better, so "y*320" is always the best choice, combined with "-ffast-math")
But if you want some, I'll make a benchmark for both libs. I guess rendering the same 32x32 tile from the center of a 128x128 tilemap onto the screen (to fill it completely) would do? If you don't trust me, you can make your own benchmark if you want to.

Quote
Well that answers the "speed problem", but not the "efficiency" one because to convert the tab into a struct, well there is a need for a function to convert the tab into a struct -.-
No reason to do anything like that, it's directly binary-compatible ;)
Code: [Select]
struct Texture {
uint16_t width;
uint16_t height;
uint16_t transparent_color;
uint16_t bitmap[];
} __attribute__((packed));
could work. Untested.

Quote
or blaming it for nKaruga slowdowns on CX models (even though we all saw what happened with the transition from 84+SE to 84+CSE).
That's not his fault, that's the hardware and it will be the exact same with nGL (may be a little bit faster as nGL doesn't invert each sprite, but rather the entire screen once before it's drawn).

Quote
think it might be a better idea to use a different texture for the selected block since I tend to get confused with actual glass windows and stuff. Would a square with nothing except an outline that slowly flashes between black and white be better?
Yay, on-topic again! Seems like I should use my graphics tablet again.

A gif of a cute cat to calm down :3
(http://3.bp.blogspot.com/-iF8ObiLplC0/UjepwnV0ywI/AAAAAAAAD44/cn4jUoqrJvA/s1600/Shocked+Kitty.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 09, 2014, 02:25:59 pm
<off-topic again sorry, but got to clear that up>

Okay so I finally have a computer again, so I worked on n2DLib after several days when I couldn't. So I tried to implement your suggestions as good as I could.

First, sorry for being angry like this. I know it's ridiculous and shit, but I just had enough of seeing people implying the lib was supposedly slow. (and Vogtinator I never meant you, I know aeTIos kept saying it some time ago although he stopped now ; or maybe I'm just being too proud or paranoid, don't know which).

Anyway, well, it's a lib, so compile flags are up to the user.

DJ : I didn't want to start a war about what lib was better, I was just asking please stop assuming my lib is slow without even trying it or wondering if that's not your code's fault x.x I remember some days ago on IRC, Streetwalrus was saying something like "tetris is slow, it's n2DLib's fault" and was serious about it, and of course it turned out the problem was his own code. The fact itself isn't really important, it's just the way of thinking that's annoying. But let's forget that and pretend it never happened.

Vogtinator : for your optimizations, I do remember me asking you some, but I don't know, maybe I was working on something else at that moment so I forgot afterwards <_< I did my best at implementing them this time, it should be visible in github's history.

Although I find it a good idea, I can't afford inverting the buffer only when updateScreen-ing depending on the screen model, because maybe one day someone will not want to erase the buffer each frame and that will give weird results.

So I guess that's it, sorry for the off-topic, sorry for being upset, sorry for saying stupid shit, things like that.

Back on-topic, when testing the last version on an emulated TI-Nspire CX CAS with Ndless 3.1 r914, I noticed you couldn't swim in water nor lava, is that intended ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 02:50:37 pm
<off-topic again sorry, but got to clear that up>

Okay so I finally have a computer again, so I worked on n2DLib after several days when I couldn't. So I tried to implement your suggestions as good as I could.
Looks better, but still a lot to improve! (any branch per pixel, for instance if(has_color) definitely needs to go!)

Quote
First, sorry for being angry like this. I know it's ridiculous and shit, but I just had enough of seeing people implying the lib was supposedly slow. (and Vogtinator I never meant you, I know aeTIos kept saying it some time ago although he stopped now ; or maybe I'm just being too proud or paranoid, don't know which).
Well, then I wonder why you posted here.. To tell everybody my lib was slow as well/as fast as yours?

Quote
Anyway, well, it's a lib, so compile flags are up to the user.
Yeah, but then you should use the correct flags for your example, it's an example after all..

Quote
DJ : I didn't want to start a war about what lib was better, I was just asking please stop assuming my lib is slow without even trying it or wondering if that's not your code's fault x.x I remember some days ago on IRC, Streetwalrus was saying something like "tetris is slow, it's n2DLib's fault" and was serious about it, and of course it turned out the problem was his own code. The fact itself isn't really important, it's just the way of thinking that's annoying. But let's forget that and pretend it never happened.

Vogtinator : for your optimizations, I do remember me asking you some, but I don't know, maybe I was working on something else at that moment so I forgot afterwards <_< I did my best at implementing them this time, it should be visible in github's history.

Although I find it a good idea, I can't afford inverting the buffer only when updateScreen-ing depending on the screen model, because maybe one day someone will not want to erase the buffer each frame and that will give weird results.
That's the reason nGL allocates a third buffer on monochrome calcs (yup, one on CX and three on non-CXs)!
320*240*2 = ~155KB, that's almost nothing.

Quote
So I guess that's it, sorry for the off-topic, sorry for being upset, sorry for saying stupid shit, things like that.

Back on-topic, when testing the last version on an emulated TI-Nspire CX CAS with Ndless 3.1 r914, I noticed you couldn't swim in water nor lava, is that intended ?
No, definitely not! You can't swin in lava and water needs to be at least two blocks deep to swin in.
I just tested and it works for me :-/

Edit: Is it permitted to double-post to seperate a release announcement from the rest?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 09, 2014, 03:10:43 pm
<off-topic again sorry, but got to clear that up>

Okay so I finally have a computer again, so I worked on n2DLib after several days when I couldn't. So I tried to implement your suggestions as good as I could.
Looks better, but still a lot to improve! (any branch per pixel, for instance if(has_color) definitely needs to go!)

Quote
Although I find it a good idea, I can't afford inverting the buffer only when updateScreen-ing depending on the screen model, because maybe one day someone will not want to erase the buffer each frame and that will give weird results.
That's the reason nGL allocates a third buffer on monochrome calcs (yup, one on CX and three on non-CXs)!
320*240*2 = ~155KB, that's almost nothing.
Well, you answered yourself to the problem :P I'll do that too, coming from the z80 scene I'm always very afraid of allocating lots of memory.

Quote
First, sorry for being angry like this. I know it's ridiculous and shit, but I just had enough of seeing people implying the lib was supposedly slow. (and Vogtinator I never meant you, I know aeTIos kept saying it some time ago although he stopped now ; or maybe I'm just being too proud or paranoid, don't know which).
Well, then I wonder why you posted here.. To tell everybody my lib was slow as well/as fast as yours?
That "by the way, it's faster than n2DLib" just sitting here without any further development really made me upset.

Quote
Anyway, well, it's a lib, so compile flags are up to the user.
Yeah, but then you should use the correct flags for your example, it's an example after all..
Woops, I actually forgot that.

Quote
So I guess that's it, sorry for the off-topic, sorry for being upset, sorry for saying stupid shit, things like that.

Back on-topic, when testing the last version on an emulated TI-Nspire CX CAS with Ndless 3.1 r914, I noticed you couldn't swim in water nor lava, is that intended ?
No, definitely not! You can't swin in lava and water needs to be at least two blocks deep to swin in.
I just tested and it works for me :-/
Ah, it wasn't 2 blocks deep, but I thought that in the original Minecraft, you could swim on top of a water cube even if it was all alone ; here it just jumps.

Edit: Is it permitted to double-post to seperate a release announcement from the rest?
Yep.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: rwill on July 09, 2014, 03:13:18 pm
And there's still more to optimize. Partial loop unrolling as 2x16bit access is slower than 1x32bit for example.

To give you an example of a almost fully optimized function, I optimized drawTexture some more: https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151 (https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151)
GCC does some partial unrolling, but doesn't transform 2 16bit accesses (ldrh/strh) to 32bit access(ldr/str), although -Ofast should do something, should I report a bug?
Code: [Select]
    8e28:   e15392b4    ldrh   r9, [r3, #-36]   ; 0xffffffdc
    8e2c:   e14292b4    strh   r9, [r2, #-36]   ; 0xffffffdc
    8e30:   e15392b2    ldrh   r9, [r3, #-34]   ; 0xffffffde
    8e34:   e14292b2    strh   r9, [r2, #-34]   ; 0xffffffde

There are actually two reasons why a compiler cannot use 32bit memory move instructions here.

1:
Code: [Select]
COLOR *dest_ptr = dest.bitmap + dest_x + dest_y * dest.width, *src_ptr = src.bitmap + src_x + src_y * src.width;dest_ptr might be src_ptr + 1 ( *src_ptr is not const ) so moving two texels for this case will produce different results.

2:
It is not guaranteed that src_ptr and dest_ptr are each aligned to 4 byte which is required if you want to move 4 byte at a time on ARM.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 03:50:52 pm
I'm not creative enough to write some kind of intro, so here you go: Crafti v1.1 ;D
New features:
Bugs fixed:
Known issues:
Redstone tutorial:
Redstone in crafti works a bit different than in minecraft, redstone wire doesn't need to be on a block, it's a block by itself and can be placed on everything including air and redstone torches!
Each block has two states: Powering or not powering. Examples for powering blocks are turned-on redstone torches, turned-on switches, pressure plates you're standing on and powered redstone wire. Redstone torches are on by default and turn off if any block surrounding the block the torch has been placed on is powering (ignoring the torch itself, of course). Redstone lamps glow if any block surrounding them is powering. Doors open if any adjacent block is powering or being powered.

Some screenshots to give you a better idea of how it works and looks like:

Switch turning redstone torch off and on:
(http://img.ourl.ca/redstone_switch.gif)

Pressure plate turning on a redstone lamp:
(http://img.ourl.ca/redstone_lamp_plate.gif)
It doesn't turn off directly after stepping off of the plate, there's a delay of 5 ticks, so doors stay open a bit longer and don't close directly in front of you.

Wire controling a floating lamp:
(http://img.ourl.ca/redstone_wire.gif)

And the most basic redstone logic gate: The inverter!
(http://img.ourl.ca/redstone_inverter.gif)

Due to redstone wire being a block a clock is very simple:
(http://img.ourl.ca/redstone_clock.gif)
The redstone torch controls the wire underneath, which is connected to the wire which controls the torch. First I thought it's a bug but actually it's rather useful!

Of course doors work as expected:
(http://img.ourl.ca/redstone_door.gif)
If you want to see how pressure plates and doors play together, you'll have to try that yourself :P

Have fun!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 03:58:04 pm
And there's still more to optimize. Partial loop unrolling as 2x16bit access is slower than 1x32bit for example.

To give you an example of a almost fully optimized function, I optimized drawTexture some more: https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151 (https://github.com/Vogtinator/crafti/blob/master/texturetools.cpp#L151)
GCC does some partial unrolling, but doesn't transform 2 16bit accesses (ldrh/strh) to 32bit access(ldr/str), although -Ofast should do something, should I report a bug?
Code: [Select]
    8e28:   e15392b4    ldrh   r9, [r3, #-36]   ; 0xffffffdc
    8e2c:   e14292b4    strh   r9, [r2, #-36]   ; 0xffffffdc
    8e30:   e15392b2    ldrh   r9, [r3, #-34]   ; 0xffffffde
    8e34:   e14292b2    strh   r9, [r2, #-34]   ; 0xffffffde

There are actually two reasons why a compiler cannot use 32bit memory move instructions here.

1:
Code: [Select]
COLOR *dest_ptr = dest.bitmap + dest_x + dest_y * dest.width, *src_ptr = src.bitmap + src_x + src_y * src.width;dest_ptr might be src_ptr + 1 ( *src_ptr is not const ) so moving two texels for this case will produce different results.

2:
It is not guaranteed that src_ptr and dest_ptr are each aligned to 4 byte which is required if you want to move 4 byte at a time on ARM.

To 1: I tried various GCC options to force such an optimization (but actually overlooked the missing const, thanks!)
2: Various GCC options + __builtin_assume_aligned
and it just doesn't want to optimize it -.-

Quote
First, sorry for being angry like this. I know it's ridiculous and shit, but I just had enough of seeing people implying the lib was supposedly slow. (and Vogtinator I never meant you, I know aeTIos kept saying it some time ago although he stopped now ; or maybe I'm just being too proud or paranoid, don't know which).
Well, then I wonder why you posted here.. To tell everybody my lib was slow as well/as fast as yours?
That "by the way, it's faster than n2DLib" just sitting here without any further development really made me upset.
From my POV you ignored my hints and I just had to write it, sorry.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 09, 2014, 03:59:00 pm
DJ : I didn't want to start a war about what lib was better, I was just asking please stop assuming my lib is slow without even trying it or wondering if that's not your code's fault x.x I remember some days ago on IRC, Streetwalrus was saying something like "tetris is slow, it's n2DLib's fault" and was serious about it, and of course it turned out the problem was his own code. The fact itself isn't really important, it's just the way of thinking that's annoying. But let's forget that and pretend it never happened.
When did I say that ? ??? I was just jokingly saying that n2DLib's 4K was big, which it obviously isn't.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 04:06:56 pm
If you use most standard C/POSIX features like sprintf, fopen and opendir the MINIMUM executable size is 52K on my fork, which is more than the current ndless_resources_3.6.tns  :o  But still less than a fullscreen image :P

Could we keep this slowly getting ridiculous and annoying discussion about n2dlib vs nGL and Matrefeytontias vs everyone out of here and/or just FORGET it?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 09, 2014, 05:08:24 pm
@Streetwalrus : I remember saying "Y U never think it could be your own fault" or something like that, and you said "yeah sorry" or kinda.

ANYWAY what about you don't call that a versus because it's not one, and someone deletes the posts that have to be deleted ? I got enough drama for a while.

Also that looks great O.O does it still work on GS calcs which use the 3.1 version of Ndless, since you now use another executable format ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 09, 2014, 05:15:27 pm
Will pistons, comparators, and repeaters and the like be implemented?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 05:20:38 pm
Quote
Will pistons, comparators, and repeaters and the like be implemented?
Comparators have nothing to compare and repeaters nothing to repeat: Redstone in crafti is infinite!
I was actually planning to implement pistons in v1.1 but thought the last release was so long ago that I should release something.
It will come in v1.2 (or v1.1.1 maybe), probably together with stairs and maybe mobs.

Quote
Also that looks great  does it still work on GS calcs which use the 3.1 version of Ndless, since you now use another executable format ?
It should even run on some versions < 3.1, I'm not using much except fopen etc. at all.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 09, 2014, 05:23:27 pm
Actually repeaters still have two uses : delayers and diodes. They let you delay by one tick while torches need two ticks (since you need to re-invert the signal).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 05:37:58 pm
Quote
Actually repeaters still have two uses: delayers and diodes. They let you delay by one tick while torches need two ticks (since you need to re-invert the signal).
Looks like I haven't played minecraft in a while.. Added to the TODO list, but below everything else as not really necessary.
Redstone torches don't need two ticks: If the redstone wire connected to the torch is in the same chunk, it changes state every tick. (Not entirely true, it also depends on position and orientation of torch and redstone, like water which behaves a bit weird at chunk borders).
This could be an issue for repeaters, as it may be that the receiving redstone (at the repeater output) gets updated before the receiver changed state and thus having a two-tick delay. Ticks aren't even synchronous for Chunks, each chunk has its own timer, so it's distributed more evenly to prevent lag spikes. I could implement it more "reliable", but only with a heavy impact on overall performance and complexity.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 09, 2014, 05:41:26 pm
What I meant is since torches invert the signal, you need two of them to make a repeater, and then it's a two ticks repeater.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 09, 2014, 05:45:35 pm
What I meant is since torches invert the signal, you need two of them to make a repeater, and then it's a two ticks repeater.
Oh, now I realized what you meant, I should really go to bed now  ._.
In that case (a torch-based repeater) the delay could be as bad as 4 ticks + chunk timing differences
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 09, 2014, 06:13:09 pm
I never thought of using a torch based repeater for the time being :3

Comparators, yes, because the redstone is infinite, there could be issues with getting such a device working
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 10, 2014, 12:15:29 am
Wow, that redstone implementation looks sick! I really need to give the new version a try when I have time :)

Do you plan a ticalc.org update soon?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 10, 2014, 02:20:43 am
That looks awesome :D
I think I will never get tired of giving +1s to your updates :P

I just had a question when reading your post. What is format Zehn ? I only get redirected to German pages when I google it o.o
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 10, 2014, 03:22:09 am
Quote
Wow, that redstone implementation looks sick! I really need to give the new version a try when I have time :)
The implementation IS sick. Just look at the code :P

Quote
I just had a question when reading your post. What is format Zehn ? I only get redirected to German pages when I google it o.o
You know ELF, right? Elf is German for eleven and Zehn is German for ten, that should explain it :)
Basically it's a custom format without the restrictions of bFLT which should load faster and supports code without PIC and with exceptions.

Quote
Do you plan a ticalc.org update soon?
Hm, why not?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 10, 2014, 04:16:21 am
Quote
I just had a question when reading your post. What is format Zehn ? I only get redirected to German pages when I google it o.o
You know ELF, right? Elf is German for eleven and Zehn is German for ten, that should explain it :)
Basically it's a custom format without the restrictions of bFLT which should load faster and supports code without PIC and with exceptions.
Ok, thanks :)

Also wow, I just updated crafti on my calc and it's really great :D (not that it was bad before :P)
There is just something that annoys me a bit. Would it be possible to have a higher touchpad sensitivity ? Because I have to rub it 5 times before seeing what's behind me :P
Of course, you can make it an option to have both precision-people and speed-people happy :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 10, 2014, 09:43:10 am
Quote
Also wow, I just updated crafti on my calc and it's really great  (not that it was bad before )
There is just something that annoys me a bit. Would it be possible to have a higher touchpad sensitivity ? Because I have to rub it 5 times before seeing what's behind me
Of course, you can make it an option to have both precision-people and speed-people happy
You can rotate faster if you press the touchpad - this is also dependant on your "Speed" setting. I didn't make the "rubbing" speed change with "Speed", as it would be impossible or too hard to aim on fastest speed.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 10, 2014, 10:10:26 am
What do you use for screenshots? I want to make a screenshot of an AND logic gate and a clock I made last night!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Adriweb on July 10, 2014, 10:23:31 am
Probably taken from running the game in nspire_emu. (well, at least it's the quickest way to get it)

Although a screenshot feature within the game would be cool (if it's not there already, I don't know :P)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 10, 2014, 10:41:07 am
Quote
Probably taken from running the game in nspire_emu. (well, at least it's the quickest way to get it)
Correct, and the gifs are made using byzanz-record. I move the window to the coords 0/0 and start it with "-x 0 -y 0 -w 320 -h 240".

Quote
Although a screenshot feature within the game would be cool (if it's not there already, I don't know )
I had implemented it once but lost the code somehow (it was before v0.7.2, when I moved to git). But it's on my todo list again!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Adriweb on July 10, 2014, 11:00:32 am
Quote
Although a screenshot feature within the game would be cool (if it's not there already, I don't know )
I had implemented it once but lost the code somehow (it was before v0.7.2, when I moved to git). But it's on my todo list again!
Maybe a part of that could help (instead of recoding this feature from scratch) : http://tiplanet.org/forum/archives_voir.php?id=12264
(also, I like the Ctrl-capture shortcut ... :P)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 10, 2014, 12:04:56 pm
I generally use Camstudio+VirtualDub or Calccapture, but Camstudio+VirtualDub produces horribly large GIFs and CalCapture colors are terrible.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on July 10, 2014, 05:41:58 pm
I think that this project is cool. </keepcalm>

*explodes*
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 11, 2014, 08:20:47 am
I added a screenshot feature in Crafti: Press Crtl + . in-game to save the screen as /documents/ndless/screenshot.ppm.tns. It doesn't call refresh_osscr() as it would take too long, so don't wonder if it doesn't show you that the file exists. I changed the file of my v1.1 announcement as it's not really a new version.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 11, 2014, 08:46:49 am
Lol, great :D

Could it be possible though to have it save in screenshotXXX.ppm.tns, where XXX ranges from 000 to 999 ? In case we have to do more than one screenshot while we are on vacations :P

Also, about the sensitive touchpad (yeah, again :P), couldn't it be possible to have the "center zone" of the touchpad be precise, and the "outer zone" be fast ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 11, 2014, 08:56:12 am
Quote
Could it be possible though to have it save in screenshotXXX.ppm.tns, where XXX ranges from 000 to 999 ? In case we have to do more than one screenshot while we are on vacations
That could get slow, but why not. I'll also add some kind of notification ("Saved as %d.ppm") on the screen.

Quote
Also, about the sensitive touchpad (yeah, again ), couldn't it be possible to have the "center zone" of the touchpad be precise, and the "outer zone" be fast ?
That could be weird if you wipe across the pad and it gets slower in the center. But I'll probably make the rotation speed dependant on the touchpad velocity.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 11, 2014, 08:58:01 am
Quote
Could it be possible though to have it save in screenshotXXX.ppm.tns, where XXX ranges from 000 to 999 ? In case we have to do more than one screenshot while we are on vacations
That could get slow, but why not. I'll also add some kind of notification ("Saved as %d.ppm") on the screen.
Well, only slow while saving, so not a big problem as long as it doesn't last ;)
Thanks :)

But I'll probably make the rotation speed dependant on the touchpad velocity.
Yeah, very good idea, I don't even know why I didn't think about it :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 11, 2014, 12:08:56 pm
Ooh I like the capture idea. It should be handy for when we want to do it on calc :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 11, 2014, 12:51:09 pm
A small feature to the settings, is it possible to change the view angle without compromising the performance?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 11, 2014, 12:52:47 pm
I don't see what you mean. Uou can already look around with the touchpad, can't you ? Or is that not what you want ?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Runer112 on July 11, 2014, 01:15:53 pm
I'm assuming he means field of view, which I agree is a nice feature in any first-person 3D game.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Streetwalrus on July 11, 2014, 01:18:47 pm
I always set the fov to default. :P Might be handy on a superwidescreen setup though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 11, 2014, 05:20:20 pm
I implemented FOV changing as well as up to 1000 screenshots and some nice messages on screen! As usual, I replaced crafti.prg.tns.zip from the last announcement.

Screenshot:
(http://i.imgur.com/q543i69.gif)

Normal FOV:
(http://i.imgur.com/4W0nY4R.gif)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 12, 2014, 10:25:42 am
Thanks!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 13, 2014, 08:08:37 am
Somehow I want to make something different than Crafti with nGL and Perspective (http://www.seewithperspective.com/) came into my mind.
With some Z-buffer tricks and smaller worlds nGL should handle it fairly well. What do you think?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 13, 2014, 08:21:49 am
Could be cool :) though it's too bad that it is said nowhere that the first game to use this concept was Eco-Sphere on PSP, several years ago.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 13, 2014, 11:05:29 am
Such game would be interesting actually. :D

Or if your engine supports sloppy terrain you could do Reuben Quest 3D :trollface:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on July 13, 2014, 11:14:09 am
Looks like fun indeed ^^
But I don't know how you'll do a convenient camera movement without a mouse.

Otherwise, you can also make a Portal game if you lack ideas :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 13, 2014, 11:57:05 am
Quote
Could be cool  though it's too bad that it is said nowhere that the first game to use this concept was Eco-Sphere on PSP, several years ago.
Not echochrome? It was boring as hell...

Quote
Or if your engine supports sloppy terrain you could do Reuben Quest 3D
(https://wheredreamscollide.files.wordpress.com/2012/05/no-meme.jpg)
You can do it if you want to :P

Quote
Looks like fun indeed ^^
But I don't know how you'll do a convenient camera movement without a mouse.
Like in Crafti?

Quote
Otherwise, you can also make a Portal game if you lack ideas :P
I thought about that but without physics, large levels and some complex mechanics it wouldn't be fun. Perspective is quite simple and can also be fun with smaller levels.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 13, 2014, 12:02:30 pm
TipOver 3D.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 13, 2014, 12:08:34 pm
Yeah well I didn't quite remember the name and went pretty random <_< it's indeed Echochrome, and well if it's boring, then Perspective is boring, since it's pretty much the same game.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 13, 2014, 12:11:49 pm
Quote
Yeah well I didn't quite remember the name and went pretty random  it's indeed Echochrome, and well if it's boring, then Perspective is boring, since it's pretty much the same game.
Not really. On echochome you can only control the camera, the weird walking things were controlled by the computer.
In Perspective you can walk around and switch between controlling the 2d character the way you're currently looking at the world and controlling the 3d character by walking around. The goal is to get the 2d character to the end.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 13, 2014, 02:10:30 pm
Perspective? No...no...no Minecraft on Nspire?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on July 14, 2014, 03:15:17 pm
So would a redstone 83+ emulator be feasible? :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on July 16, 2014, 02:20:44 pm
Most likely. I believe I saw a video of a redstone cpu that was architectuarily congruent to an 8080 chip
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: CalebHansberry on July 16, 2014, 08:30:14 pm
The Nspire finally gets a good 83+ emulator!
*runs*
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Francois Medina on July 23, 2014, 03:19:49 pm
Wow the game is Amazing, I just noticed a bug on big redstone structures : some lanterns  turn on and off the wrong way (like light turns on when wire is off and off when wire is on)
I don't know how to do screenshots so I have no pictures :/
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 25, 2014, 08:59:59 am
Actually, that's not a bug, that's how it works. If the redstone signal changes at the same time the torch notices the previous state change, it appears broken but it isn't. It's basically the "in-between" state you see. If thats the case even if you wait some seconds, please upload your world so I can fix it.
You can do screenshots with "Ctrl+.".

BTW: What are you building? :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on July 26, 2014, 03:05:24 pm
I made a video to demonstrate how it looks and runs on hardware, recorded in 1080p :P

Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on July 26, 2014, 04:11:59 pm
So many pixels for so few pixels :trollface:

It actually runs super-great :D can't wait to have a color TI-Nspire in a way or another to try that ;D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: GinDiamond on August 22, 2014, 02:15:48 pm
Any further work onto this?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on August 22, 2014, 02:22:11 pm
Not now, I'm busy with some other, more important projects and also other parts of my life.
It's open source and the code should be quite easy to understand, though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Eiyeron on August 26, 2014, 10:03:57 am
Is there any way to get only the source for nGL and not crafti? I'd like to fiddle with it sometimes.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on August 26, 2014, 10:16:41 am
There's not a seperate repository for it, but you can copy the nGL files from https://github.com/Vogtinator/crafti (https://github.com/Vogtinator/crafti).
The core files are:
gl.cpp gl.h triangle.inc.h glconfig.h fix.h fastmath.cpp fastmath.h
For some 2D functionality:
font.cpp font.h texturetools.cpp texturetools.h
And basic 3D stuff:
aabb.cpp aabb.h glbox.cpp glbox.h gldrawable.h
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Eiyeron on August 26, 2014, 10:17:17 am
I saw the textures in crafti were a little wonky (maybe for speed reasons), are there any texture routine more accurate?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on August 26, 2014, 10:50:34 am
Quote
I saw the textures in crafti were a little wonky (maybe for speed reasons), are there any texture routine more accurate?
Depends on what you mean by "wonky". Some inaccuracies are due to the fixed point math.
For obvious reasons it's doing Affine texture mapping (http://upload.wikimedia.org/wikipedia/commons/thumb/5/57/Perspective_correct_texture_mapping.jpg/400px-Perspective_correct_texture_mapping.jpg), but you don't notice that much while playing.
The problem is, that for every scanline, the X distance is the total length of the line. If you want to do it the "correct" way, the length is sqrt(dx*dx+dz*dz), but doing it every line (or like quake, every 5th or so) is still a whole lot too slow. And I can't use the invsqrt trick, as that only works for floats.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Eiyeron on August 26, 2014, 10:52:51 am
Okay, I just wanted to know why, thanks!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on November 07, 2014, 11:09:47 am
Finally, Crafti gets its ticalc news feature :D http://www.ticalc.org/archives/news/articles/14/148/148684.html

Also I need to check the latest version at one point because I think what I got is an older version.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 07, 2014, 12:22:51 pm
Quote
Finally, Crafti gets its ticalc news feature  http://www.ticalc.org/archives/news/articles/14/148/148684.html (http://www.ticalc.org/archives/news/articles/14/148/148684.html)
:w00t: I uploaded the latest version some months ago so this is a real surprise for me.

Quote
Also I need to check the latest version at one point because I think what I got is an older version.
That's fairly simple, the latest version doesn't have the ugly black gradient with 50% opacity menu.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on November 07, 2014, 12:24:35 pm
Aw, I liked that menu for some reasons D:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 07, 2014, 12:53:03 pm
Aw, I liked that menu for some reasons D:
Oh, I just noticed I didn't change the menu at all in v1.1, the ugly black menu is gone since v1.0. For comparision:

Old:(http://i.imgur.com/jq4svm6.gif)New:(http://img.ourl.ca/crafti_v1.0_menu.png)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: ben_g on November 07, 2014, 02:31:50 pm
That old menu doesn't look ugly to me, it looks clean and modern. The new one does have more 'feel' to it though.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: DJ Omnimaga on November 07, 2014, 10:39:41 pm
Aw, I liked that menu for some reasons D:
Oh, I just noticed I didn't change the menu at all in v1.1, the ugly black menu is gone since v1.0. For comparision:

Old:(http://i.imgur.com/jq4svm6.gif)New:(http://img.ourl.ca/crafti_v1.0_menu.png)
Oh right yeah that menu. I like the new one actually. I thought you meant the items menu at first. :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on November 08, 2014, 01:08:41 pm
Question: is nGL (the library) not on GitHub? I'd really like to use it, after seeing how powerful it is.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on November 08, 2014, 01:10:39 pm
Question: is nGL (the library) not on GitHub? I'd really like to use it, after seeing how powerful it is.
A quick search didn't come up with anything: https://github.com/search?q=nGL%20nspire&type=Everything&repo=&langOverride=&start_value=1
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 08, 2014, 01:35:28 pm
Question: is nGL (the library) not on GitHub? I'd really like to use it, after seeing how powerful it is.
A quick search didn't come up with anything: https://github.com/search?q=nGL%20nspire&type=Everything&repo=&langOverride=&start_value=1
Click on "Code" :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on November 08, 2014, 01:39:35 pm
All that is crafti. I want to be able to git submodule just the library to use it. Will you please put the library in a separate repo? Thank you.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 08, 2014, 01:40:57 pm
Will do, just wait a minute.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on November 08, 2014, 01:43:18 pm
Yay thanks!

Now to begin work on my secret project. :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on November 08, 2014, 01:51:28 pm
Yay thanks!

Now to begin work on my secret project. :D
It's up on https://github.com/Vogtinator/nGL. I added a "lib" taget to the Makefile so you can use it from within a subdirectory. If you need help, just write a PM :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: aeTIos on November 08, 2014, 06:23:21 pm
Dang. Why didn't I see this earlier? O.O
Actually I did see the thread but I never really bothered to reply. Gotta show my support one time :P I really hope to see crysis for the Nspire one time using this lib. That's totally possible, right? :trollface:
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: bb010g on November 08, 2014, 10:19:00 pm
Question: is nGL (the library) not on GitHub? I'd really like to use it, after seeing how powerful it is.
A quick search didn't come up with anything: https://github.com/search?q=nGL%20nspire&type=Everything&repo=&langOverride=&start_value=1
Click on "Code" :P
/me derps
Yay thanks!

Now to begin work on my secret project. :D
It's up on https://github.com/Vogtinator/nGL. I added a "lib" taget to the Makefile so you can use it from within a subdirectory. If you need help, just write a PM :)
You should add "Nspire" to the repo description at least. :)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on January 10, 2015, 07:09:42 am
Crafti is last year's ticalc POTY! ;D

(http://www.ticalc.org/images/poty/2014-nspire-big.gif) (http://www.ticalc.org/community/awards/poty/2014.html#3)

Huge thanks to everone voting for me :-*
The competition was strong, I expected nQuake to score much higher.

Also, I've been working on the next release for some time already, but it's not going to be finished soon, I'm busy with school stuff and in a few months, work.

Edit: Over 1000 downloads, >700 on ticalc alone!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on January 14, 2015, 01:24:48 pm
Crafti is last year's ticalc POTY! ;D

(http://www.ticalc.org/images/poty/2014-nspire-big.gif) (http://www.ticalc.org/community/awards/poty/2014.html#3)

Huge thanks to everone voting for me :-*
The competition was strong, I expected nQuake to score much higher.

Also, I've been working on the next release for some time already, but it's not going to be finished soon, I'm busy with school stuff and in a few months, work.

Edit: Over 1000 downloads, >700 on ticalc alone!

Sweet! Can't wait for the next update!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Mike Stramba on January 15, 2015, 09:46:56 am
Hi Vogtinator,

I tried opening  crafti.prg.tns with Teacher Software trial 3.9.0.463,  but get :

This document format is not supported

This happens with either the latest "Redstone Update" release or from
http://www.ticalc.org/archives/files/fileinfo/460/46054.html

I tried running the software in both "normal" and "CAS" mode

Mike
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Legimet on January 15, 2015, 01:10:46 pm
Ndless (native) programs don't run on the simulator. You can try either a real calc or nspire_emu (and you will need Ndless (http://ndless.me/)).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Mike Stramba on January 16, 2015, 03:17:52 pm
Ok thx.

Not much of a simulator then is it ?

> nspire_emu (and you will need Ndless).

Seems like those only work if you already have a real calculator (to download the rom) ?

If so, why would anyone want to use an emulator if you have the real thing?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on January 16, 2015, 04:03:22 pm
For debugging and testing mostly. That is also why setting up nspire_emu isn't very user-friendly (for now).
With the emulator it's possible from the IDE to press F5 to upload the file to the emulator and run or debug it automatically.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Keoni29 on January 17, 2015, 07:55:14 am
Congrats on the POTY. I have not checked on this project in a while and I must say that I am really pleased with the progress you made. Great work :D
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 13, 2015, 08:38:25 pm
I finally got around to writing a tutorial on how to use nGL: http://github.com/Vogtinator/nGL
Maybe we'll see some more 3D games on the nspire now!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 13, 2015, 08:53:06 pm
Yay, finally ! :D

I found this cool game called Env recently, I might want to try and clone it. In a while, 'cause school and hundreds of active projects and stuff.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: gameblabla on May 16, 2015, 04:36:00 pm
I finally got around to writing a tutorial on how to use nGL: http://github.com/Vogtinator/nGL
That would be great if you made a tutorial about texture mapping.
Also, does anyone know if nGL is faster for 2D stuff than n2DLib ?
From what i've seen, it seems so.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 16, 2015, 04:59:43 pm
Quote
That would be great if you made a tutorial about texture mapping.
Will do, that's the next step :)

Quote
Also, does anyone know if nGL is faster for 2D stuff than n2DLib ?
The 3D parts definitely not. Although it's faster on desktop machines to use orthogonal projection for 2D rendering as that's hardware accelerated,
that's not the case here.
There is a small 2D part in texturetools.cpp, for working with TEXTURE objects, like (GL_LINEAR scaled) blitting, block blitting with 50% opacity, resizing and converting to greyscale for classic calcs, but not much more. Those parts are optimized, thus probably faster than n2DLib (never tested, but it might show if you blit an excessive amount of pixels) and support blitting from TEXTURE to TEXTURE instead of blitting to screen only.
If you read some older posts in this thread and n2DLib, you might notice that there was already quite a discussion about speed...

Edit: Lesson 2 - Texture mapping, is up.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Matrefeytontias on May 16, 2015, 06:41:58 pm
Yeah well people wouldn't stop talking shit about how n2DLib was slower than nGL even though not a single test was ever made. I'm very glad to notice the exact same sentence again, "it's probably faster (though never tested)". You optimized it ? Oh yeah cool, so did pierrotdu18, Hayleia and I. So if someone could make the damned speed test so that we finally know.

For the thousandth time, I won't be angry if nGL is faster that n2DLib. But reading sentences like "it's optimized, thus probably faster than n2DLib" clearly assuming that n2DLib is not optimized, thus totally ignoring all the work that was put into it by several people, that really upsets me.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 17, 2015, 01:39:43 am
I finally got around to writing a tutorial on how to use nGL: http://github.com/Vogtinator/nGL
Maybe we'll see some more 3D games on the nspire now!
Yay tutorials! Now to make some cool stuff with nGL!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 17, 2015, 08:07:19 am
I don't know why I even bother answering this the second time, I wrote this some time ago already.

Quote
Yeah well people wouldn't stop talking shit about how n2DLib was slower than nGL even though not a single test was ever made.
I would make a test, but n2DLib doesn't support TEXTURE-TEXTURE blitting what nGL does. Although that shouldn't make a huge difference, it'll be unfair.

Quote
You optimized it ? Oh yeah cool, so did pierrotdu18, Hayleia and I.
Well, I'm sorry to say, but it just doesn't look like it.
The drawSprite routine, as the simplest example, makes a call to setPixel per pixel.
This is bad because of four reasons:
-Function calls are slow
-Two comparisons
-Multiplication
-Variable loaded from RAM, indirectly

For easier comparision, here are the two inner loops of drawSprite and the nGL equivalent, compiled with the same flags as your example:
Code: [Select]
00000a80 <setPixel>:
     a80:       e35100ef        cmp     r1, #239        ; 0xef
     a84:       93500d05        cmpls   r0, #320        ; 0x140
     a88:       33a03d05        movcc   r3, #320        ; 0x140
     a8c:       30210193        mlacc   r1, r3, r1, r0
     a90:       359f300c        ldrcc   r3, [pc, #12]   ; aa4 <setPixel+0x24>
     a94:       31a01081        lslcc   r1, r1, #1
     a98:       35933000        ldrcc   r3, [r3]
     a9c:       318320b1        strhcc  r2, [r3, r1]
     aa0:       e12fff1e        bx      lr
     aa4:       00011078        .word   0x00011078

In drawSprite:
     c94:       e1550008        cmp     r5, r8
     c98:       e08b3005        add     r3, fp, r5
     c9c:       aa000008        bge     cc4 <drawSprite+0x68>
     ca0:       e0da20b2        ldrh    r2, [sl], #2
     ca4:       e1d630b4        ldrh    r3, [r6, #4]
     ca8:       e1530002        cmp     r3, r2
     cac:       0a000002        beq     cbc <drawSprite+0x60>
     cb0:       e1a01004        mov     r1, r4
     cb4:       e1a00005        mov     r0, r5
     cb8:       ebffff70        bl      a80 <setPixel>
     cbc:       e2855001        add     r5, r5, #1
Code: [Select]
5a0:   e25cc001        subs    ip, ip, #1
 5a4:   3a000005        bcc     5c0 <drawTexture(...)+0x158>
 5a8:   e0d560b2        ldrh    r6, [r5], #2
 5ac:   e1d080b6        ldrh    r8, [r0, #6]
 5b0:   e2811002        add     r1, r1, #2
 5b4:   e1580006        cmp     r8, r6
 5b8:   114160b2        strhne  r6, [r1, #-2]
As that code is run per pixel, I guess that that is definitely a noticable difference.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Adriweb on May 17, 2015, 09:13:38 am
I guess one is optimized C, the other is optimized ASM... (or, at least, C code such that the ASM gets optimized much better in the end). So clearly on this level the assembly-optimized version can only be better.
But knowing how to optimize at this level is definitely something that much less people know how to do.

And I'm sure that since both things are open-source, one could help the other when needed ;)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: pimathbrainiac on May 17, 2015, 12:16:42 pm
That with what Adriweb said. I'm sure if you all worked on the same project, we'd get one even better library than either of the two are now :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Hayleia on May 17, 2015, 05:21:15 pm
You optimized it ? Oh yeah cool, so did pierrotdu18, Hayleia and I.
Wut ? I don't know about pierrot and you but I didn't do anything. I pretty much dropped the project when I saw one of you was not putting brackets for one-instruction blocks, even when it's a for in a for (which leads to very ugly code in my opinion).
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: rwill on May 18, 2015, 09:35:12 am

For easier comparision, here are the two inner loops of drawSprite and the nGL equivalent, compiled with the same flags as your example:
Code: [Select]
...As that code is run per pixel, I guess that that is definitely a noticable difference.

Sadly both routines appear to be quite unoptimized.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Adriweb on May 18, 2015, 09:47:55 am
Then let's just code the lib in hand-written ASM directly :P
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 18, 2015, 01:44:43 pm
Quote
Sadly both routines appear to be quite unoptimized.
I guess you could make it faster by doing 32-bit transfers, but the shortest asm version with word-transfers is the nGL version minus
Code: [Select]
ldrh    r8, [r0, #6], because that should happen outside of the loop and r1 could be used as counter instead of r12.
Basically (r0 is source, r1 is dest, r2 is end of source)
Code: [Select]
loop:
ldrh r3, [r0], #2
strh r3, [r1], #2
cmp r0, r2
bne loop
Also, 32bit transfers would be impossible if source or dest aren't 32-bit aligned which isn't the case if you have an uneven X.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: rwill on May 18, 2015, 03:40:58 pm
Shorter is not *edit* always */edit* faster. Especially given the ARM9EJ-S core.

*edit*

Given your example, which seems to copy without the transparency check, we end up with something this ( cycle estimate at end of line ):

Code: [Select]
loop:
ldrh r3, [r0], #2   | 1
strh r3, [r1], #2   | 2-4 ( 2 cycles of 2 cycle interlock on r3 )
cmp r0, r2     | 5
bne loop            | 6-8

So, for example, unrolling the loop would help quite a bit.
8 Cycles for copying a single pixel without any transformation is way too much.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 20, 2015, 07:44:41 am
Quote
So, for example, unrolling the loop would help quite a bit.
8 Cycles for copying a single pixel without any transformation is way too much.
It would, but as I said, only possible if Xsrc % 2 == Xdest % 2, so not widely applicable.

Quote
8 Cycles for copying a single pixel without any transformation is way too much.
Yeah, but I guess you can't do much about it without using Asm (and I target not to, except if there are very obvious improvements).
The assembler doesn't look much different with more gcc optimizations.

Quote
Given your example, which seems to copy without the transparency check, we end up with something this ( cycle estimate at end of line ):
I guess it could be improved by one cycles if the cmp is moved between the ldrh/strh?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: rwill on May 20, 2015, 10:08:15 am
Ah .. might as well be more specific and direct ..
Code: [Select]
void blit_pels( const int16_t *pp_srcB, int32_t i_src_stride, int16_t *pp_dstB, int32_t i_dst_stride, int32_t i_width, int32_t i_height )
{
int32_t i_y;
for( i_y = 0; i_y < i_height; i_y++ )
{
int16_t pp_a0, pp_a1, pp_a2, pp_a3;
const int16_t *pp_src;
int16_t *pp_dst;
int32_t i_remain4, i_remain1;

pp_src = pp_srcB;
pp_dst = pp_dstB;

i_remain4 = i_width >> 2;
while( i_remain4 > 0 )
{
pp_a0 = *( pp_src++ );
pp_a1 = *( pp_src++ );
pp_a2 = *( pp_src++ );
pp_a3 = *( pp_src++ );
*( pp_dst++ ) = pp_a0;
*( pp_dst++ ) = pp_a1;
*( pp_dst++ ) = pp_a2;
*( pp_dst++ ) = pp_a3;
i_remain4--;
}

i_remain1 = i_width & 3;
while( i_remain1 > 0 )
{
pp_a0 = *( pp_src++ );
*( pp_dst++ ) = pp_a0;
i_remain1--;
}
pp_srcB += i_src_stride;
pp_dstB += i_dst_stride;
}
}


There might be some gain to increase the unroll block to 8 pixels instead of the 4 but I did not bother to even test this one here.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 21, 2015, 11:02:19 am
Quote
Quote
So, for example, unrolling the loop would help quite a bit.
8 Cycles for copying a single pixel without any transformation is way too much.
It would, but as I said, only possible if Xsrc % 2 == Xdest % 2, so not widely applicable.
Somehow I was thinking about 32-bit access here, I don't know why.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: rwill on May 22, 2015, 11:45:56 am
... 32-bit access ...

I have not checked but later versions of GCC should be able to produce code for ARM that will use 32 bit moves if possible given my example function. Thinking about it further - the function might be made faster by doing 2 lines at the same time inside the inner copy loop. Ah well, "high level" optimizations...
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: Vogtinator on May 20, 2016, 05:54:35 pm
Crafti v1.2

No major changes, just some bugfixes and improvements.
I haven't tested classic support extensively, so if you're relying on that you should keep your old version around.
On a HW-W calc this should improve usability significantly, so please upgrade!

(http://i.imgur.com/cqkOsWc.png)
Improvements in crafti (https://github.com/Vogtinator/crafti):
  • Bugfix: Division by 0 when calculating collision while looking straight ahead
  • Zehn compression for faster startup and less space requirements

(http://i.imgur.com/Db2REly.gif)
Improvements in nGL (https://github.com/Vogtinator/nGL):
  • Several performance improvements
  • Uses lcd_blit, so works natively on HW-W
  • On PC, use SDL for graphics
  • Add tools for converting wavefront obj
  • Add VECTOR3 and nglDrawArray
  • Add two new lessons to the tutorial (https://github.com/Vogtinator/nGL/tree/master/Tutorial)
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: nspireguy on July 19, 2016, 03:04:16 pm
Awesome!
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: stevepetoskey on June 13, 2019, 04:03:13 pm
Is crafti still getting updates?
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: TIfanx1999 on June 25, 2019, 09:59:08 pm
Seeing that the last post was 2016, and the last time the author was active was 2017, it doesn't seem very likely.
Title: Re: nGL - a fast (enough) 3D engine for the nspire
Post by: potatOS on July 20, 2019, 07:22:52 pm
how do i change the texture files for the blocks? i have a png of the resource pack that i want to use, and it should be compatible as the png is the same resolution. however, i cant seem figure out how to successfully convert the png to the hex code in terrain.h (in the textures folder) and get anything more than a blue garbled mess in the game; just as a test i decided to re-build the game without editing any files to see if the problem was the compiler or the file edits, and the textures were perfectly intact. i would greatly appreciate it if you could tell me what program/website you used to convert the png into hex, or just generally what methods/settings were used.