Hello!
So i have been making a little experiment that have me butt head with unity's working, abd I have no idea what's going on, so to investigate I started another experiment that isn't working as intended, that is not at all, and I'm at loss to know why.
- I rendered UV unwrap raw mesh data using a special shader, and Graphics.DrawMesh() to a render texture, but upon inspection the data is wrong (world normal and position).
- It seems to make sense since I'm bypassing the gameobject construct of unity, therefore I have faulty matrix. Therefore I tried passing my own matrix. But the worldnormal data don't seem to match, and doing the inverse of the transpose of my own matrix don't seems to do the trick (the standard stuff to transform normal) ...
- To investigate further, as I suspect that rawmesh is the imported data before unity apply import settings, I create a little program that I attached to the gameobject to compare its render to various DrawMesh() command ... BUT drawmesh don't work as intended ...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MeshVsObjectNormalTest : MonoBehaviour
{
//public GameObject normalObject;
Mesh[] rawMesh;
Matrix4x4 objectMatrix;
Camera cam;
Material mat;
// Start is called before the first frame update
void Start()
{
rawMesh = new Mesh[1];
rawMesh[0] = this.GetComponent<MeshFilter>().mesh;
objectMatrix = Matrix4x4.identity;
cam = Camera.main;
mat = this.GetComponent<Renderer>().material;
}
// Update is called once per frame
//void Update()
void LateUpdate()
//void OnPostRender()
{
//Graphics.DrawMesh(rawMesh[0], objectMatrix, mat,0, cam);
//Graphics.DrawMesh(rawMesh[0], Vector3.zero, Quaternion.identity, mat,0, cam);
Graphics.DrawMesh(rawMesh[0], Vector3.zero, Quaternion.identity, mat,0);
//mat.SetPass(0);
//Graphics.DrawMeshNow(rawMesh[0], objectMatrix);
Debug.Log(cam);
}
}
Nothing shows up, but it's how every example code do it when I google, and I'm already using that command successfully for render to texture ...
Is there something I'm missing?
