[WIP][SBDL] Procedural Texture

Procedural texture generated in realtime and applied on a sphere. Procedural texture used: SAF test by @drummyfish

SkyBerron Procedural Texture.bin.1_speed

SkyBerron Procedural Texture.bin.2_speed

SkyBerron Procedural Texture.bin (89.1 KB)

4 Likes

Not procedural but nice :slight_smile: You have precomputed offsets for that texture mapping?

EDIT: Or you’re planning to add procedural texture later?

Imho, anything generated on the fly can be considered procedural :wink: I was thinking about plasma or Conway’s as a cheap procedural, but SAF test is just perfect in terms of texture size and performance.
U/V texture coordinates and diffuse coefficient for shading are computed through raytracing and stored in 16 bit values. I could have included the precomputed values in flash, but I had got enough free RAM and enough compute power to do the raytracing at the start, one row per frame… didn’t you notice the raytracing running? :wink: Nearly realtime raytracing using floats. Press A and you get another raytracing of the sphere with different axial angles.
Another idea I had in mind is perspective corrected texture mapping on a cube, using multiple instances of SAF. Tbh, I’m using SAF++ as I turned SAF into a C++ class to allow encapsulation and object instancing. You know: less suckless, more functionality :wink:

But you’re not generating the texture on the fly, you’re reading it from somewhere.

Ah raytracing… and with floats? Quite surprised it’s running this nicely. But then you can do more shapes than just a sphere, that’s cool.

Every frame I call function loop from SAF test class (derived from SAF class) and it writes pixels through draw pixel calls to a 64x64 8bpp RAM buffer. That’s sort of generation on the fly. That image buffer is applied as texture to the sphere using the precomputed rendered sphere u+v+shading mapping and a variable x offset to give the impression of spinning. So the “live” output from SAF test is used as a dynamic texture that changes over time. Maybe it’s not what you would call procedural texture, but that’s enough procedural for me. Although the binary is bigger than 80 kb in size, there’s no texture nor look up tables in there (although there are fonts, Pico-8 palette, and a spritesheet reused from previous projects).
Yes, SBDL has grown bigger as I have added more functions. I’m afraid the linker has to include most of them even when they are not actually being used because I am lazy and using a lot of pointer to function arrays and unoptimized code. I will get to this issue later, maybe when I think of a better alternative to function pointers.

Shapes built with flat surfaces could be rasterized more efficiently using textured triangles. The spinning trick would only work with revolution surfaces. Sphere raytracers are very simple and fast. So I could not think of a better shape. Maybe a cylinder or cone could also work, removing the bouncing.
In my to do list there’s also something about bump mapping.

1 Like