MeshVertexColor(Color) No Alpha

Everything related to 3D programming
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

MeshVertexColor(Color) No Alpha

Post 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
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: MeshVertexColor(Color) No Alpha

Post 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
			}
		}
	}
}
Please correct my english
http://purebasic.developpez.com/
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: MeshVertexColor(Color) No Alpha

Post 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
Last edited by Thade on Mon Oct 15, 2012 11:37 am, edited 1 time in total.
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: MeshVertexColor(Color) No Alpha

Post 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)
Please correct my english
http://purebasic.developpez.com/
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: MeshVertexColor(Color) No Alpha

Post 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 ...
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
Thade
Enthusiast
Enthusiast
Posts: 266
Joined: Sun Aug 03, 2003 12:06 am
Location: Austria

Re: MeshVertexColor(Color) No Alpha

Post 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?
--------------
Yes, its an Irish Wolfhound.
Height: 107 cm; Weight: 88 kg
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: MeshVertexColor(Color) No Alpha

Post 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.
Please correct my english
http://purebasic.developpez.com/
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: MeshVertexColor(Color) No Alpha

Post 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. :?
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: MeshVertexColor(Color) No Alpha

Post 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
Please correct my english
http://purebasic.developpez.com/
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: MeshVertexColor(Color) No Alpha

Post 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.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: MeshVertexColor(Color) No Alpha

Post by Fred »

Yes, he works on the 3D side, doing an amazing job :)
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: MeshVertexColor(Color) No Alpha

Post by Olby »

Yassss, now I know where to send off my 3D requests!! Well done Comtois :)
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Lexicon
User
User
Posts: 98
Joined: Mon Jul 22, 2013 6:16 am
Contact:

Re: MeshVertexColor(Color) No Alpha

Post 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?.. :(
PureBasic 5.11 | WinXP | 2GB RAM | GForce GT240
Post Reply