Vertex alpha in .x files - question (Fred?)

Blitz3D Forums/Blitz3D Programming/Vertex alpha in .x files - question (Fred?)

Skitchy(Posted 2004) [#1]
I've written a fully working .x exporter, except for *1* stupid little thing that doesn't seem to make any sense at all :/

I'm using the MeshVertexColors{RGBA} chunk to define the color and *alpha* of each vertex in the mesh. The color shows up just fine (so I **KNOW** the data is getting into the engine), but the alpha just refuses to show itself.

This isn't the good old EntityFX(mesh,34) problem, and I've tried it in several different non-Blitz engines with the same result - color is there but alpha ignored.

On my quest for an answer I came upon this page :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/direct3d/gettingstarted/direct3drendering/alphablending/vertexalpha.asp
that states:
To enable vertex alpha, set the device's render state RenderStates.DiffuseMaterialSource to ColorSource.Color1 so that the Microsoft® Direct3D® runtime takes the diffuse value from the diffuse color rather than the material.

Obviously, this is not something you can do in Blitz past EntityFX, but as I mentioned I'm trying to get it working in certain other engines as well.

What I'm really asking is :
a) Is there a way I can force DX (generally) into activating this render state for the given mesh by putting something in my .x file?
b) If not, what is the workaround? I'm pretty sure FredBorg has done it in Gile[s], so perhaps he might comment :) :) :)
c) If somebody could post (or send me) an ASCII .x mesh exported from Gile[s] that I can study that would be great - a single triangle would be ideal, provided it has vertex alpha on at least one vert.

I tried Ultimate Unwrap. It DOES export the alpha values, just like my exporter. And just like my exporter they don't show up :( This single glitch has cost me days.


Dreamora(Posted 2004) [#2]
1) Nope renderstates are engine specific

2)workaround: you have to load the X yourself and assign the vertex alpha on loading. Fredborg is doing this as far as i know from change list since I own it ( 1.0X ) because the standard x loader was quite destructive

c) ??? did you perhaps mix up with B3D export which supports this?


it seems as most engines don't support vertex alpha from X
Are you sure that the color is ARGB for vertex and not RGB? can't remember 4 color values there in dx sdk


Skitchy(Posted 2004) [#3]
Yes, its definitely RGBA. Check that link above.
I thought Gile[s] could export .x but I may be wrong.

Some guy said he'd exported a .B3D from ALE, loaded into Gile[s], exported to .x, and loaded into another engine - so I assumed it worked. ;)

Thanks for the reply :)


Dreamora(Posted 2004) [#4]
Yes Gile[s] can export x

If I find some sample where I use vertex alpha I'll put it online.

btw: do you have some sample X lines for the MeshVertexColor section where you set the RGBA?


Skitchy(Posted 2004) [#5]
Sure. This is a 2 poly plane exported from Ultimate Unwrap. I've used this as a 'template' for my own exporter (to make sure all the segments and ';' are in the right place with the right numbers. I can't post one from my own exporter because they're about 50,000 lines long! ;)
Specifically, look at the MeshVertexColors{} section. The values are :

{
Total_verts;
Vert_ID; Red; Green; Blue; Alpha;,
Vert_ID; Red; Green; Blue; Alpha;,
etc.
}

All values are 0.0 -> 1.0

Frame Body {
   FrameTransformMatrix {
    1.000000, 0.000000, 0.000000, 0.000000,
    0.000000, 1.000000, 0.000000, 0.000000,
    0.000000, 0.000000, 1.000000, 0.000000,
    0.000000, 0.000000, 0.000000, 1.000000;;
   }

   Mesh staticMesh {
    4;
    -2.000000; -0.000000; -2.000000;,
    -2.000000; 0.000000; 2.000000;,
    2.000000; -0.000000; -2.000000;,
    2.000000; 0.000000; 2.000000;;
    2;
    3;0, 1, 2;,
    3;1, 3, 2;;

   MeshNormals {
    4;
    0.000000; 1.000000; -0.000000;,
    0.000000; 1.000000; -0.000000;,
    0.000000; 1.000000; -0.000000;,
    0.000000; 1.000000; -0.000000;;
    2;
    3;0, 1, 2;,
    3;1, 3, 2;;
   }

   MeshTextureCoords {
    4;
    0.000000; 0.000000;,
    0.000000; 1.000000;,
    1.000000; 0.000000;,
    1.000000; 1.000000;;
   }

   MeshVertexColors {
    4;
    0; 1.000000; 1.000000; 1.000000; 1.000000;,
    1; 1.000000; 1.000000; 1.000000; 1.000000;,
    2; 1.000000; 1.000000; 1.000000; 1.000000;,
    3; 1.000000; 1.000000; 1.000000; 1.000000;;
   }

   MeshMaterialList {
    1;
    2;
    0,
    0;

    Material {
     1.000000; 1.000000; 1.000000; 1.000000;;
     128.000000;
     0.000000; 0.000000; 0.000000;;
     0.000000; 0.000000; 0.000000;;
    }

   }
  }
}


Like I said, I know without a doubt that the data is getting into the engine(s) because the vert colors are set correctly.
Just that pesky alpha ;)


Dreamora(Posted 2004) [#6]
it might be that they only support material or alpha