Jump to content

Lookup Tables In Vex


Recommended Posts

I have the following problem: In a VEX shader I have a fairly complex formula and rather then evaluating it each time I'd like to use a lookup table. As far as I know VEX won't allow us to to create an array containing ~500 entries.

There are currently two solutions I came up with though I don't like either one much.

i) Store a few values and use something like a spline interpolation (much slower then a lookup, though still more effecient then evaluating the 'big' formla)

ii) Using 4x4 matrices and building something like a binary tree with 'if - instructions' (fairly fast, but takes time to implement / time to write a small tool to automate it)

I don't like either solution much and wonder if anyone has come up with a smarter solution.

Jens

Link to comment
Share on other sites

I have the following problem: In a VEX shader I have a fairly complex formula and rather then evaluating it each time I'd like to use a lookup table. As far as I know VEX won't allow us to to create an array containing ~500 entries.

There are currently two solutions I came up with though I don't like either one much.

i) Store a few values and use something like a spline interpolation (much slower then a lookup, though still more effecient then evaluating the 'big' formla)

ii) Using 4x4 matrices and building something like a binary tree with 'if - instructions' (fairly fast, but takes time to implement / time to write a small tool to automate it)

I don't like either solution much and wonder if anyone has come up with a smarter solution.

Jens

A texture map?

Link to comment
Share on other sites

A DSO?

... if we assume that the "big formula" is complex enough that it's no longer just a matter of hallucinating a way to store its static data in VEX but also of accessing it efficiently...

Might as well do yer fancy binary/red-black/K-d/whatever storage along with all the number crunching over in C++ land, no?

If it's big/complex enough, then whatever overhead calling the dso might incur should become negligible by comparison (i.e: it should perform the fastest).

Link to comment
Share on other sites

All solutions seem fine, thanks for the input.

I want to keep everything with VEX if possible and I like the idea using a texture to store the values most (basically I'm most familiar with that :P). However I have one problem.. getting the data into the texture. Is there a simple way to create a texture from data assuming I have created the appropriate r,g,b values to represent the data and have it in a text file? Like a two-liner with hscript ?

Writing a small program for that with java wouldn't be that much of an effort.. but :unsure: if I can avoid it, all the better.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...