x


Terrain Culled in RenderWithShader

I have an issue where my terrain is being culled inappropriately when used with a buffer I am constructing with the RenderWithShader functionality. The camera is created and then disabled immediately. Each frame I call this in OnPreCull:

Camera cam = shaderCameraObject.camera;
cam.CopyFrom (camera);
cam.backgroundColor = Color.black;
cam.clearFlags = CameraClearFlags.SolidColor;
cam.cullingMask = clipLayer.value;
cam.targetTexture = boatCullBuffer;
cam.RenderWithShader(shader, "CullBuffer");
Shader.SetGlobalTexture("_CullBuffer", boatCullBuffer);

So the camera has the same farClip as my main camera (I've debugged to confirm this). Here's a shot of the main camera's view:

alt text

And then here is a shot of the RenderWith Shader (Terrain should render completely green):

alt text

Any Thoughts? Why is the culling happening inappropriately?

more ▼

asked Jan 18 '11 at 04:21 AM

JonManatee gravatar image

JonManatee
251 7 8 18

Could you make a screen shot of the terrain in wireframe, depending on the zoom and relative size of the faces, it could have an impact.

Jan 24 '11 at 10:56 AM Jean Fabre

Are you sure that your shader you're using for RenderWithShader is working correctly? Try to use a different shader and check the result (rendertexture). Can you post the shader you use? And does this happens with other geometrie? (something other than terrain). Like Jean said, give us a screen shot with wireframe or a simpler scene that have the same issue.

Jan 25 '11 at 09:30 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

your snippet is being called on the OnPreCull? the RenderWithShader function doesn't calls OnPreCull http://unity3d.com/support/documentation/ScriptReference/Camera.RenderWithShader.html so your CopyFrom is probably not being applied. Try calling it from somewhere else.

more ▼

answered Jan 22 '11 at 12:57 AM

Bravini gravatar image

Bravini
1.1k 6 11 29

I don't think that's right, because this is attached to the Main Camera, the one rendering the top image. Which IS calling OnPreCull. The second camera on shaderCameraObject is being told to RenderWithShader() which will not call OnPreCull(), but that is irrelevant to the Main Camera. To be sure, I changed the code to LateUpdate and it did not fix the problem.

Jan 22 '11 at 02:39 AM JonManatee

could you upload a scene package with just the relevant components?

Jan 22 '11 at 02:59 AM Bravini
(comments are locked)
10|3000 characters needed characters left

Edit: Ooops, nm I misread the question sorry

more ▼

answered Jan 24 '11 at 09:47 AM

Jeston gravatar image

Jeston
419 27 31 34

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1472
x147
x17

asked: Jan 18 '11 at 04:21 AM

Seen: 1321 times

Last Updated: Jan 18 '11 at 04:21 AM