I rendered some unwrapped UV uncooked mesh information utilizing a particular shader and Graphics.DrawMesh() on a render texture, however upon inspection the info is inaccurate (regular and world place).
- On the left is a muted vanilla shader modified to generate the conventional world from sport objects, the normals align with the unit base proven within the prime proper nook.
- On the appropriate is the goal advanced shader utilizing uncooked mesh with a customized matrix, uv unwrapping rendered into texture and skim as texture into the sport object by one other shader (work is out of scope, context is roughly a lightmap like a G-buffer)
It appears to make sense since I am bypassing the development of the Unity sport object, due to this fact I’ve a defective array. Subsequently, I attempted passing my very own array. However the world’s regular information would not appear to match, and doing the inverse transpose of my very own matrix would not appear to work (the usual to remodel the conventional)…
To analyze additional, as I believe the uncooked mesh is the imported information earlier than Unity applies its import settings, I created a small program that I hooked up to the sport object to match its rendering with numerous DrawMesh() instructions… however DrawMesh would not work as anticipated…
utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
public class MeshVsObjectNormalTest : MonoBehaviour
{
//public GameObject normalObject;
Mesh() rawMesh;
Matrix4x4 objectMatrix;
Digital camera cam;
Materials mat;
// Begin is known as earlier than the primary body replace
void Begin()
{
rawMesh = new Mesh(1);
rawMesh(0) = this.GetComponent<MeshFilter>().mesh;
objectMatrix = Matrix4x4.identification;
cam = Digital camera.fundamental;
mat = this.GetComponent<Renderer>().materials;
}
// Replace is known as as soon as per body
//void Replace()
void LateUpdate()
//void OnPostRender()
{
//Graphics.DrawMesh(rawMesh(0), objectMatrix, mat,0, cam);
//Graphics.DrawMesh(rawMesh(0), Vector3.zero, Quaternion.identification, mat,0, cam);
Graphics.DrawMesh(rawMesh(0), Vector3.zero, Quaternion.identification, mat,0);
//mat.SetPass(0);
//Graphics.DrawMeshNow(rawMesh(0), objectMatrix);
Debug.Log(cam);
}
}
Nothing exhibits up, however that is how each instance I can discover after I search does it, and I am already utilizing that command efficiently to render to texture…
Is there one thing I am lacking?

