I’m trying to pass a value between 1-1000 to an GLSL shader program which only 
supports floats with a precision of 1 decimal place so the plan is to pack the 
value into a vec4 (RGBA components between 0-1) which I could decode in the 
shader program.

For example if I want to encode the value 50 I do: 50/1000 = 0.050 and get a 
value with 3 decimal places which could fit into an RGB value,

but how can I extract the decimal places? I think it has something to do bit 
shifting but I wasn’t able to figure it out. The final result should be:

r = 0
g = 5
b = 0


Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to