-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: It would be great to add a feature to render parts of the scene selectively. #5562
Comments
Interesting... |
I suggest you to use bitmasks. The implementation might look like this:
As for cameras they need to keep state of individual layer. Let's use bitmasks for this purpose.
Also we need to check status of individual layer by ANDing them with cullingMask. I am not familiar with your code, but in my opinion it can be done in the projectObject function of the THREE.WebGLRenderer.
The usage API might look like this: Suppose there are 3 objects and 2 cameras
By default all the objects are in the first layer and visible from both the cameras.
Now the camera2.cullingMask is 11111111111111111111111111111101. The second bit is 0, which means the layer2 is invisible from camera2.
|
I think using bitwise operations is the way to go. API wise however this is too hard for the user. How about something like this... object1.layer = 0;
object1.layer = 1;
camera.layers.hide( 1 ); @WestLangley I feel we have talked about this before. Rings a bell? |
I agree.
I'm not sure about I'm also not sure if
https://github.com/mrdoob/three.js/search?utf8=✓&q=bitmask&type=Issues |
How about... object1.layer = 0;
object1.layer = 1;
camera.layers.disable( 1 ); // disableAll(), enableAll();
Hmmm, maybe the renderer...? |
Maybe the scene?
|
I know the bitwise operators are hard for modern programmers. So we need a high level API. Let me think more about it.
I'm sure layers should be property of the camera. Because the main goal of the feature to make objects visible from one camera and invisible from another. |
From a design standpoint, neither the camera nor the renderer should need to know anything about the scene. I think |
It seems I'm missing the point. |
We are just debating the issue here. Your opinion is welcome. |
Just trying to understand how to use |
Well, in Blender seems like the layers concept is in the scene. |
Here is how it works in Unity https://www.youtube.com/watch?v=iYaOkbC58W4 |
Hmmm, yep! I like that use case ^^ |
Certainly the layers belong to the scene. And it's possible to use them not only in scope of this feature. For instance you can use layers with lights, raycasts etc. Here is one more sample of layers usage in Unity https://www.youtube.com/watch?v=HR-Tf_6uzwc |
Hmmm... the behavior is going to get a bit complicated, I'm afraid... There are a number of cases...
|
Hmmm... It's actually not too bad. Yes, I would expect that if I set If anything, this collides with |
Is this the intent? A renderable object is visible only if
|
Yes. And if I had to remove one of those, I would remove the last one, so that way all the visibility logic is in the scene graph and not in the material. |
Yeah, you never have liked the |
;) |
Ah yeah, I remember discussing this for lights. Implementing this for lights will be more difficult though. But starting from the camera should be easy. |
It's would be user friendly to use the similar API for lights in future. |
Is somebody implementing this? If not, I could give it a shot. Personally, I'd follow Unity's design. However instad of Object will be culled if I'm not sure however if Unity culls the whole branch (=the object in question, its children, grandchildren etc.), but I'd rather have the behavior to cull the entire branch -- at least initially. Later we could have |
API-wise, I don't want the proposed utility functions or classes because I think it bloats the code. These could be added later if somebody requests them. I however do understand that artists may not know how bitmasking works, but anyway the complexity of this feature is at the level that any artist attempting to use it should know what they are doing and try to study how bitmasks really work. |
…erBits to set objects to layers. Cubemap dynamic2 example to use layers. New example to demostrate layers with shadowmaps. Answers feature request mrdoob#5562
Here you go: #5931 |
I don't think we should be culling the whole branch. That's what |
@mrdoob Hmm, how about having both |
Lets first sort out object level first :) |
It looks like layers are ignored when using toJSON(). This is a total bummer, since we're using layers and importing/exporting lots of scenes... |
@Yugloocamai That should be easy to fix. Do you mind taking a look @Mugen87? |
Since |
I mean something like Camera.cullingMask in Unity http://docs.unity3d.com/ScriptReference/Camera-cullingMask.html
The text was updated successfully, but these errors were encountered: