summaryrefslogtreecommitdiff
path: root/src/libs
AgeCommit message (Collapse)Author
2022-04-28libs/din: lose the asserts in dotgradient()Vito Caputo
This just slows things down, and now that the code is mature enough to never trigger these asserts just get rid of them.
2022-04-28libs/din: minor optimization in clamp()Vito Caputo
short-circuit by directly returning bound when exceeded
2022-04-28libs/din: premultiply din->width * din->heightVito Caputo
dotgradient() is very hot and needs this result when indexing din->grid[]. Since it doesn't change for a given din instance, just cache the result @ din_new().
2022-04-27til_fb: til_fb_fragment_t.{pitch,stride} uint32_t unitsVito Caputo
Originally it seemed sensible to make these units of bytes, for flexibility reasons. But it's advantageous for everything to be able to assume pixels are always 4-byte/32-bit aligned. Having the stride/pitch be in bytes of units made it theoretically possible to produce unaligned rows of pixels, which would break that assumption. I don't think anything was ever actually producing such things, and I've added some asserts to the {sdl,drm}_fb.c page acquisition code to go fatal on such pages. This change required going through all the modules and get rid of their uint32_t vs. void* dances and other such 1-byte vs. 4-byte scaling arithmetic. Code is simpler now, and probably faster in some cases. And now allows future work to just assume things cna always occur 4-bytes at a time without concern for unaligned accesses.
2022-03-19*: drop til_module_t.licenseVito Caputo
Originally the thinking was that rototiller modules would become dlopen()ed shared objects, and that it would make sense to let them be licensed differently. At this time only some modules I have written were gplv3, Phil's modules are all gplv2, and I'm not inclined to pivot towards a dlopen model. So this commit drops the license field from til_module_t, relicenses my v3 code to v2, and adds a gplv2 LICENSE file to the source root dir. As of now rototiller+libtil and all its modules are simply gplv2, and anything linking in libtil must use a gplv2 compatible license - the expectation is that you just use gplv2.
2021-10-01*: librototiller->libtilVito Caputo
Largely mechanical rename of librototiller -> libtil, but introducing a til_ prefix to all librototiller (now libtil) functions and types where a rototiller prefix was absent. This is just a step towards a more libized librototiller, and til is just a nicer to type/read prefix than rototiller_.
2021-02-14*: split rototiller.[ch] into lib and mainVito Caputo
This is a first approximation of separating the core modules and threaded rendering from the cli-centric rototiller program and its sdl+drm video backends. Unfortunately this seemed to require switching over to libtool archives (.la) to permit consolidating the per-lib and per-module .a files into the librototiller.a and linking just with librototiller.a to depend on the aggregate of libs+modules+librototiller-glue in a simple fashion. If an alternative to .la comes up I will switch over to it, using libtool really slows down the build process. Those are implementation/build system details though. What's important in these changes is establishing something resembling a librototiller API boundary, enabling creating alternative frontends which vendor this tree as a submodule and link just to librototiller.{la,a} for all the modules+threaded rendering of them, while providing their own fb_ops_t for outputting into, and their own settings applicators for driving the modules setup.
2021-01-18modules/drizzle: low-hanging fruit optimizationsVito Caputo
- switch puddle_sample() to 0..1 coordinates to avoid some pointless extra arithmetic on every pixel - avoid redundant ->w multiplies in puddle_sample() - avoid multiplies in inner loops of drizzle_render_fragment() by accumulating coordinates w/addition instead I noticed full-screen 'compose' was struggling to keep a full frame rate on my laptop when testing with the new 'plato' layer. valgrind profiles showed drizzle as the big hog, mostly the puddle_sample() function. These changes help but it's still not great, getting much better will likely become invasive and crufty. It would be nice to cache the vertical lerp results and reuse them across puddle_sample() calls when valid, that might be a useful TODO. The runner-up is spiro, prolly some low-hanging fruit there as well, I haven't looked yet.
2020-02-10libs/sig: triangle wave; sig_ops_tri / sig_new_tri()Vito Caputo
Added a triangle wave
2020-02-04libs/sig: square wave; sig_ops_sqr / sig_new_sqr()Vito Caputo
This builds minimally upon the existing sine wave code, just use the sign to drive the signal high or low. Wikipedia shows a third state for 0 values, but that's for a -1..+1 signal. I'm producing all 0-1 signals as it's more convenient for this application, but it seems like it would be awkward to return .5f for the 0 case. So 0 is being treated as just another positive value; high.
2020-02-04libs/sig: add sig_new_$op wrappersVito Caputo
Provides improved ergonomics when using the bulitin ops, and much appreciated arity and type checking.
2020-02-03libs/sig: add sig_ref()Vito Caputo
Added some rudimentary refcounting so sig_t's can be readily shared by multiple sig_t's.
2020-02-03libs/sig: remove ticks_ms modulo in sig_ops_sinVito Caputo
Seems broken, fix it correctly later.
2020-02-03libs/sig: fix sig_ops_sin hz floor checkVito Caputo
off by one order of magnitude
2020-02-03libs/sig: add sig_ops_invVito Caputo
map 0-1 inputs to their inverse 1-0
2020-02-03libs/sig: s/sig_ops_inv/sig_ops_neg/gVito Caputo
Rename inv->neg, preparation for a new sig_ops_inv for inverting 0..1 to 1..0
2020-02-03libs/sig: add sig_ops_divVito Caputo
Included a little hack to defend against divide by zero, seems reasonable given the intended use cases.
2020-02-03libs/sig: add sig_ops_{add,sub}Vito Caputo
2020-02-03libs/sig: add sig_ops_expand convenienceVito Caputo
This is a specialized version of sig_ops_scale which assumes a min..max range of -1..+1 nvidia register combiners docs describe this operation as "expand normal", and they have several variants, but I don't want to go too crazy here right now. Plain expand it is.
2020-02-03libs/sig: add sig_ops_scale w/test exampleVito Caputo
This assumes the input value is always 0-1, but may be used to produce values in any signed range, mapped linearly to the input.
2020-02-03libs/sig: add sig_ops_inv for additive inverseVito Caputo
aka negation
2020-02-03libs/sig: fixup sig_ops_sin to stay within 0-1Vito Caputo
The whole idea was to produce values 0-1, except of course sig_ops_{mult,const} where one could deliberately get out of these bounds. Everything else should stay within 0-1 as it makes everything much more composable.
2020-02-03libs/sig: add sig_ops_{max,min}Vito Caputo
Supply two sig_t *'s: a, b
2020-02-03libs/sig: add sig_ops_clampVito Caputo
Supply three sig_t *'s: value, min, max
2020-02-03libs/sig: add ops_{abs,ceil,floor,pow,round}Vito Caputo
Added a simple test exercising pow and round
2020-02-03libs/sig: consideration for sig_t.ctxt alignmentVito Caputo
The flexible array of void *'s would just align to a pointer, which may not be safe for all members of whatever gets shoved in here. In an effort to make it more robust, make it an array of a junk drawer union of types.
2020-02-03libs/sig: update comment for ops_lerp_initVito Caputo
Comment was vestigial from ops_mult.c which ops_lerp.c was derived from.
2020-02-03libs/sig: add sig_ops_rand random generatorVito Caputo
(Ab)uses rand_r by feeding ticks_ms as seedp for pseudo-random numbers deterministically derived from ticks_ms.
2020-02-03libs/sig: remove math.h include from ops_const.cVito Caputo
2020-02-03libs/sig: cosmetic rearrangementVito Caputo
Make sig_ops_t.destroy functions consistently after init, no functional changes.
2020-02-03libs/sig: add sig_ops_lerp linear interpoplationVito Caputo
This takes three signals; a, b, and t t controls the weight interpolating between a and b, they all key off the same time ticks_ms.
2020-02-03libs/sig: convert ops_sin_ctxt_t.hz to a sig_t *Vito Caputo
Now hz can vary with time as well...
2020-02-03libs/sig: intrduce sig_ops_constVito Caputo
The simplest of signals: a constant value. The immediate need for this is to convert ops_sin_ctxt_t.hz to another sig_t enabling varying hz with time, while still being able to have a fixed hz as well.
2020-02-03libs/sig: introduce a signal generator abstractionVito Caputo
This adds a small framework of sorts for creating and composing signal generators. Two generators are implemented at this time; sig_ops_sin and sig_ops_mult sig_ops_sin accepts a hz variable and will produce a sine wave of that frequency. sig_ops_mult accepts two sig_t generators and multiplies their outputs Callers may construct their own sig_ops_t ops structs and supply them to sig_new(), but it's expected that libs/sig will grow a collection of commonly used generators which can then be used by simply passing their sig_ops_$foo to sig_new(). See the test code at the bottom of libs/sig/sig.c for some contrived sample usage. Note by composing multiple sig_ops_sin generators with a sig_ops_mult generator, one can already easily construct a synth-like LFO generator. Some obvious todos are to add triangle/sawtooth/square wave generators. More compositional generators may be interesting as well, like additive and subtractive for example. Those will need to implement clipping, as it's expected that the generators *always* stay within unity (0-1). No modules use this yet, but I expect to wire this up to rtv for driving knobs.
2020-01-12libs/ray: decouple film and frame dimensionsVito Caputo
The existing code conflated the rendered frame dimensions with what's essentially the virtual camera's film dimensions. That resulted in a viewing frustum depending on the rendered frame dimensions. Smaller frames (like in the montage module) would show a smaller viewport into the same scene. Now the view into the scene always shows the same viewport in terms of the frustum dimensions for a given combination of focal_length and film_{width,height}. The rendered frame is essentially a sampling of the 2D plane (the virtual film) intersecting the frustum. Nothing is done to try enforce a specific aspect ratio or any such magic. The caller is expected to manage this for now, or just ignore it and let the output be stretched when the aspect ratio of the output doesn't match the virtual film's aspect ratio. In the future it might be interesting to support letter boxing or such things for preserving the film's aspect ratio. For now the ray module just lets things be stretched, with hard-coded film dimensions of something approximately consistent with the past viewport. The ray module could make some effort to fit the hard-coded film dimensions to the runtime aspect ratio for the frame to be rendered, tweaking things as needed but generally preserving the general hard-coded dimensions. Allowing the frustum to be minimally adjusted to fit the circumstances... that might also be worth shoving into libray. Something of a automatic fitting mode for the camera.
2020-01-08libs/puddle: add a classic 2D raindrop sim libVito Caputo
These were commonish in the 90s demo days, done as a library to encourage use by different modules. You can simply render this directly onto a frame buffer like the old days, or sample it as a height map or density field for more complex compositions.
2019-12-18libs/din: fix scaling overflow, add assertsVito Caputo
Phil reported a crash in swab, illuminating an overflow in how the unit cube was being scaled to the noise field dimensions. Added some asserts enforcing critical assumptions as well, though it will probably cost some FPS in din-heavy modules like swab.
2019-11-25din: scale resultVito Caputo
I'd like the output to fill the range -1..+1, but it's not doing that and I'm uncertain on what exactly the scaling factor should be here. In one reference a factor of 1/sqrt(.75) is specified, but in my tests that doesn't seem to quite fill the range but it doesn't seem to blow it out so it seems safe for now.
2019-11-25din: drop .f from integer additions in din()Vito Caputo
2019-11-25din: don't include v3f.h in din.hVito Caputo
This requires a forward declaration of v3f_t and changing din() to take a v3f_t *. The swab module needed updating to supply a pointer type and a v3f_t definition. This is being done so din.h users can have their own v3f implementations. I might consolidate all the duplicated vector code scattered throughout the libs and modules, but for now I'm carrying on with the original intention of having modules be largely self-contained. Though the introduction of libs like ray and din has certainly violated that a bit already.
2019-11-18libs/din: add a perlin noise implementationVito Caputo
This is a 3D noise field addressed as a unit cube. The caller supplies the resolution of the noise field in three dimensions. I've just pulled in my v3f.h here, but it probably makes sense to later on move vector headers into libs/ and share them. Later. It's called din as in noise, because it's shorter than perlin and noise.
2019-11-16libs/txt: add minimal ascii text rendererVito Caputo
This is as basic as it gets, the only fanciness is it recognizes newlines and supports horizontal and vertical justification. As this is intended to be run from potentially threaded fragmenter renderers, it receives a fragment and *frame* coordinates for the text to be rendered. If the text doesn't land in the given fragment, nothing gets drawn. Currently this is not optimized at all. There's a stubbed out rect overlap test function which could be used to avoid entering the text rendering loop for fragments with zero overlap, that's an obvious low-hanging fruit optimization. After that, skipping characters that don't overlap would be another obvious thing. As-is the text render loop is always entered and the bounds-checked put pixel helper is used. So every fragment will incur the cost of rendering the full string, even when it's not visible. For the rtv captions this isn't a particularly huge deal, but stuff to improve upon in the future.
2019-11-16libs/ascii: add a basic mono bitmap ascii charsetVito Caputo
The rtv module needs to show some captions, so I'm adding a minimal bitmap ascii text renderer.
2019-11-13ray: add rudimentary gamma correctionVito Caputo
color banding has been quite visible, and somewhat expected with a direct conversion from the linear float color space to the 8-bit integral rgb color components. A simple lookup table is used here to non-linearly map the values, table generation is taken from Greg Ward's REAL PIXELS gem in Graphics Gems II.
2019-05-19libs/ray: fix off by one error in prepared objectsVito Caputo
Missed the sentinel, oops
2019-05-18libs/ray: trivial indentation fixupVito Caputo
2018-12-31libs/grid: fix grid_ops_t.taken player typeVito Caputo
Just making things consistent, also dropping unnecessary player assert from submit module. Future libs/grid may explore using the "unassigned" zero player in taken calls for unassigning cells like in simultaneously taken collision scenarios.
2018-12-30libs/grid: add grid cellular automata componentVito Caputo
Prep for adding a new module displaying a cellular automata based on the grid component from a multiplayer game I'm working on.
2018-04-03libs: commit missing Makefile.am filesVito Caputo
Oops! This should have made it into b5bc96, been sitting in my tree.
2018-03-19ray: libize raytracer core, introduces src/libsVito Caputo
This is the first step of breaking out all the core rendering stuffs into reusable libraries and making modules purely compositional, consumers of various included rendering/effects libraries. Expect multiple modules leveraging libray for a variety of scenes and such. Also expect compositions mixing the various libraries for more interesting visuals.
© All Rights Reserved