Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1403811 Posts in 68294 Topics- by 61958 Members - Latest Member: Kvrochi

December 09, 2022, 08:39:09 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Drawmesh in unity that should but didn't work...
Pages: [1]
Print
Author Topic: Drawmesh in unity that should but didn't work...  (Read 569 times)
gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« on: October 10, 2022, 05:33:06 AM »

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 ...

Code:
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?  WTF
« Last Edit: October 10, 2022, 05:40:32 AM by gimymblert » Logged

gimymblert
Level 10
*****


The archivest master, leader of all documents


View Profile
« Reply #1 on: October 10, 2022, 09:33:21 AM »

I only found the answer because I asked here ... The scale is 100 less big, so it wasn't visible at the camera position because too small... tooks me weeks to figure that out ...
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic