Sign in to follow this  
Vijay Kumar

objects not to be rendered when objects are behind other objects

Recommended Posts

Hi Deltakosh,

can we skip the mesh not to be rendered when camera is not able to see that mesh.

http://www.babylonjs-playground.com/#UJEZ1#8

in below screenshot camera is able to see two meshes so active indices count is 3912.

1.JPG

in below screenshot sphere is behind the ground mesh so any how it is required to render the sphere, so can we skip that object from being rendered, so that active indices count also will be reduced.

2.JPG

i have seen LOD concept but it is not helpful for my situation.

The reason why i am asking this is, in my scene the objects in other room also getting rendered when camera is at that  direction actually those are behind the wall .

because of that my active indices count is very high and my scene performance is very slow.

sorry for my poor English, but at least i think you guys understand what i am trying to explain.

Share this post


Link to post
Share on other sites

@Vijay Kumar

I think there were a post about this a while back,
and if i don't recall completely wrong, it isn't posible before webgl 2.0.

 i don't quite remember what the correct term for it was though :)

i suppose something you could do is to apply some kind of area triggers,

example:

all meshes that can't be seen from the starting point(either due to walls or distance, etc) are set to isVisible = false; by default.

when a player then starts moving around,

and is between this and that x and this and that z the meshes he is moving towards gets set to isVisible = true; while the meshes he is moving away from is set to isVisible = false;

if that makes any sense :)

Share this post


Link to post
Share on other sites

Made a quick AreaTrigger example :)

 

AreaTriggers_Example.png

So, basicly..

var player;
    player.area1shown = true; //starting area.
    player.area2shown = false;
    player.area3shown = false;

var timeout= false;

//registerBeforeRender..
if( player.position.x > -25 && player.position.x < -20 &&  player.position.z > 2 && player.position.z < 5 && !timeout){
timeout = true; //only run one time while the player is standing in the trigger field.
    if( player.area1shown ){
        //area1 (starting area) is already visible so player is mostlikely leaving.
        player.area1shown = false;
        //call function to set meshes in starting area to isVisible = false;
    } else {
        player.area1shown = true;
        //call function to set meshes in starting area to isVisible = true;
    }
} else {
//when player leaves the areatrigger, allow it to be triggered again..
timeout= false;
}

 

 

Share this post


Link to post
Share on other sites

Hi  aWeirdo ,

Thanks for your suggestion and the valuable time you spent for me.

the above concept will work when the camera is moving in straight path.

For example in the below screenshot if the camera is in 1st position i can at least disable some meshes in 1st room,

but if the camera is in 2nd position i think it is not possible to disable meshes in any room ..

3.jpg

Is there any method like that the mesh is visible or not visible to camera in current frame.

 

Share this post


Link to post
Share on other sites
11 hours ago, Vijay Kumar said:

but if the camera is in 2nd position i think it is not possible to disable meshes in any room

You know what room you are in, and I'm assuming you know what objects are in each room.  Just render the objects that are in your current room and the objects in any adjacent room if you are facing the doorway.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.