Odd behavior with textured box under camera

Oct 19, 2010 at 3:38 AM
Edited Oct 19, 2010 at 4:04 AM
First let me say, this project is amazing. I can’t believe how awesome and fun this is to work with. I understand it’s a work in progress, and that my understanding of 3d world building is very limited. I’ll keep that this is a work in progress in mind if everyone here keeps in mind I’m pretty new to 3d programming :)


My question is about the camera and a 3d box position. Here is the XAML (you’ll need your own texture.
NOTE: Texture is 32x32 (really small)

<Execution:Game x:Name="Game" Width="1024" Height="768" >
                <View:Camera x:Name="GameCamera" Position="-28,20,-146" Target="-8,20,-90"/>

            <Lighting:OmniLight  Position="0,100,-60" Diffuse="White"/>
            <Lighting:ViewLight   Diffuse="#FFFFFFFF"/>

            <Geometries:Box  Dimension="300,5,300" Position="0,-10,0">
                    <Materials:Material DiffuseMap="/SilverlightApplication2;component/Images/Grass.png" />

Notice that only half of the box is rendered (the top of one face)
Change the camera to this: 
<View:Camera x:Name="GameCamera" Position="-61,20,-225" Target="-38,20,-170"/>

Now the entire box is shown, but the camera is not on top of it.

What causes this?

Oct 19, 2010 at 4:09 AM
Edited Oct 19, 2010 at 4:14 AM

Instead of the large 300x300 box under the camera I tried to tile 20x20 tiles under the camera, I tiled 300 of them, or a grid 15x15. They seem to render fine with the camera at the same positions as in the code above.

It looks like my problem is from the large 300x300 box. But why would a large box work differently than the smaller ones. I’d rather use the larger one since it’s a lot less points to work with. 8 vs 2400 if I’m doing my math correctly.

Could this be the Frustum-culling? Is there a property I can use to turn this off for testing?

Oct 19, 2010 at 4:57 PM

Hi and thanks,

are you using the release version of Balder   I've been working on clipping the last week and pushed some new stuff to the source repository this weekend, maybe that'll help ? 

Please let me know if it doesn't, as I'm still trying to make the clipping perfect. 

Oct 19, 2010 at 5:36 PM

I got the latest version from source and I'm still seeing the same clipping.  When the camera moves over a large face that face can clip.  In this case I was 100 above the face and it still clipped.  The texture does not seem to be the issue. I can take the texture off, and just set a color and see the same thing.

My sample project is a mess :)  But I'd be happy to send it your way if you think it would help with debugging. Basicly it just shows a few boxes and lets you walk around them.  Using the above XAML the problem can be reproduced as well.

If there are any other details or tests I can run I'd be happy to do so.

Oct 19, 2010 at 6:30 PM
Ok. I'll use your sample when I work on the clipping issues as well. Thanks.
Oct 19, 2010 at 8:24 PM

I got an email that an image was posted to this thread, but I can't find it for the life of me... Is the post hidden somehow? Here is the text copied from my email:

"From: adept
This is what I'm seeing with the Camera set to:
<View:Camera x:Name="GameCamera" Position="-28,20,-146" Target="-8,20,-90"/>Is this wrong?"

(I don't often use codeplex, so I'm not understanding the format please let me know)

Oct 19, 2010 at 8:52 PM

I wrote the message and pasted the picture in here and clicked Post - and the image went away, so I deleted the message. 

Anyways, here it is. Used the first Camera position in your sample, and this is what I'm seeing (Could you describe for me whats wrong) :

Oct 19, 2010 at 9:13 PM

I do not see anything wrong with your example above. But the box should be 300x5x300. Here is a series of three images that show what I'm seeing.  I know it's hard to get the point across with just images.  In Image 1 I show the camera a ways out (look at top left of image for camera and target positions) Then I move the camera closer (notice the target changes too) Then, I get too close to the single 300x5x300 box and one of the faces is clipped. The red outline I have added and is NOT rendered as part of the program.

 XAML for box:
            <Geometries:Box  Dimension="300,5,300" Position="0,-10,0">
                    <Materials:Material DiffuseMap="/SilverlightApplication2;component/Images/Grass.png" />

Entire box, no culling.
Entire box, no clip

no culling still
most of box, no clip

Camera is now too close to box, there is clipping going on.
box clipped

Oct 19, 2010 at 9:49 PM

Thanks for those images - that helped a lot. I think I see what you mean now. In fact I saw something similar in a demo project I'm working on earlier tonight. The clipping is too greedy, and I think I have a pretty good idea of were its happening.

I'll continue the clipping hunt tomorrow - have a couple of other reports similar to this, so thats my focus these days.

Oct 25, 2010 at 9:40 PM

I've been hard at work with the clipping today. And hopefully this problem should be gone now. 

The tip should have the latest with this in it.

Nov 1, 2010 at 10:39 PM

Due to the performance loss I understand that the code to help support large faces or faces close to the camera needed to be rolled back. Does anyone have any advice on how I can look into or help fix this? I’ve been digging in the source and I have found the spot where this seems to be stemming from, I think. 


Specifically the check to see if the mixed product is greater than the negative area of the view. Am I right to assume that this will check to see if a face is larger than the screen? If this is what the check is for, I assume it’s also to help cull the faces behind the camera, since they will be very large. It also seems to cull out triangles that should be on screen, but are too large.

 I am wondering about solutions to cull triangles that are behind the camera but allow any triangle in front of the camera, regardless of size. I tried the following but it didn’t seem to work correctly: mixedproduct > -(viewport.Width*viewport.Height * 20)

Nov 2, 2010 at 7:21 AM


is there a performance loss with the latest version? 

Nov 2, 2010 at 2:42 PM

The latest version seems to perform well.  I was just trying to tackle the clipping problem. (as shown above in the screenshots)  I did have some success, though at a high price.  I broke each face into eight smaller faces, now the camera can get much closer before the clipping problem happens. That pushed my face count > 20,000 though, so I need to scale back my world a bit.  I'm excited to be able to work with this system. I've never had much success with 3d before, but Balder is making it easy!

I'm building my terrain generator to be flexible. If the clipping problem is solved for large faces, I'll scale back the number of faces I break my world into. In either case I have a large flat area (like the screen shots above), the difference is how many faces build that large flat area.

Thanks to the Balder team for their great work!

Nov 2, 2010 at 6:54 PM


I'll be working more on the clipping issue at a later stage - just got some work related stuff that I need to be focusing on for the next couple of days. There is probably just a small thing I'm not seeing that is causing this problem.