Jump to content

How to get entity's scale via the entity's matrix in Shader.


reepblue
 Share

Recommended Posts

Is there a way to get the entity's scale value based on the matrix value? 

I'm currently passing scale modifiers via code but I'd like to see the results in the editor if possible. How would I do this? Examples would be the most helpful!

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Yes. The magnitude of the first three components in the first three matrix rows are the entity global scale:

vec3 scale;
scale.x = len(mat[0].xyz);
scale.= len(mat[1].xyz);
scale.= len(mat[2].xyz);

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thanks for the start. The compiler complains about the len() function, so I replaced it with length

I'm getting the desired results with decals, but not with planes despite it using the same code.

image.thumb.png.4fa20feba2bd46493cf838b1138634d3.png

 

If I could remove the normal blending with the decals, I wouldn't be making an overlay class.

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I rolled back to my previous solution for many reasons.

  1. I would have to check the entity's normal and swap out what scale values to use.
  2. I have to create a spawner class anyway which does a calculation to determine the base size from the texture. I would not be able to see the results in the editor anyway.
  3. My overlay classes are never intended to resize during runtime. 

The information was helpful and I hope it's useful to others!

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

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...