_var and global VECTOR definitions

Posted By: HeelX

_var and global VECTOR definitions - 04/07/13 23:29

Hi,

I want to access d3d_spotlightcone in a shader and wondered why I can't read out the falloff. To test it, I wrote

Code:
float3 d3d_spotlightcone_var;

color.rgb = d3d_spotlightcone_var.rgb;
return color;



The screen turns red and I can change the redness, if I change d3d_spotlightcone.x into the range 0...1; if I change d3d_spotlightcone.y or d3d_spotlightcone.z, nothing happens.

This implies, that only the .x component is accessible via _var and .y and .z components of a vector are always = 0. I doublechecked with e.g. d3d_fogcolor1 and the same observations can be made.
Posted By: jcl

Re: _var and global VECTOR definitions - 04/08/13 13:35

I'm pretty sure that _var is only for transferring data from vectors that are defined in your script. It is not for system variables, which are stored in a different way.

Please try it. You can find an example in the manual how to use _var shader variables. This should also work for VECTOR structs. Please post here again if you encounter a problem.
Posted By: HeelX

Re: _var and global VECTOR definitions - 04/08/13 15:27

Originally Posted By: jcl
It is not for system variables, which are stored in a different way.
It works at least for d3d_alpharef.

Originally Posted By: jcl
This should also work for VECTOR structs.
I am not interested into making a global vector, copy the contents of d3d_spotlightcone into it and access it in my shader - because I strongly believe that all official shader variables should be accessible in actual shaders via something like "float3 vecSpotlightcone" or with _var/_flt.

Since because I am working with point and spotlights atm, I only can think of d3d_pointlightfalloff, d3d_spotlightfalloff and d3d_spotlightcone, which aren't supported. But this counts for e.g. detail_size as well. It would be just plain nice if they would be supported as all those other variables.
© 2024 lite-C Forums