Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Trying to reproduce WorldToViewportPoint function

$
0
0
Hello. I am trying to reproduce native camera.WorldToViewportPoint function, for projecting mesh vertices to viewport. I write colors to texture for visualisation. So, here is what i've tried:
1) Transform vertex position to worldspace using TransformPoint, then use WorldToViewport
Code (CSharp):
  1. Vector3 v = goTransform.TransformPoint(vertices[i]);
  2. Vector3 pos = mCamera.WorldToViewportPoint(v);
  3. texture.SetPixel((int)(pos.x*textureSizeW), (int)(pos.y*textureSizeH), Color.white);
And as...

Trying to reproduce WorldToViewportPoint function

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>