Search Unity

Showcase How to make Parametric Shapes in Unity3D that can be baked in relistic quality

Discussion in 'High Definition Render Pipeline' started by USMANHEART, Jun 2, 2021.

  1. USMANHEART

    USMANHEART

    Joined:
    Jul 23, 2016
    Posts:
    56
    I am using Unity C# Script to create shapes.
    My shapes can be like box (6 faces without rounded corner), curve and polygon.
    I create shapes with basic method like creating new Mesh and Meshfilter. Then assigning UVs, Normals, Vertices etc to the mesh. Usually one cube shape contains 24 vertices. But these shapes are not giving me realistic results when I Bake my scene.
    Right now my output after baking scene is like


    My box details are



    Here is my code sample

    Code (CSharp):
    1.  
    2.     private void Awake()
    3.     {
    4.         GameObject Shape = new GameObject("Cupboard");
    5.         MeshRenderer mr = Shape.AddComponent<MeshRenderer>();
    6.         mr.material = Material;
    7.         MeshFilter meshFilter = Shape.AddComponent<MeshFilter>();
    8.         meshFilter.mesh.Clear();
    9.  
    10.         Mesh mesh = new Mesh();
    11.         mesh.vertices = Vertices();
    12.         //It return vertices of each face (total 24)
    13.         // 1 face= 4 corners
    14.         // 1 corner = 3 points(x,y,z)
    15.         // 1 box have total 8 corners. So 8x3=24
    16.         mesh.triangles = Triangles();
    17.         // this function will return traingles (total 12 traingles)
    18.         // 1 face = 2 triangles
    19.         // 1 box have total 6 faces. So 6x2=12
    20.         mesh.uv = UV(); // returns UVs for each face
    21.  
    22.         meshFilter.mesh = mesh;
    23.         mesh.RecalculateNormals();
    24.     }
    25.  

    I want this kind of output, video link:

    If I use some pre-made FBX models, that models are giving better result than the models I created myself from Unity3D Scripting. Can someone guide me how to make it possible?
    Please ignore I can't bake at run-time or it might take long time.
    My target is to display this youtube video demo kind of output. How do I make shapes by using scripting that can give me this kind of output?

    If this method is not suitable, then where can I draw a box that can be used to get realistic output after baking in Unity3d? I just want unity3d to bake.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,795
    You would need to use some 3d modelling software, like Blender.
     
  3. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    Also engine's name is Unity, not Unity3D
     
    James_Arndt likes this.
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,445
    those premade cabinets have probably thousands of vertices, carefully modeled edges, proper UV maps,
    maybe special hand crafted texture maps (could have also baked normals, AO or other textures assigned..)

    i'd check how those models are made, then try to generate similar models from script (if that's the requirement),
    possibly some plugins can do parametric models from Houdini, not sure if theres runtime support..
     
    USMANHEART likes this.
  5. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,795
    Glad to see the community taking Unity's branding seriously, now quickly go follow them on twitter, their handle is @ unity3d
     
    James_Arndt likes this.
  6. USMANHEART

    USMANHEART

    Joined:
    Jul 23, 2016
    Posts:
    56
    really?

    Facebook
    upload_2021-6-2_23-28-8.png

    Twitter
    upload_2021-6-2_23-28-40.png


    It is also old time I see this name they use before
     
  7. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    883
    This old name from the times when UT could not afford to buy a domain unity.com.
    Now they have this domain name and if you will open it you will not find Unity3D in a single place.
    Also the name of the company is Unity Technologies not Unity3D Technologies.
    Also there is no 3D in a single Unity logo.
     
    Last edited: Jun 2, 2021
    USMANHEART likes this.
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,795
    Can we drop this?

    Because otherwise I will start mentioning how actually Unity branding guidelines say we need to refer to Unity as "Unity Software", so your correction is also technically wrong.

    Or I could point out that a ton of e-mail still use the Unity3d domain, like for example the one about trademarks.
    upload_2021-6-2_19-28-11.png


    But instead, can we just agree that sometimes people might type Unity3d instead of Unity and that's okay and we shouldn't derail a whole thread for a pretty minor mistake.
     
    chap-unity likes this.
  9. USMANHEART

    USMANHEART

    Joined:
    Jul 23, 2016
    Posts:
    56
    good to know
     
    iamarugin likes this.
  10. USMANHEART

    USMANHEART

    Joined:
    Jul 23, 2016
    Posts:
    56
    But still my main quastion, is there a way to create Box shapes with more vertices in Unity Scripting? Kindly guide me. Any kind of guidance will be Appreciated
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,795
    Why do you need to create them with scripting?
     
  12. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,445
  13. USMANHEART

    USMANHEART

    Joined:
    Jul 23, 2016
    Posts:
    56
    because shapes will be drawn according to my client want. they will first draw shapes in an app, that app is simple OpenGL. Then I have shape information like size, position and angle. I will redraw in Unity with script.
    Now that shape be such a good quality if I bake it in Unity3D editor, it must look realistic. Shapes are random size, position and angles, depends on what user want