My Custom Geometry is invisible, but casts shadows.

rated by 0 users
This post has 11 Replies | 2 Followers

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
2.0 Studios Posted: 02-26-2010 3:14 AM

Hey,

I'm having some issues with custom geometry. It casts shadows to world around, but it itself is completely invisisble.

We create a mesh in code, using a vertex buffer, index buffer and vertex positionnormaltexture for our vertex type.

            CustomMesh FinalBall = new CustomMesh(VertexBuffer, IndexBuffer, VerticesCount, IndiceCount / 3,
                new VertexDeclaration(g_Camera3D.GET.Graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements)
                , VertexPositionNormalTexture.SizeInBytes, renderEffect);


This renders fine without sunburn.
http://i.imgur.com/mozgJ.jpg

Then we attempt to buid a SceneObject from the data we generate.


BasicEffect TempEffect = new BasicEffect(g_Camera3D.GET.Graphics.GraphicsDevice, null);

            SceneObject Temp = new SceneObject("TestingName", TempEffect , Bounding, this.world, this.IndiciesBuffer,
                VerticesBuffer, this.dec, 0, PrimitiveType.TriangleList, FaceCount, 0, VertCount, 0, this.strideSize);


This gets us this:
http://i.imgur.com/kW6GI.jpg

Is there anything we are missing or doing wrong, that would cause custom geometry to turn invisible?

Thankyou for your help. (We are using 1.3.1 and deferred lighting)

-- Daniel & Jarryd

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi 2.0,

Are you setting the Visibility property after creating the SceneObject (make sure it's set to both render and cast shadows)?

Also make sure the bounding sphere passed into SceneObject is in object-space.

 

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Yep the Visibility property is set to cast shadows and render.

The bounding sphere was created with a Center or Vector3.Zero (This should make it always placed in the objects center?) and we tried sizes of 30 (our models size) , 3, 300, 1000, 10000 all which did not work...

The object is at the worlds 0,0,0 too so we figured it could be the bounding sphere out of place.

Any other ideas?

 

Thanks heaps for your help
Daniel

Top 10 Contributor
Posts 337
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

if you have set the alpha to <=0.15 the object will not appear at all. !!! values of 0.16 or greater will fix this.

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi 2.0,

Sorry I didn't catch this sooner:

2.0 Studios:
BasicEffect TempEffect = new BasicEffect(g_Camera3D.GET.Graphics.GraphicsDevice, null);

2.0 Studios:
(We are using 1.3.1 and deferred lighting)

BasicEffect is a type of forward rendered effect and cannot be rendered with the deferred render manager (though you can render outside of the render manager using forward effects - SunBurn supports mixing rendering modes).

Try using SunBurn's built-in DeferredObjectEffect instead - it provides all the features available in the SunBurn material system and is a deferred effect for use with the deferred render manager.  I believe this requires tangent-space information, but SunBurn's VertexPositionNormalTextureBump class has static methods that automatically generate this for you using the VertexPositionNormalTexture information you've already provided.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Yer the alpha we are using is 1.0f so i don't think that is the problem

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Thanks for the help John i will try this tomorrow and see if i can get it to work that way.

Thanks again.

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Hey,

It is almost working!
http://i.imgur.com/CtaCP.png

But the object is inside out. Outside of XNA I would simply drop this in:

 g_Camera3D.GET.Graphics.GraphicsDevice.RenderState.CullMode = CullMode.CullClockwiseFace;

And that would fix it. But I don't think I can do that inside sunburn.

So I found this:
BallSceneObjectTest.RenderableMeshes[0].CullMode = CullMode.CullCounterClockwiseFace;

But that is read only, so I cannot chage it.

So I tried to make it double sided.

            DeferredObjectEffect temp = (DeferredObjectEffect)SceneTest.RenderableMeshes[0].Effect;
            temp.DoubleSided = true;

That kinda works. The object I don't think is inside out anymore.

http://i.imgur.com/ktAH6.png

But the lighting is backwards and the shadows are funny looking.

I am fairly certain that it is the winding order, but I am unsure of how to get at it.

--Jarryd

Top 75 Contributor
Posts 47
SunBurn_Indie_Licensee
SunBurn_Pro_Licensee

Reverse the winding order in the content pipeline settings.

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Dave:

Reverse the winding order in the content pipeline settings.



I cannot do this.

this is not a loaded model. I am generating this sphere from a heightmap texture. I need to reverse the winding programatically.

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi 2.0,

The object windings are determined in your code that generates the index buffer data, you'll need to swap the index order of two of the verts for each triangle (assuming a triangle list).

As an example, if your code looks something like this:

indices[i++] = verta_index;
indices[i++] = vertb_index;
indices[i++] = vertc_index;

You should swap it to:

indices[i++] = verta_index;
indices[i++] = vertc_index;
indices[i++] = vertb_index;

SunBurn follows the default counter-clockwise winding order set by XNA / DirectX.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Thankyou BobTheBuilder. That was exactly what I needed to do. Now I can move onto making these funny shaped objects part of the gameplay!

Your are quite tenacious in helping people solve their problems, and it is much appreciated. It is one of the main reasons sunburn is great.

-- Jarryd

Page 1 of 1 (12 items) | RSS