Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

disappearing/clipping of quads

Discussion in 'General Graphics' started by syrasia_unity, Jan 30, 2021.

  1. syrasia_unity

    syrasia_unity

    Joined:
    Jan 26, 2018
    Posts:
    3
    Hello there,
    I run into a problem with my camera (maybe?) clipping out objects at the borders. But changing the parameters of the camera does not bring a solution for my problem.
    What could be relevant:
    I instantiate a prefab of a quad and modify it to be my terrain, but I don't change the size (just rotated and elevated the corners).
    Here a picture: (the quads extend to every direction, so they should render, but are missing)


    The quads are normal quad of unity applied with material.
    The code of the quads (the modification):

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class QuadTile : MonoBehaviour
    7. {
    8.    
    9.  
    10.     // Start is called before the first frame update
    11.     void Start()
    12.     {
    13.        
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update()
    18.     {
    19.        
    20.     }
    21.  
    22.     public void ParseCorners(float[] corners)
    23.     {
    24.         if (corners.Length == 4)
    25.         {
    26.             Mesh mesh = GetComponent<MeshFilter>().mesh;
    27.             Vector3[] vertices = mesh.vertices;
    28.             for (int i = 0; i < 4; i++)
    29.             {
    30.                 vertices[i] = new Vector3(vertices[i].x, corners[i], vertices[i].y);
    31.             }
    32.             mesh.vertices = vertices;
    33.         }
    34.         else
    35.         {
    36.             throw new ArgumentException("Exatly 4 corners are needed", nameof(corners));
    37.         }
    38.     }
    39. }
    40.  
    I tried to increase clipping planes, but only reducing made a difference (and obviously not a helpful one).
    Could the render cube of the quads be a issue, even as I didn't increased their size, only orientation/form.

    I am just generally confused what is causing the issue.
    Using Unity 2020.2.2f1.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,925
    Does it look like correct in Scene view?
    Do you have an image of what you are expecting it to look like?
     
  3. syrasia_unity

    syrasia_unity

    Joined:
    Jan 26, 2018
    Posts:
    3
    Same in effect Scene view.
    I expect it to extend to the borders of the screen. Like normal Models placed.
    Just tested and normal placed stuff is shown right, only my instated quads are not shown to the camera borders.
    Edit: I just tested, my modification of the quads creates the problem. So I have to find the reason there.
    Edit 2:
    I can call this solved!
    Calling:
    Code (CSharp):
    1. mesh.RecalculateNormals();
    2. mesh.RecalculateBounds();
    fixes the problem. The bounds were incorrect.
     
    Last edited: Jan 31, 2021