Changing Texture Array index using World Position values

Node-based Shader Editor

Changing Texture Array index using World Position values

Postby zleviel » Mon Jan 07, 2019 1:30 pm

Hello!

I'm pretty new in using ASE (and shader in general), and have been amazed on the awesome stuff ASE can do :D

So for our game project we have a square tiled grid based map, something you might see in isometric simulation games or tactical turn based games.

The idea is to change the alpha map of a tile based on its position in the world.

I've tried converting the X and Z values of the world position into an index for a Global Array which then determines the texture index in the Texture Array.

If I use only the X or Z value (or any Float or Int node) and use it as the index of the Texture Array, it works perfectly fine.

But it doesn't work if I process the X and Z value using Math Operators to get a proper index for the Texture Array, it even returns some weird results...

Image
Using Add Operator on a 3x3 grid

Image
Using Multiply Operator, notice the curve

Image
Using Divide Operator

I am absolutely confused on how the Operators created these weird shapes and cutouts of my mask @_@

Here are my Nodes:

Image

Note: The divide by 6 on the left is to convert the world position into a "grid position", so you get (0,0), (0,1), (1,2) instead of (0,0), (0,6), (6,12)

Also, using Global Array output (With Float/Int Node index) on a Texture Array doesn't seem to work (It is also possible that I don't use the Global Array node properly >.<)

Any help is appreciated! Thank you!
zleviel
 
Posts: 2
Joined: Mon Jan 07, 2019 12:51 pm

Re: Changing Texture Array index using World Position values

Postby Amplify_Borba » Wed Jan 09, 2019 2:48 pm

Hey there, thank you for getting in touch and for your support!

Could you share some additional details regarding your tile setup and how exactly this effect is supposed to behave?
A screenshot or video of any similar effects will also help, as the more information we have, the better insight we can provide!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Changing Texture Array index using World Position values

Postby zleviel » Thu Jan 10, 2019 9:36 am

Hello!

Thank you for the reply, we've already solved this issue; apparently we needed to round the result of the division when calculating the index using the Round/Floor/Ceil Node XD

Here's the intended output (with textures):

Image

But after further progress... we found out that this might not be the best way to achieve what we want lol...

Thank you! :D
zleviel
 
Posts: 2
Joined: Mon Jan 07, 2019 12:51 pm

Re: Changing Texture Array index using World Position values

Postby Amplify_Borba » Thu Jan 10, 2019 11:41 am

Oh, thank you for letting us know that you've solved it!

Unfortunately I'm not sure on what to suggest regarding this particular type of shader, I'd probably resort to scripting in order to establish rules / behaviors for the tiles and also to control certain material parameters.

Please let us know if you have any further questions, we'll be happy to assist.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 1 guest

cron