0

I want to create a shader that will grab a pixel color by the object position

Basically Texture2D.GetPixel(transform.position.x,transform.position.z), but in shader.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
cooluser
  • 3
  • 3

1 Answers1

0

You need a SampleTexture2D node to get pixel color in texture, Use Position Node as a sample uv, the Position will give a 3d vector, you can use Split node and Combine node to extract the axis you want and recombine them, then connect it to the UV socket on SampleTexture2D node.

yingdi fu
  • 1
  • 1