Vertex Colors?
Blitz3D Forums/Blitz3D Programming/Vertex Colors?
| ||
Can someone explain what vertex colors are and how they are used in Blitz3d? |
| ||
Basicly a vertex has several properties X#,Y#,Z# coordinates U#,V# coordinates R%,G%,B%,A# You can modify each vertex color (R,G,B) and transparency (Alpha) once you know in which surface it is and its index. See the command VertexColor : http://blitzbasic.com/b3ddocs/command.php?name=VertexColor&ref=goto The advantage of using vertex colors instead of several surfaces + several brushes is to be able to reduce the surfaces count and also to create nice shades on triangles. |
| ||
Changing the color of a vertex will affect the shading of the mesh - texels on any polygon that shares that vertex will be shaded by the vertex color depending on their distance from and the colors of any other vertex they are also connected to. One possible use (tho usually done in B3D via entitycolor or similiar commands) is to highlight a selected object. |
| ||
I don't like my tone from when I was younger (far too arrogant), but you can read these posts I made about vertex coloring. http://blitzbasic.com/Community/posts.php?topic=89327 http://blitzbasic.com/Community/posts.php?topic=90523 http://blitzbasic.com/Community/posts.php?topic=88742#1083849 By far the most unexplored vertex color trick is vertex alpha... you can make some pretty interesting transparency effects with vertex alpha: light cones, ghosts etc. |
| ||
Is there any hands-on example I can perhaps see? The effect is wonderful, and I'd love to see it in action. In case you're thinking that I'll just take the example and walk out the door without learning a thing, I've actually changed quite a bit from my earlier days in the blitz community. I have a desire to learn, not steal. |
| ||
Well, there's not much to it. You'd apply a vertex's color (including alpha) either by code or by a painting tool in your modelling application (latter preferable, since it's more intuitive and allows for tweaks). Can you think of a specific use you'd have for vertex alpha in your game? any visual effect that might use smooth transparency of meshes? |
| ||
Something whipped up in five minutes.Graphics3D 800,600,0,2 camera=CreateCamera() light=CreateLight(2) MoveEntity light,10,10,10 pivot=CreatePivot() EntityParent light,pivot cube=CreateSphere(64) EntityFX cube,2 MoveEntity cube,0,0,4 Repeat For s=1 To CountSurfaces(cube) surf = GetSurface(cube,s) For v = 0 To CountVertices(surf) - 1 TFormPoint VertexX(surf,v),VertexY(surf,v),VertexZ(surf,v),cube,pivot VertexColor surf,v,128+TFormedY()*127.0,128+TFormedZ()*127,128+TFormedX()*127.0 Next Next UpdateNormals cube TurnEntity pivot,1,1.5,1.2 TurnEntity cube,.1,.2,.3 RenderWorld Flip Until KeyDown(1) End |