I was wondering if there is a faster alternative or approximation to these functions in HLSL. I realize that they can be replaced with texture look-ups, but I've heard that these math operations have become faster than textue samples in recent years. I also understand that I can store a lighting model in a texture, but then I would still have to do at least 8 samples.
So, plain and simple, any other functions or tricks I could use?
thanks in advance :)
fast alternative to sin/cos/tan
Started by starstutter, Aug 13 2009 12:02 AM
9 replies to this topic
#1
Posted 13 August 2009 - 12:02 AM
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#2
Posted 13 August 2009 - 12:17 AM
How accurate? For very, very fast, precompute some lookup tables. Of course, the more accurate, the bigger the table. Else, you want to look into Chebyshev. The book Numerical Recipes covers this pretty well.
#3
Posted 13 August 2009 - 12:23 AM
Are you talking about an array of half or float values? I would have to interpolate between then right?
Btw, I guess on a scale of 1 to 10 in terms of speed (with 1 being the regular functions in HLSL), I guess maybe 5-7
Btw, I guess on a scale of 1 to 10 in terms of speed (with 1 being the regular functions in HLSL), I guess maybe 5-7
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#4
Posted 13 August 2009 - 12:26 AM
Yeah, an array. And, yes, assuming you need to get values that lie between your pre-computed ones, then interpolation (simplest being linear, else you can get slightly fancy and get a little more accuracy) would be the way to go.
#5
Posted 13 August 2009 - 12:29 AM
ok, I'll give it a shot and get back to you, thanks
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#6
Posted 13 August 2009 - 12:31 AM
Of course, wikipedia is your friend: http://en.wikipedia....ki/Lookup_table
#8
Posted 13 August 2009 - 12:36 AM
Duh, don't forget our local heavy contributor: http://www.devmaster...read.php?t=5784
#9
Posted 13 August 2009 - 12:43 AM
The result is actually slower, but I might know why:
I generated a lookup table like you said:
const half aCosT[64] =
{1.5708,
1.55517,
1.53954,
1.5239,
1.50826,
1.49259,........... and so on...
then referenced it like this:
half theta_r = aCosT[(VdotN * 0.5) * 64]; <- VdotN stays between 0.0f - 1.0f
I rember reading in an ATI paper that referencing (indexing) with a float value is costly. Any way to perform this lookup without using a float (or half)?
I generated a lookup table like you said:
const half aCosT[64] =
{1.5708,
1.55517,
1.53954,
1.5239,
1.50826,
1.49259,........... and so on...
then referenced it like this:
half theta_r = aCosT[(VdotN * 0.5) * 64]; <- VdotN stays between 0.0f - 1.0f
I rember reading in an ATI paper that referencing (indexing) with a float value is costly. Any way to perform this lookup without using a float (or half)?
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
#10
Posted 13 August 2009 - 12:46 AM
oh, well then I'll try nicks idea :)
(\__/)
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
(='.'=) This is Bunny. Copy and paste bunny into
(")_(") your signature to help him gain world domination.
bunny also wants to fight spam: Click Here Bots!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












