Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GLSL modf - compile problems

683 views
Skip to first unread message

VelociChicken

unread,
Sep 29, 2012, 5:13:59 PM9/29/12
to
Hello, I may be tired and thinking in all the wrong places(!), but I
can't get 'modf' to compile.

It says here it's version 130 compatible:
http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml

Am I getting the syntax correct?

xz are a 2D coordinate, and I want the fraction in uv and the integer in
ij, but it does not compile, anybody have any ideas?

"
vec2 xz;
ivec2 ij;
vec2 uv = modf(xz, ij);
"

Thanks,
Dave.


VelociChicken

unread,
Sep 30, 2012, 2:54:41 PM9/30/12
to
OK, the 'ij' parameter needs to be a vec2 for it to compile.
Unfortunately 'uv' still does not return the fractional part!
If I use 'uv = fract(xz)' then uv returns correctly, what's going on
here anybody?
Thanks,
D.

VelociChicken

unread,
Sep 30, 2012, 4:31:35 PM9/30/12
to
Looking at the description of what it does, 'ij' will have to be set to
zero for it to return as expected. It also appears to be slower than
'floor' and 'fract' which makes it useless for the job anyway.
Oh well.

bob smith

unread,
Oct 1, 2012, 1:41:03 PM10/1/12
to
Why would ij have to be set to zero?

This is what the docs say:

The fractional part of the number is returned from the function

(http://www.opengl.org/sdk/docs/manglsl/xhtml/modf.xml)

VelociChicken

unread,
Oct 1, 2012, 2:24:17 PM10/1/12
to
Nevermind, I was getting confused with other (wrong) parts of the code,
and the formula for mod rather than modf!
Long day, yesterday... :) Doh indeed.




0 new messages