Page 1 of 1

Vertex Alpha Issue

Posted: Sat May 27, 2006 9:54 pm
by EzikialBasix
Hey I finally got my class working as it should, except for one problem. I have a Skycone with the color gradient depending on the time of day. I also have a star sphere in the back with a star texture on it. I'm trying to make portions of the cone transparent at night (except the horizon) but it doesnt work.

Ive tried EMT_TRANSPARENT_ADD_COLOR and I've tried VERTEX_ALPHA but to no luck.


Day Time (incorrect.. you can see stars ):
Image


Night Time ( YOU CAN"T SEE STARS QQ ):
Image


It really doesnt make sense to me. I've tried loading the Image from a PNG and a BMP.. PNG with transparency doesnt work.. and BMP with black areas and ADD_COLOR wont work. I don't know what im doing wrong.


Basically Im loading an IImage with 16x16 color data for each row of vertices in my skydome. The colors work fine, but not the transparency portions.


Heres the code for it.

Code: Select all

void ESphere::SkyTransform(irr::s32 shiftFactor)
{
	irr::scene::IMesh *mesh = m->getMesh(m->getFrameCount() - 1);
	
	int vertCount = mesh->getMeshBuffer(0)->getVertexCount();
	void* v = mesh->getMeshBuffer(0)->getVertices();
	irr::f32 temp;

	// Get all of the vertices heights
	float *vertList = new float[vertCount];
	for(int a = 0; a < vertCount; a++)
	{
		temp = ((irr::video::S3DVertex*)v)[a].Pos.Y;
		vertList[a] = (float)temp;
	}

	// Sort the vertices from least to greatest
	std::sort(vertList + 0, vertList + (vertCount - 1));

	// Map vertices from 0 to 1
	float *vertMap = new float[vertCount];
	float MaxVert = vertList[vertCount - 1];

	for(int a = 0; a < vertCount; a++)
	{
		vertMap[a] = vertList[a] / MaxVert;
	}

	// Set Fog Color
	device->getVideoDriver()->setFog(skyimage->getPixel(shiftFactor, 15), true, 8000, 100000, 0, true);

	// Assign Color to heights
	for(int a = 0; a < vertCount; a+=4)
	{
		if(vertMap[a] <= 0)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp <= vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 15);
			}
		}

		if(vertMap[a] > 0)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 14);
			}
		}

		if(vertMap[a] > 0.1)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 12);
			}
		}

		if(vertMap[a] > 0.2)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 8);
			}
		}

		if(vertMap[a] > 0.3)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 6);
			}
		}

		if(vertMap[a] > 0.4)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 5);
			}
		}

		if(vertMap[a] > 0.5)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 4);
			}
		}

		if(vertMap[a] > 0.6)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 3);
			}
		}

		if(vertMap[a] > 0.7)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 2);
			}
		}

		if(vertMap[a] > 0.8)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 1);
			}
		}

		if(vertMap[a] > 0.9)
		{
			for(int b = 0; b < vertCount; b++)
			{
				temp = ((irr::video::S3DVertex*)v)[b].Pos.Y;
				if(temp == vertList[a])
					((irr::video::S3DVertex*)v)[b].Color = skyimage->getPixel(shiftFactor, 0);
			}
		}
	}

	delete [] vertList;
	delete [] vertMap;
}
:( :(

Posted: Thu Nov 09, 2006 11:19 pm
by dloomis
Have you tried inverting your alphas?