Search Unity

gameobjects that are not seen by the camera ale rendered. need help whith this :(

Discussion in 'General Graphics' started by Synatops, May 30, 2015.

  1. Synatops

    Synatops

    Joined:
    May 29, 2015
    Posts:
    12
    hello there,
    i have an little big problem.
    i instantiate some cubes (as example 5x5x5) that must all be single objects.
    the problem is that the cube in the middle of the cube that nobody sees are also rendered what causes laggs and framedrops (well not by 225 cubes but if i instatiate some more what i will ..).
    so i should try to check, if i can see one side of an cube. if true, render it, else dont.

    but i have no idea how to do this :(

    if someone has an idea please let me know :)
    thanks

    if there is the posibility to answer in german i would prefer but english is also alright :D
     
  2. Synatops

    Synatops

    Joined:
    May 29, 2015
    Posts:
    12
    or if someone has an idea how i can render more than 500'000 cubes with textures without massive laggs or better called with more than 5 fps that would pretty pretty cool <3
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    You don't; instead you use the Mesh class to construct combined meshes. See the various Minecraft topics, since this has already been thoroughly discussed.

    --Eric
     
    theANMATOR2b likes this.
  4. Synatops

    Synatops

    Joined:
    May 29, 2015
    Posts:
    12
    yeah well i think only for the generation of my meshes the ideas of the minecraft topic might work but in later gameplay this will be cause errors.

    isnt there any solution to check is the gameobject seen from the camera or is something in front of it so it isnt seen ?

    or another idea which could work (as well im not pretty sure if it cause same errors like the MC ideas) may i check something like this for every block and if yes, will it cause low framerates ?


    Code (CSharp):
    1. if ((my.transform.position.y+1) = other.transform.position.y [ or y-1 or (same for all sides) ]){ // check if another cube is on all sides
    2.           my.renderer = false // on all sides is another cube so dont render me
    3. }
    4. else{
    5.          my.renderer = true // one side is seen so render me
    6. }
     
  5. CodeMonke234

    CodeMonke234

    Joined:
    Oct 13, 2010
    Posts:
    181
    Google: View Frustum culling. However, It is already enabled by default. Only objects whose bounds are in the view frustum are rendered.

    Occlusion Culling can also help, depending on your scene. This pre-computes a data structure, like an octree, that stores visibility information. So a skyscraper in front of the viewer can block a city block and save it from being rendered.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    There won't be any errors, unless you programmed it wrong.

    No, this won't work. You can't create individual cubes and have it perform well, end of story. You must use the technique of creating mesh chunks with the Mesh class, as described in the various Minecraft topics. So just do that.

    --Eric
     
  7. Synatops

    Synatops

    Joined:
    May 29, 2015
    Posts:
    12
    in the minecraft topics are chunks or better called mulicube cubes createt nothing else.
    for my game i need other more complex multicube structures.


    i've read the documentation and i think this is nearby exactly that what i need (if it would work)
    maybe i've done something wrong or forget something to set up correctly but for now it just dont do that what it should. i'll try it later again when i have more time to test.

    if u're able to give me some more informations about this i would be realy happy :D

    thanks for that
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,203
    I really have to idea what you mean. The correct answer is to create mesh chunks with the Mesh class. Occlusion culling won't help much; you have far too many objects. But if you insist on not accepting this, well, good luck but you won't get very far.

    --Eric
     
unityunity