3 questions:

What is the size of the dimension of the sTDSineLookup texture? I can’t seem to get it to output the same value as a sine function with any dimension size I’ve tried.

Is sampling the sTDSineLookup and converting the value to a cosine still faster than using the cos function?

Finally will the sTDSineLookup be as accurate as the sin function? I imagine this would just depend on its dimension.

thanks

Keith

So I think I figured out why I’m not getting the proper value but I can’t seem to get a full sine wave. The texture seems to be only half of the sine wave. Then setting the extend UV mode to mirror has no effect on the built uniform. Here is what I have done to figure out what is happening.

The variable s1 is using the texture coordinate to draw a full sine wave across the texture with the values 0 to 1 using the GLSL sin function. When sampling the sTDSineLookup using just the texture coord it seems that it is only half of the sine wave (variable s2). Then if the texture coordinate is scaled and offset it doesn’t mirror so only 25% of texture is correct (variable s3).

So now the texture coordinate would have to be wrapped and mirrored to work correctly in which I can’t think of way without using an if statement which I think would defeat the whole purpose of using the lookup to begin with.

I am I missing something? Or does the OpenGL Repeat Mirror flag need to be set in the TOP?

[code]layout (location = 0) out vec4 fragcolor;

void main()

{

float s1 = sin(radians(vUV.s*360))*.5 +.5;

float s2 = texture(sTDSineLookup,vUV.s);

float s3 = texture(sTDSineLookup,vUV.s*2+.5);

```
//fragcolor = vec4(s1);
//fragcolor = vec4(s2);
fragcolor = vec4(s3);
```

}[/code]

Yes, it’s a half-sine ramp. I’ve updated the help to describe it better. It’s not meant to be used as a full replacement for sin() actually, but rather a way to turn a linear 0-1 into a sin-shaped 0-1 ramp, with automatic clamping for values outside 0-1 range

Ah okay that makes sense. To bad I was hoping to speed up some iterated rotations (using matrices). Its starts really adding up 20+ sin/cos functions iterated 15+ times. Maybe I if input a wave chop into a uniform array and sample that for a lookup it will be faster than calling the sin function? I’ll test it out.

thanks

Keith