- Home /
Getting color from RayCastHit: Able to retrieve texture coordinates but Texture2D still shows as "degenerate" (0x0)
Hi,
I'm trying to retrieve the color of a pixel by using Unity's RaycastHit to find a texture's UV coordinates, feed them into a Texture2D object, and create the Color using Texture2D.GetPixelBilinear. The UV coordinates retrieved are usually something like (.253, .25), with the Texture2D created with them rounding to (.3, .3). But trying to use .GetPixelBilinear with these coordinates results in a degenerated (0.0, 0.0) texture. The Color is set to solid white (RGBA 1, 1, 1, 1) where I was expecting green. Not sure why this runs, retrieves coordinates and color but shows texture as degenerate.
Here's my code:`
%|-1389572212_1|% pos.y += 1; %|-1447323163_3|% Ray theRay = new Ray(pos, Vector3.down);
%|-1205298955_5|% { %|-647167951_7|% int ux = (int)uvCoord.x; %|-1591675652_9|% %|-1412893999_10|% %|-995715125_11|% %|1321062807_12|% `
Thank you in advance for the help!