[ad_1]
I rendered some UV unwrapped uncooked mesh information utilizing a particular shader, and Graphics.DrawMesh() to a render texture, however upon inspection the information is incorrect (world regular and place).
It appears to make sense since I’m bypassing the gameobject assemble of Unity, subsequently I’ve defective matrix. Therefore, I attempted passing my very own matrix. But the worldnormal information do not appear to match, and doing the inverse of the transpose of my very own matrix would not appear to do the trick (the usual stuff to remodel regular) …
To examine additional, as I believe that uncooked mesh is the imported information earlier than Unity applies its import settings, I created a bit of program that I connected to the sport object to match its render to varied DrawMesh() instructions … however DrawMesh would not work as supposed …
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class MeshVsObjectNormalTest : MonoBehaviour
{
//public GameObject normalObject;
Mesh[] uncookedMesh;
Matrix4x4 objectMatrix;
Camera cam;
Material mat;
// Start known as earlier than the primary body replace
void Start()
{
uncookedMesh = new Mesh[1];
uncookedMesh[0] = this.GetComponent<MeshFilter>().mesh;
objectMatrix = Matrix4x4.id;
cam = Camera.predominant;
mat = this.GetComponent<Renderer>().materials;
}
// Update known as as soon as per body
//void Update()
void LateUpdate()
//void OnPostRender()
{
//Graphics.DrawMesh(uncookedMesh[0], objectMatrix, mat,0, cam);
//Graphics.DrawMesh(uncookedMesh[0], Vector3.zero, Quaternion.id, mat,0, cam);
Graphics.DrawMesh(uncookedMesh[0], Vector3.zero, Quaternion.id, mat,0);
//mat.SetPass(0);
//Graphics.DrawMeshNow(uncookedMesh[0], objectMatrix);
Debug.Log(cam);
}
}
Nothing exhibits up, however it’s how each instance I can discover once I search does it, and I’m already utilizing that command efficiently to render to texture …
Is there one thing I’m lacking?
[ad_2]