Planetside Software Forums

General => Terragen Discussion => Topic started by: Kevin Kipper on May 31, 2011, 01:13:01 PM

Title: Mask by Camera FOV
Post by: Kevin Kipper on May 31, 2011, 01:13:01 PM
I want to populate a heightfield with trees but only the side of the terrain that is visible to the camera.  How do I create a mask based on the camera's FOV?
Thanks!
Title: Re: Mask by Camera FOV
Post by: Tangled-Universe on May 31, 2011, 01:22:16 PM
Why would you want to do that?
If you render with "ray traced objects" enabled then the trees which aren't visible to the camera won't be rendered too.

Cheers,
Martin
Title: Re: Mask by Camera FOV
Post by: Kevin Kipper on May 31, 2011, 01:24:59 PM
To cut down on the # of objects that get instanced.  If they are never visible to the camera, there's no need to generate them.  In other 3d packages, this would cut down on the scene overhead and I assume this would be the same in Terragen 2.  Also, it helps clean up the display by having fewer objects visible.
Title: Re: Mask by Camera FOV
Post by: Oshyan on May 31, 2011, 01:37:20 PM
Check "clip to camera" in the populator(s) settings.

- Oshyan
Title: Re: Mask by Camera FOV
Post by: Tangled-Universe on May 31, 2011, 01:37:50 PM
I've never tried this before, but you could try the following:

Add a 100% white surface layer/lambert shader as the final surface shader of your node-network.
Make a separate sun and set elevation to 90.
Disable GI enviro light. Set GI to 0 in the renderer and disable rendering of atmosphere in the renderer.

If you render you should have a white terrain and black sky. This is your mask now.

Create an imagemap-shader and load the mask into it.
The camera projection type is "through camera" as default, leave that as is.
Scaling is also default 1x1.

Use the imagemap as blendshader for your population's density shader (which controls slope/altitude etc.).
I suspect only the parts facing the camera will be populated now.

Secondly, you can also decrease memory-usage by using the "clip to camera" function which makes sure only objects are being populated within the camera frustum.
However, still on all sides of the terrain and it isn't calculating the population's instances faster.

Title: Re: Mask by Camera FOV
Post by: Dune on June 01, 2011, 04:07:08 AM
I would have conjured up something like that as well, it should indeed work. It may even be more important to use this method for tiny displacements (or water) behind terrain structures, as this is rendered first, taking time, and will be 'snowed under' with more frontal structures anyway.
Title: Re: Mask by Camera FOV
Post by: inkydigit on June 01, 2011, 07:24:19 AM
maybe a combination of 'clip to camera' and a distance shader, will be a quick way of reducing the populations?
Title: Re: Mask by Camera FOV
Post by: Tangled-Universe on June 01, 2011, 07:54:53 AM
Quote from: inkydigit on June 01, 2011, 07:24:19 AM
maybe a combination of 'clip to camera' and a distance shader, will be a quick way of reducing the populations?

The idea is that RedMaw wants to have surfaces facing away from the camera not being populated, like trees behind the hill/mountain within the camera-view, thus reducing the number of instances to a minimum.
Title: Re: Mask by Camera FOV
Post by: cyphyr on June 01, 2011, 08:48:53 AM
It tried something similar a while ago. I placed a VERY bright light at the exact camera position, turned off all other lights and added a simple white lambert shader to the terrain. Then with an orthographic camera above the population area i rendered out a BW mask showing areas that the camera could see (white) and areas the camera could not see (black). This image is then re-imported and projected plan y at the co-ordinates of the orthographic camera. Going back to your normal perspective camera and the population use the BW image as a distribution shader. NOw you should have trees where there was light visiable to the camera and nothing where there was no lilght visable.
Hope this
helps
Richard