Passing vec* variables to shaders + "vector" props

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Passing vec* variables to shaders + "vector" props

Post by Rado1 »

Some (probably related) feature requests:

1. Is there a way to pass uniform variables of type vec* and references to vec* variables to shaders? If not, this feature request is valid; if yes, please explain how. For now, I always use shader variables such as mousePositionX and mousePositionY and in shader code write: vec2 mousePosition = vec2(mousePositionX, mousePositionY); ... this is too cumbersome.

2. It would also be nice to use references to RenderSetColor.Color, Material.Color, Model.Position, etc. (I called them "vector" properties) as uniform shader variables of type vec4 or vec3.

3. In ZGE expressions properties such Material.Color can be assigned to vec4 variables, and vice versa. Also accessing Material.Color[0] can return R value (this was already proposed by Kjell).
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

About 1: Yes you can send vec* variables to shaders.

Assume you have a vec3 variable like this:
<Variable Name="uAttractPos" Type="7"/>

And a ShaderVariable like this:
<ShaderVariable VariableName="AttractPos" VariableRef="uAttractPos"/>

Then you can declare this in your shader:
uniform vec3 AttractPos;
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thanks Ville. Could you please also explain how to pass arrays of vectors as uniforms? Should I use ArrayKind Texture1D? Actually, I haven't tried it yet, I'm just asking because I plan to use it in near future.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Vec* arrays as uniforms are not supported yet, just arrays of mat4 (ArrayKind=Mat4). But it is easy for me to add. Just remind me again when you need it and I'll fix it.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

VilleK wrote:But it is easy for me to add. Just remind me again when you need it and I'll fix it.
Great! I'm going to implement GLES Phong shader for multiple lights and want to pass light positions + diffuse/specular colors + intensities as array(s). I would really appreciate this possibility.
Post Reply