2010년 7월 13일 화요일

[RSL] Mathematical Functions 중에서.... v.1

float floor ( float x )
float ceil ( float x )
float round ( float x )

floor returns the largest integer (expressed as a float) not greater than x. ceil returns the smallest integer (expressed as a float) not smaller than x. round returns the integer closest to x.

integer값을 float 타입으로 반환받기 위한 방법이다.
floor : 내림, ceil : 올림, round : 반올림 으로 생각하면 간단할것 같다.

object index id를 aov로 출력할때 이 방법을 사용하였다.
ex.

output varying color objid[100] = {};

float index = 0;
attribute("identifier:id", index);
float color_array = floor(index / 3);
setcomp(objid[color_array], index - 3 * color_array, 1);

댓글 없음: