Continuously generated levels are not completely an unusual technology to construct today. Nevertheless, possessing a brilliant globe, with a lot of moving objects and complete customized amount layout that also has to run on low-end mobile phones, frequently demonstrates more difficult than at first expected. On this page, one of the most advanced developers, Michiel Frankfort, describes how we tackled this for KLM Jets , Papercraft Air-O-Batics.
This is what they done!
[RequireComponent(typeof(Camera))]
public class LowResFrustumExtension : MonoBehaviour {
Awake() {
On awake we create one or multiple camera’s nested as a child into this gameobject. We then inherit all the settings found on the parent-camera component. For each camera, we assign a target RenderTexture (RT), with decreased resolution.
Thanks to the custom projection-matrix, we are able to go with anamorphic (non square) pixels, allowing us to scale down the ‘width’ by a factor of 2 and the ‘height’ by a factor 4. After rendering, the target-texture will appear ‘skewed’ but by blitting the RT back to full screen, it stretches back into place. We do not scale down with a square ratio,because this reduces tearing. There are a lot of vertical lines that will start to jitter when the ‘width’ is scaled down to a factor of 4, but for the (relative stable) horizontal lines, this looks okay.
Each camera and its target RT represents a ‘RenderLayer’. Each layer renders a certain area of the total render-distance. For example, this is one of the setups we used for Jets:
MainCamera (full-res) 0.1 to 25
First RenderLayer (half-res) 25 to 55
Second RenderLayer (third-res) 55 to 75
The RenderLayers need to be rendered in a ‘far-to-near’ order, so the camera’s depth equals the parent camera’s depth, minus its own RenderLayer index.
}
Update() {
On update we loop through all the RenderLayers and update the custom projection-matrix accordingly. Each layer should extend its parent main camera, therefore some values need to be inherited in each frame, such as fov, culling-mask, etc.
}
OnPreRender() {
This ‘OnPreRender’ is fired when the parent/main camera is about to be rendered. At this point, due to lower camera-depth, all the children RenderLayers are already done rendering. This means that there is a stack of RenderTextures available and ready to be ‘blitted’ to the final RT or screen.
So we first make sure the screen is targeted as its final render-target, then we loop through all RenderLayers and blit its RT to the screen.
}
}
read original article here
http://www.littlechicken.nl/en/coding-en/klm-jets-doubling-viewing-distance-without-lod-ing-or-performance-drop/
MORE TO SEE:
Comments
Post a Comment