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

User avatar
Rado1
Posts: 770
Joined: Wed May 05, 2010 12:16 pm

Passing vec* variables to shaders + "vector" props

Postby Rado1 » Tue May 28, 2013 3:39 pm

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: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Mon Oct 14, 2013 11:34 am

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: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Tue Oct 15, 2013 6:10 pm

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: 1912
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Postby VilleK » Wed Oct 16, 2013 9:17 am

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: 770
Joined: Wed May 05, 2010 12:16 pm

Postby Rado1 » Wed Oct 16, 2013 10:16 pm

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.


Return to “Feature requests”

Who is online

Users browsing this forum: No registered users and 1 guest