Page 1 of 1

MeshVertexColor(Color) No Alpha

Posted: Sun Oct 14, 2012 2:22 am
by Thade
Hi

MeshVertexColor(Color)

Docs:
Color of the vertex. This color can be in RGB or RGBA format

Alpha in RGBA has no effect (is always 255). RGB works as it should.

Code: Select all

Procedure CreateText3D(Text.s, Material, Color, Color2= $FFFFFFFF)
	Protected Mesh
	Mesh=CreateMesh(-1)
	For i=0 To Len(Text)-1
		c=Asc(Mid(Text, i+1, 1))
		cu=c & 15
		cv=c >> 4
		cuf.f=0.0625 * cu
		cvf.f=0.125 * cv
		AddMeshVertex(-0.5+i, 0.5, 0)
		MeshVertexTextureCoordinate(cuf, cvf)
		MeshVertexColor(Color)
		AddMeshVertex(0.5+i, 0.5, 0)
		MeshVertexTextureCoordinate(cuf+0.0625, cvf)
		MeshVertexColor(Color)
		AddMeshVertex(-0.5+i, -0.5, 0)
		MeshVertexTextureCoordinate(cuf, cvf+0.125)
		MeshVertexColor(Color2)
		AddMeshVertex(0.5+i, -0.5, 0)
		MeshVertexTextureCoordinate(cuf+0.0625, cvf+0.125)
		MeshVertexColor(Color2)
		AddMeshFace(i*4+0, i*4+2, i*4+1)
		AddMeshFace(i*4+1, i*4+2, i*4+3)
	Next
	FinishMesh()
	NormalizeMesh(Mesh)
	MaterialBlendingMode(Material, #PB_Material_AlphaBlend)
	MaterialAmbientColor(Material, #PB_Material_AmbientColors)
	SetMeshMaterial(Mesh, MaterialID(Material))
	Entity=CreateEntity(-1, MeshID(Mesh), MaterialID(Material))
	FreeMesh(Mesh)
	ProcedureReturn Entity
EndProcedure
Material is a Texture Font.Png 1024x1024 with white Chars and transparent background - Chars: 0 - 127 (0 - 31 empty)
Edit: Uploaded the Font Texture http://www.RRSoftware.net/uploads/Forum ... shadow.png

Code: Select all

Cam1=CreateCamera(-1, 0, 0, 100, 100)
At Initialising


Code: Select all

	Text.s = StrF(Engine3DFrameRate(#PB_Engine3D_Current),2)
	If OldText.s<>Text
		DeleteText3D(Entity1)
		Entity1=CreateText3D(Text.s, FontMaterial1, RGBA(255,0,0,255), RGBA(255,255,0,255))
		EntityLocate(Entity1, 0, 60, 300)
		ScaleEntity(Entity1, 10, 40, 10)
		OldText=Text
	EndIf
	Text2.s = Str(Zlr)
	If OldText2.s<>Text2
		DeleteText3D(Entity2)
		Entity2=CreateText3D(Text2.s, FontMaterial1, RGBA(255,0,0,127), RGBA(255,255,0,127))
		EntityLocate(Entity2, 0, 20, 300)
		ScaleEntity(Entity2, 10, 40, 10)
		OldText2=Text2
	EndIf
	Zlr+1

    CameraLocate(Cam1, 0, 100, 600)
    CameraLookAt(Cam1, EntityX(Entity1), EntityY(Entity1), EntityZ(Entity1))
 
Put this inside any 3DDemo into the Main Loop

RR

Re: MeshVertexColor(Color) No Alpha

Posted: Sun Oct 14, 2012 7:20 pm
by Comtois
MeshVertexColor(Color) work fine. the bug is in MaterialBlendingMode().

Should work with this materialScript

Code: Select all

material MyMaterial
{
	technique
	{
		pass
		{
			lighting off
			scene_blend alpha_blend
			depth_write off

			texture_unit
			{
				texture arial_blackshadow.png
			}
		}
	}
}

Re: MeshVertexColor(Color) No Alpha

Posted: Sun Oct 14, 2012 9:52 pm
by Thade
Hi Comtois

No - this works on the complete Background of each surface - or the Colors are not displayed (Chars are only white) - Maybe I do something wrong - but changing commands and parameters show different results - none of them shows the wanted one.

Anyway - my expierience with 10 years Blitz3D Background tells me:
MeshVertexColor() does NOT work as it should. It colors the vertices as expected but does NOT make them semitransparent as it should happen. 50 other engines would do exact this right!
And MaterialBlendingMode() seems to be okay - because it makes the background transparent as expected.

Edited:
A Material script is by far not versatile enough ... Obviously wrong as Comtois shows below ...


RR

Re: MeshVertexColor(Color) No Alpha

Posted: Sun Oct 14, 2012 10:21 pm
by Comtois
using the script, I get this
Image

this is not the expected result?

Before testing with script, have you commented these lines ?

Code: Select all

   ;MaterialBlendingMode(Material, #PB_Material_AlphaBlend)
   ;MaterialAmbientColor(Material, #PB_Material_AmbientColors)

Re: MeshVertexColor(Color) No Alpha

Posted: Mon Oct 15, 2012 11:36 am
by Thade
Looks as I expected it - obviously my fault - I made something wrong in my code.

Have to make it better net time :)

Comtois wrote:using the script, I get this

Before testing with script, have you commented these lines ?

Code: Select all

   ;MaterialBlendingMode(Material, #PB_Material_AlphaBlend)
   ;MaterialAmbientColor(Material, #PB_Material_AmbientColors)
Yes I did - but obviously made a mistake assigning the Material to the entity ...

Re: MeshVertexColor(Color) No Alpha

Posted: Mon Oct 15, 2012 1:58 pm
by Thade
Thank you for your help, Comtois - now it's working fine. The results are identical now :D

Is it nessessary to destroy the mesh and build a new mesh each time the Text changes? There's no chance to manipulate surfaces and vertices in an existing entity build from a mesh, right? Or did I miss something in the manual?

Re: MeshVertexColor(Color) No Alpha

Posted: Mon Oct 15, 2012 5:54 pm
by Comtois
Thade wrote:There's no chance to manipulate surfaces and vertices in an existing entity build from a mesh, right?
It's on my TodoList.

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Oct 16, 2012 12:39 pm
by Olby
Thade wrote:There's no chance to manipulate surfaces and vertices in an existing entity build from a mesh, right? Or did I miss something in the manual?
Yup, I would like to do that as well. Quite a hassle now. :?

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Oct 16, 2012 3:39 pm
by Comtois
Olby wrote:
Thade wrote:There's no chance to manipulate surfaces and vertices in an existing entity build from a mesh, right? Or did I miss something in the manual?
Yup, I would like to do that as well. Quite a hassle now. :?
It's on the top of my toDo List :)

MaterialBlendingMode() is fixed

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Oct 16, 2012 3:50 pm
by Olby
Comtois wrote:
Olby wrote:
Thade wrote:There's no chance to manipulate surfaces and vertices in an existing entity build from a mesh, right? Or did I miss something in the manual?
Yup, I would like to do that as well. Quite a hassle now. :?
It's on the top of my toDo List :)

MaterialBlendingMode() is fixed
Are you working on PB, didn't know that.

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Oct 16, 2012 4:03 pm
by Fred
Yes, he works on the 3D side, doing an amazing job :)

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Oct 16, 2012 4:13 pm
by Olby
Yassss, now I know where to send off my 3D requests!! Well done Comtois :)

Re: MeshVertexColor(Color) No Alpha

Posted: Tue Dec 03, 2013 12:30 pm
by Lexicon
Hi!

Can I use MeshVertexColor without disable lightning? I need to colored my terrain but I can't change ambient light and fog's color. Also, how can I make evening, night, morning in my game without lightning?.. :(