Questions about Vertex Color, Textures and Vertex Alpha

GenericBum

24-04-2006 02:45:12

I'm working on putting together some guidelines for content on my PocketPC port of Ogre and I'm using oFusion. Specifically, I'm looking at Banjo-Kazooie levels to figure out how I should approach levels.

Banjo-Kazooie uses vertex color and vertex alpha data with overlapping polygons to blend between two textures. Since I don't have shaders on the PocketPC, I'm wonder how I can accomplish this using oFusion.

This first shot is from the real Banjo-Kazooie:


Here is what my version of the level looks like in Max, but you can't see the underlying polygons with the 2nd texture.


My question is this: I can add the vertex color and enable color blending on the material, which seems to work. But the "alpha blending" on the material with the vertex alpha doesn't seem to do anything. And is there an option for both?

Some other random questions I've encountered:
- How do I setup a Max blinn material so that when I evaluate it as an Ogre Material it is set to Lighthing = off?
- How do I setup a Max material so that when I evaluate it as an Ogre Material the diffuse colors come across?

Thanks,
GenericBum

Lioric

24-04-2006 17:29:20

Read this thread, it has details on blending different textures using the vertex alpha value, just dont use the "env mapping" setting for the other pass in your case

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=571

You need to disable Lighting in your pass material(s)

If you need to automatically disable the Lighting (so vertex color and alpha values are used) you can select your objects, right-click and select properties, and activate "Vertex Channel Display" option

GenericBum

24-04-2006 19:04:42

The tip on showing Vertex Colors in the Max viewports definitely helped get me started. And I read the thread to see how to setup the materials.

Here is what I'm seeing at this point:


The vertex color and alpha is all setup correctly (I think), but the results in Ogre are very odd. The dark and white polygons are fine, since I haven't setup all the materials or switched everything to no lighting. But I can't figure out why polygons are just "dropping out".

I've reset xform on the meshes, flipped and unified normals, and done a bunch of other things to try and fix it, but with no success.

Any ideas?

GenericBum

Lioric

24-04-2006 20:45:04

If in that pass you enable Lighting and disable the textureUnit, the missing polygons are displayed?

GenericBum

25-04-2006 04:02:33

Actually, if I enable lighting and set the Emissive to white then the polygons show up.

GenericBum

25-04-2006 04:19:51

Here is the view with lighting turned back on and the emissive color set to white.



There is a wierd oddity. When I pull instances out of the multi-material and set options. If I click back and forth between instances in meditor, some of the options dont refresh. For instance, I removed the culling on a two-sided material and then clicked on the material next to it, and the culling options stayed off, despite the fact that they had been on before.

I would be happy to zip these files up and send them to you.

One thing that puzzles me is that even in a test file, I cannot get the blending to work. Perhaps there is something I'm not doing right.

I have an ogre_material that contains 1 technique that contains 1 pass that contains 1 texture unit. The pass is set to alpha blending and it is applied to a set of polygons. Then I have another ogre_material that contains 1 technique that contains 1 pass that contains 1 texture unit. This pass is also set to alpha blending and it is applied to a set of polygons under and overlapping the first set. Is that correct?

GenericBum

Lioric

25-04-2006 17:58:47

You should avoid using overlapping geometry, it will cause z-depth issues (specailly on very limited precision hardware) and will depend on the clip planes

This is a multipass effect, you use a single mesh and a single material with two or more passes, and the colors will be blended using the alpha values on a multipass rendering

Click for bigger images



This is an example created with a sinlge plane, it has a single material that contains two passes:



the grass diffuse pass, that is a normal pass but with Lighting disabled
the stone pass, uses the "Alpha blend" mode and Lighting disabled too

The grass pass dont use alpha values or any blend mode so this pass will render all tha plane with the grass texture

The stone pass uses the alpha values, as a result:

In the image, the selected verts has its alpha value to 100% and the rest of verts has its alpha value to 0, so the selected verts will be rendered with the stone material (this material uses the alpha values) and the rest of the verts will dislpay the grass base material

GenericBum

25-04-2006 19:17:44

Will do. Thanks Lioric for taking the time to make the screenshots.
GenericBum

GenericBum

26-04-2006 05:40:11

Hmm.. I'm definitely not getting something.

I've zipped up a small demo max file with two textures trying to recreate your example.

It would be cool if you could download it here and tell me what I'm doing wrong.
http://www.manifestgames.com/AlphaTest.zip

I played with alot of the different settings, but couldn't get either texture to be effected by the vertex alpha.

GenericBum

Lioric

26-04-2006 19:09:13

The example file is correct, the issue is that on some cases, max dont update the objects alpha flag if a vertex color is not modified

I will look into this issue later

In your example, just change the color of a vertex or some vertices (you can set them to white color again after that) and the alpha values will be used (as max updates the alpha flag)

I will recommend a good tool used to make "shadows/dirt" per vertex that produced good results, it was called "pits and peaks" or some like that, i used that when i needed to add per vertex detail