title: holes with shader and setPixel Unity3D
body: <p>I am using clipping shader for cutting holes in my mesh. My shader is (it's part of shader):</p>
  
  <pre><code>        void surf (Input IN, inout SurfaceOutputStandard o) {  
             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
              fixed3 normal = UnpackScaleNormal(tex2D(_Normal, IN.uv_MainTex), 1);
              clip(tex2D(_SliceGuide, IN.uv_SliceGuide).rgb-_SliceAmount);
              o.Albedo = c.rgb;//2//tex2D(_MainTex,IN.uv_MainTex).rgb;//c.rgb;
  
              o.Normal = normal;
          }
          ENDCG
  </code></pre>
  
  <p>My SliceAmount is a range. It works because it cut very beautiful hole in my texture. But I have problems with coordinates where to cut hole.</p>
  
  <p>I am using SetPixel to make texture with black rectangle. So I use:</p>
  
  <pre><code>for (int y = (int)yStartCorner; y &lt;= (int)yEndCorner; y++)
      {
          for (int x = (int)xStartCorner; x &lt;= (int)xEndCorner; x++)
          {
              Debug.Log("X: " + x + ", y: " + y);
              texture.SetPixel(x, y, Color.black);
          }
      }
      texture.Apply();
  </code></pre>
  
  <p>Start and End corners I take from Raycast textureCoord. But when I try to convert float to int, my hole never is perfectly fitted, how you can see on image. Pink dots are points when raycast hit:
  <a href="https://i.stack.imgur.com/5KZ6d.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5KZ6d.jpg" alt="enter image description here"></a></p>
  
  <p>It's 3D, I used iso view to show, that my hole doesn't fit my raycast coords.</p>
  
  <p>What am I doing wrong? Maybe I don't know something important about textures? Any help is appreciated!</p>