Jump to content

packing/unpacking in shader


Rick
 Share

Recommended Posts

Because the data we can send to the shaders is limited, I'm thinking about packing/unpacking (encoding/decoding) data into the color Vec4 to pass in more data. Does anyone know if this would cause any major performance issues by doing this since the shader code would have to unpack to get the actual values?

Link to comment
Share on other sites

For the subtexture shader I made, I want to also send offset and scale of the subtexture itself. Currently I'm using the alpha now for the scale, but I only apply it to the x of the vec2 ex_color. I tested on wall segments for the narrow sides and it works well to scale up the texture so it matches the longer sides, but the top part of the walls need the y value adjusted. Doing it uniformly doesn't work visually.

 

@shadmar This has to be model instance specific, and if I remember correctly the only model instance specific data currently is position/rotation/scale/color.

 

@Josh basically what I'm trying to do is make what the face selection of the CSG can do with the texture scale/offset, but for models that use my subtexture shader to give me more flexibility.

 

Playing around with my next game ideas, and it means making buildings like you do in The Sims where you have wall segments and you paint different images on any side of them. I can pretty much do that now with the color alpha being the scalar value for the x portion and leave the top part of the walls a solid black, but would be nice to have more flexibility with the textures.

 

Ideally we'd have some custom vec3 variables that are for us to use for whatever, but not sure if GLSL allows this or if it slows things down to much.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...