Jump to content
Brutile

Camera Layers

Recommended Posts

Not sure if there is something already in Leadwerks to do this, but I would like something similar to Unity3D's camera layer system, where you could set an object (like a gun) on a layer that the camera could cull. You could then setup two cameras, one that renders the environment, and another that just rendered the gun. This would be helpful in stopping weapons passing through walls, and would also allow higher FOV without making the gun look stretched and horrible.

Share this post


Link to post

good idea

 

could also be interesting in combination with post effects per camera. like background black/white and gun tooneffect

Share this post


Link to post

Ok, that makes sense and I got it mostly working, but when I render, it will only show the last world that I rendered. It was rendering the background, which rendered over the top of the first one.

Share this post


Link to post

Thanks shadmar, that worked, but the objects in the worlds are now pixellated, even with multisampling turned up. Is there a way to fix it?

Share this post


Link to post

Try to add something like this :

fortex->SetFilter(Texture::Smooth);
fortex->SetAnisotropy(16);
foreground->SetColorTexture(fortex);

 

and maybe

 

camera->SetMultisampleMode(2);

Share this post


Link to post

SetAnisotropy gives me a script error: error in function 'SetAnisotropy' argument #1 is 'Texture'; 'Texture' expeced. I'm using Lua.

Share this post


Link to post

I think multiple worlds is a good way of doing things, but I still think you shouldn't need to use textures and buffers. There should simply be a way of culling the background of a camera, then rendering the two worlds.

Share this post


Link to post

Not sure if there is something already in Leadwerks to do this, but I would like something similar to Unity3D's camera layer system, where you could set an object (like a gun) on a layer that the camera could cull. You could then setup two cameras, one that renders the environment, and another that just rendered the gun. This would be helpful in stopping weapons passing through walls, and would also allow higher FOV without making the gun look stretched and horrible.

That's actually a bad example because if the gun penetrates into a surface, even if you hack it to appear on top, the surface's shadow will still be cast onto the gun. (This occurs sometimes in STALKER, at least the first one.) My solution was to scale down the weapon to a very small size and put it right in front of the camera. You still get the nice environment shadows cast onto the visible weapon, and it doesn't penetrate walls.

Share this post


Link to post

I did the same thing Josh did with scaling and it works. However, it was a nightmare of trial and error trying to get the right scale and position.

Share this post


Link to post

I think it's a bit of an exaggeration to call that a nightmare. wink.png

 

Another option is to make it so the gun is rotated up when it is close to a wall. They did this in Crysis, and I think even Dangerous Rays has this behavior. I saw another game where the gun would just get rotated downwards out of view when close to a wall, maybe it was Doom 3? That would be a nice feature to add to the player script.

Share this post


Link to post

I have pretty tame nightmares :). Probably 15 mins of trial and error of scaling, test, get pissed, rinse and repeat.

 

That rotate downward was a video posted here that some made with LE. It did look nice. It was in 3rd person but I'm sure it works in 1st too.

Share this post


Link to post

So, Josh, is it really intended, that you can't simply render two different worlds/cameras, etc. over one another (with alpha)? I think, the ability of doing that was a great feature in LE2.5. Especially the ability of rendering first only the layers without lighting and then AFTER that rendering the lighting seperately (calculated only once from screen-space, as explained in your own document: http://www.leadwerks.com/files/Deferred_Rendering_in_Leadwerks_Engine.pdf). (The part about the lighting is really important for performance). The lack of this would be quite a drawback, imho.

Share this post


Link to post

I have pretty tame nightmares smile.png. Probably 15 mins of trial and error of scaling, test, get pissed, rinse and repeat.

 

That rotate downward was a video posted here that some made with LE. It did look nice. It was in 3rd person but I'm sure it works in 1st too.

Hahaha... At work we searched for (as it was discovered) a misplaced '.' character for two weeks. THAT's a nightmare :D

Share this post


Link to post
smile.png I have more patience for bugs than I do scaling trial and error it seems because a bug is a mistake and I accept that. Scaling like this should be easier and real-time to make it more efficient. I could have probably set something up for that, but either I write 30+ mins of code to do that or I suffer 15 mins of rescale/restart to find the exact value. I picked the trial and error just to something.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

×
×
  • Create New...