passing float to pixelshader

Posted By: Tempelbauer

passing float to pixelshader - 03/23/11 11:09

hi
i´m new to shaders

i have a simple question: how to pass a float-var (from lite-c) to a pixelshader by keeping it´s precision. the float-value i want to pass has a range about [4,0) with the maximum precision-deep. possible values are (for example):
Code:
float mx;
mx = 4.0;
mx = 0.7;
mx = 0.00002;
mx = ...



my shader works correctly for mx >= 0.0005. in the other cases the value i got in the shader is 0. So i guess the value will be converted to a var before passing --> the precision is lost.

i´m confused:
- the manual says that the skills are type of var (http://www.conitec.net/manual_d/aentity-skill.htm)
- in the shader the skills are available in float4 (http://www.conitec.net/manual_d/Shader-entskill.htm)
- to pass a var i have to use floatv(). this function expects a var and converts it into a ieee-float (for the shader)

so: is it possible at all to pass a float when the skills are typeof var?? how to do this? is there a wordaraound?

currently i use
mat.skill1 = floatv(mx);
to pass it. i know its wrong, but i have no better idea


can someone help the newbie?
thanks
Posted By: Hummel

Re: passing float to pixelshader - 03/23/11 17:36

I think you cant use entity skills if you want to keep float precision. I you use the material skills youz dont need the floatv() since its already a float type. You could also use a global float f.i. float g_foo=0.0121;>//Lite-C
declaration for use in the shader:
float g_foo_ftl;//HLSL
Posted By: Tempelbauer

Re: passing float to pixelshader - 03/24/11 16:11

wonderful laugh
the global float works perfectly

many thanks
Posted By: Joey

Re: passing float to pixelshader - 03/25/11 11:15

you can also use floatd(.001,1000) to pass .000001 to the shader.
© 2024 lite-C Forums