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
Vec4 as shader uniforms
Moderators: winston, another_commander
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Vec4 as shader uniforms
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Vec4 as shader uniforms
Nah. Never touches the things.Griff wrote:If possible, could we have vec4's as shader bindings, i think Oolite uses them internally but clamps
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!Griff wrote:something to do with the 4th component being the alpha value in a png
Seriously, though, implemented in r5009.
E-mail: [email protected]
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: Vec4 as shader uniforms
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
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: Vec4 as shader uniforms
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
in my fragment shader I have this
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.
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"; };
Code: Select all
uniform vec4 Decal1_Scale_Position_Rotation;
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries
Re: Vec4 as shader uniforms
Try
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.
Code: Select all
Decal1_Scale_Position_Rotation = { type = quaternion; value = "0.72 0.765 12.0 0.5"; normalized = false; asMatrix = false; };
- Griff
- Oolite 2 Art Director
- Posts: 2483
- Joined: Fri Jul 14, 2006 12:29 pm
- Location: Probably hugging his Air Fryer
Re: Vec4 as shader uniforms
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
brings the decal back onto the ship but again the 4th component is overwritten to 1.0.
Code: Select all
Decal1_Scale_Position_Rotation = { type = vector; value = "0.72 0.765 12.0 0.5"; normalized = false; asMatrix = false; };
Wiki homepage for my OXP: http://wiki.alioth.net/index.php/Griff_Industries