Hi, Im trying to pass some data to a shader using a texture created from code. I need one float value per vertex so TextureFormat.RFloat seems to make sense:
var tex = new Texture2D(32, 32, TextureFormat.RFloat, false, true); // (no mips, linear)
To be on the safe side I make sure all values are set to 0:
for (int i = 0; i < t.Length; i++)
t *= 0;*
*tex.LoadRawTextureData(t);*
*tex.Apply(false);```*
*I then assign the texture to the material:*
*```material.SetTexture("_Data", tex);```*
*In the vertex shader I sample the texture:*
*```v.vertex.y = tex2Dlod(_Data, float4(v.texcoord.xy, 0, 0));```*
*I expect the value to be 0, but it ends up being 0.5. I've tried many other texture formats, but I can't manage to get even a 0 out. Setting the y to any number yields the expected result:*
*```v.vertex.y = 5```*
*Am I doing something wrong?*
*Cheers, Bas*