• Advertisement
Sign in to follow this  

int-float with arrays

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having trouble converting from int to float using arrays. The following works if I use an array of integers, but when using floats it doesn't work (as shown below). I tried casting it to a float but that didn't work as well? Anybody have an idea of what I am doing wrong? Is there a better way to do this?
float[] RGBA(100);
void RGBShader() {
	for (int i=0; i<100; i++) {
		RGBA[i] = i;
	}
}


The goal here is to pass a block of floating point pixel values and have the script manipulate it. I could use a two dimensional function, but the computation has to be fast. I will probably run some tests comaring the array method, function call method, and a standard C code method to see what the overhead performance is like. Just want to get the array method working. If not possible, no worries, i'll stick with the function calls.

Share this post


Link to post
Share on other sites
Advertisement
Ahhh, that explains it. I usually cast as (float)i, but doing it as float(i) worked. Thanks alot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement