- Home /
Need help with using world position in shader
So in my game I have a mesh thats supposed to represent a grid of tiles. Each tile is _TileLength vertices by _TileLength vertices. The _Map texture is how I pass the colors of each tile. The goal of the shader is to simply apply the tile's color to all of the vertices it includes on the mesh. The problem is that what I have seems to using the color of the first pixel, not the pixel based off of each vertexes world position. I am very new to shaders so I don't even know where to start. Am I even using the right kind of shader for this, any help would be very much appreciated!
Answer by BastianUrbach · Nov 12, 2019 at 08:48 AM
tex2D takes texture coordinates in the range 0-1, not pixel coordinates. You need to divide float2(xCoord, yCoord) by the texture resolution.