Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasherpete committed Oct 31, 2023
1 parent e638039 commit 1a3f52d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
This is just a simple algorithm for the TI-84+ CE to render simple voxels quickly and dynamically. For now it is just an engine/algorithm, but once it is in a ready stage, it will be used to make a couple games.

![gif](https://cdn.discordapp.com/attachments/1168344250908418078/1168599163961868358/screen.gif) ![image](https://cdn.discordapp.com/attachments/772599413247442948/1168328775025561660/wireframe1.png)

### Setup

In `main.c`, you will find some `#define`'s at the top. Just configure them to your needs. If you change any of the Z render distances, make sure to regenerate the `powAZx50` array by using the Python script found in /utils.

### TODO

- [ ] Add common voxel coordinate lookup table to optimize rendering
Expand All @@ -12,6 +17,9 @@ This is just a simple algorithm for the TI-84+ CE to render simple voxels quickl
- [ ] Find a way to render everything unclipped (will need help!!)
- [ ] Render screen coordinates using 8 bit values instead of 16 - will allow the right side of the screen to be used for stats

<br>

- [x] *Unplanned*: Implement a lookup table for both powAZx50 variables - which are calculated every voxel
### Changelog

***v0.1.0*** - First demo
16 changes: 10 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,28 @@
#define GFX_WIDTH_HALF 160

// all exclusive
#define RENDER_DIST_X 4 // dont draw below -4x or higher than 4x
#define RENDER_DIST_Y 3
#define RENDER_DIST_X 8 // dont draw below -4x or higher than 4x
#define RENDER_DIST_Y 8
#define RENDER_DIST_Z_BACK 3 // back from the camera
#define RENDER_DIST_Z_FRONT 8 // above 0

// simple rectangular prism. cone-shape would be best.
// simple rectangular prism. cone-shape would be best in the future
#define RENDER_DISTANCE_ALGORITHM (z > -RENDER_DIST_Z_BACK) && (z < RENDER_DIST_Z_FRONT) && (x < RENDER_DIST_X) && (x > -RENDER_DIST_X) && (y < RENDER_DIST_Y) && (y > -RENDER_DIST_Y)


// when you change the Z render distance, update these values using the Python script
uint8_t powAZx50list[] = {98, 78, 62, 50, 40, 32, 26, 20, 16, 13, 10};

void drawBox(int x, int y, int z) {


void drawBox(int_fast8_t x, int_fast8_t y, int_fast8_t z) {

// render distance calculations. needs improvement
if (RENDER_DISTANCE_ALGORITHM) {

// just some optimizations
const uint_fast8_t powAZx50 = pow(FOV,z) * 50;
const uint_fast8_t powAZp1x50 = pow(FOV,(z+1)) * 50;
const uint_fast8_t powAZx50 = powAZx50list[z+3];
const uint_fast8_t powAZp1x50 = powAZx50list[z+2];

// calculate values - data type needs to go from -1 to 241 height, 321 width
// potential optimization here. willing to make viewport 255x255
Expand Down
11 changes: 11 additions & 0 deletions utils/powAZx50.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import math

a = int(input("Enter the value of RENDER_DISTANCE_Z_BACK: "))
b = int(input("Enter the value of RENDER_DISTANCE_Z_FRONT: "))

list1 = []

for i in range(a, b):
list1.append(round(pow(.8, i)*50))

print(f"{{{str(list1)[1:-1]}}}")

0 comments on commit 1a3f52d

Please sign in to comment.