Changing Texture Array index using World Position values
Posted: 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
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...
Using Add Operator on a 3x3 grid
Using Multiply Operator, notice the curve
Using Divide Operator
I am absolutely confused on how the Operators created these weird shapes and cutouts of my mask @_@
Here are my Nodes:
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!
I'm pretty new in using ASE (and shader in general), and have been amazed on the awesome stuff ASE can do
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...
Using Add Operator on a 3x3 grid
Using Multiply Operator, notice the curve
Using Divide Operator
I am absolutely confused on how the Operators created these weird shapes and cutouts of my mask @_@
Here are my Nodes:
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!