Opaque mesh interior?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Opaque mesh interior?

Post by Dances »

Is it possible to 'fill' a mesh with a particular color, so that when the camera is inside of the mesh that color is displayed?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You could render the mesh with its normal inverted and with your set colour instead of a texture and that might do the trick..

Though it depends what effect you're actually after, why do you want the inside of a mesh rendered in a specific colour?

You could do a test on the camera position and if it's inside the mesh you could just render a full screen quad in your set colour, but i imagine that might be quite a poor effect, depending on what you want to do!
Image Image Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Rendering with the normal inverted won't help. Remember that the hardware decides which side is the 'front' of the face using the winding order, not by the direction of the vertex normals. You would need to reorder the index buffer to change the winding order.

I think it would be much more simple to disable backface culling. Unfortunately you really want to change the winding order, so backface culling isn't enough either. Even then the interior of the model would not be one solid color, it would look like the outside but on the inside. You could work around that by switching the texture, but that wouldn't work well if part of the object is clipped by the near plane.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It seems that you could extract the near clip plane from the view frustum [or the view/projection matrices]. For each scene node that is near the camera, transform the near clip plane into object space and see if the plane clips the object bounding box.

If it does, then there is a good chance that the mesh is going to be clipped. So you save the materials used by the scene node and assign your material in its place. Set the winding order to CCW, render the model, then reset the winding order and materials.

At least it seems like that would work.

Travis
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

Double-sided lighting may be what you're looking for. It's simple enough: you define lighting parameters for front-facing primitives and separate lighting parameters for back-facing primitives. It's supported by OpenGL but I don't know if Irrlicht supports it directly.

Alternatively, you could write a vertex shader or fragment program to compute the cross product so you can choose between front- and back-facing colours.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

What I wanted to do with this is to go for a cheap blanket of fog effect. I was thinking of making a box which is filled with the fog color, which gets lighter in alpha value near the top.

What you have said made me think I could just put a visible billboard in front of the camera if it is in the mesh's bounding box. I'm just not sure how I would 'fade out' the fog near the top. I'm also no sure how I could make the fog look nice from above.

I was hoping to expand this system for clouds as well.

I am making a project involving a LOT of fog and cloud effects, so particles aren't an option; they're too hard on the system. I also want consistency so that 'players' on a network can see the same clouds.

EDIT: I've been goofing around with google, and trying to learn about things like Volumetric fog (as I am absolutely clueless on these things) and I found screenshots of exactly what I'm looking for. How could I do this to the interior of a mesh? I know it wouldn't be the prettiest kind of cloud, but it would satisfy me for now.

http://www.nothings.org/computer/vfog/shots.html

He actually has a write up on how he does his fog effect but I get SO lost reading it. I need to find a step-by-step site that explains the ins-and-outs of a game engine so I can wrap my brain around this stuff -.-
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Okay, I've got a basic understanding of this.
I need to cast a ray from the camera, determine how far through the fog object the ray went, and then adjust the opacity of the object, pixel by pixel.

I know the engine is already ray-tracing, and to try to do it again would be retardedly inefficient. I'm not really 'ready' to start changing around the insides of Irrlicht though. Is there any theoretical way to do this with a scene node without making any code changes that require a recompile of Irrlicht?
Post Reply