Page 1 of 1
Vec4 as shader uniforms
Posted: Fri Jun 15, 2012 8:35 pm
by Griff
If possible, could we have vec4's as shader bindings, i think Oolite uses them internally but clamps the 4th component to 1.0* and only allows you to specify 3 components of the vec 4 in shipdata.plist
* something to do with the 4th component being the alpha value in a png
Re: Vec4 as shader uniforms
Posted: Fri Jun 15, 2012 9:38 pm
by JensAyton
Griff wrote:If possible, could we have vec4's as shader bindings, i think Oolite uses them internally but clamps
Nah. Never touches the things.
Griff wrote:something to do with the 4th component being the alpha value in a png
No, it’s because 1.0 is the only sane default alpha value in any context, and also because 1.0 is the standard w component for a
homogeneous 4-vector converted from a Cartesian 3-vector (which Oolite uses internally). The more you know!
Seriously, though, implemented in r5009.
Re: Vec4 as shader uniforms
Posted: Fri Jun 15, 2012 10:47 pm
by Griff
oo smashing! this'll cut down on the number of floats i'm using - always feel a bit guilty, feel like i'm hogging them all
Re: Vec4 as shader uniforms
Posted: Mon Aug 19, 2013 9:51 am
by Griff
I've only just got around to trying this out, I can't seem to get it working, i'm using trunk v1.77.1.5678
In my shipdata.plist shaders section i'm using a vec4 to send position.x, position.y, scale and rotation settings for a ship decal to a shader, i've written it like this
Code: Select all
Decal1_Scale_Position_Rotation = { type = vector; value = "0.72 0.765 12.0 0.5"; };
in my fragment shader I have this
Code: Select all
uniform vec4 Decal1_Scale_Position_Rotation;
but in game, oolite seems to ignore the last component in my vec4 and seems to be changing it to a 1.0, I'm probably not using the correct 'type =vector' setting in my shipdata.plist but type=vec4 doesn't seem to work at all.
Re: Vec4 as shader uniforms
Posted: Mon Aug 19, 2013 12:19 pm
by Svengali
Try
Code: Select all
Decal1_Scale_Position_Rotation = { type = quaternion; value = "0.72 0.765 12.0 0.5"; normalized = false; asMatrix = false; };
PS: It's in w,x,y,z if I recall it right, so you may need to place the 0.5 as first one.
Re: Vec4 as shader uniforms
Posted: Mon Aug 19, 2013 1:50 pm
by Griff
Thanks for the help Svengali, it doesn't seem to work though unfortunately, with "type = quaternion" my shader isn't able to read the values at all as it doesn't show a decal. trying it as
Code: Select all
Decal1_Scale_Position_Rotation = { type = vector; value = "0.72 0.765 12.0 0.5"; normalized = false; asMatrix = false; };
brings the decal back onto the ship but again the 4th component is overwritten to 1.0.