Blending

Started by
9 comments, last by OrangyTang 17 years, 9 months ago
I'm using OpenLayer, but my problem lies within OpenGL blenders.

Light.BlitTransformed(x, y, 600, 600, 50, 50, 0.0, Tinted(Rgba(1.0, 1.0, 1.0, 1.0)), 1.0);
Light.BlitTransformed(200, 200, 200, 200, 50, 50, 0.0, Tinted(Rgba(0.5, 1.0, 0.5, 1.0)), 1.0);
	
Blenders::Set(GL_SRC_ALPHA_SATURATE, GL_SRC_COLOR);
	Map[MAPID]->Draw();
Blenders::Set(GL_SRC_COLOR, GL_SRC_COLOR);
	Bmp->Blit(SCREEN_W/2, SCREEN_H/2, 1.0);
Blenders::Set(ALPHA_BLENDER);


As you can see, the "character" is fully lit, while there is no "light" nearby. Is there any specific blender combination that would make the bitmap fade when outside a light source's range?
Advertisement
try glBlend( GL_DST_COLOR, ..... );
Light.BlitTransformed(x, y, 600, 600, 50, 50, 0.0, Tinted(Rgba(1.0, 1.0, 1.0, 1.0)), 1.0);Light.BlitTransformed(200, 200, 200, 200, 50, 50, 0.0, Tinted(Rgba(0.5, 1.0, 0.5, 1.0)), 1.0);Blenders::Set(GL_SRC_ALPHA_SATURATE, GL_SRC_COLOR);	Map[MAPID]->Draw();Blenders::Set(GL_DST_COLOR, GL_ONE);	Bmp->Blit(SCREEN_W/2, SCREEN_H/2, 1.0);Blenders::Set(ALPHA_BLENDER);

It did help... a little, but it's still not what I've been hoping for.

The image fades when outside of a light radius, but when it's inside, it becomes translucent.
Try GL_ZERO instead of GL_ONE in the Blenders::Set(GL_DST_COLOR, GL_ONE); call.

BTW, I've tried all of them, nothing seems to be working. Halfway translucent image is the best I can get.
Quote:Original post by CursedTyrant

BTW, I've tried all of them, nothing seems to be working. Halfway translucent image is the best I can get.


What kind of texture you are using for that ? Does it have alpha layer ?
Bmp = new Bitmap("data/players/0.png", "data/players/0a.png")

0a.png is the alpha mask.
Quote:Original post by CursedTyrant
Bmp = new Bitmap("data/players/0.png", "data/players/0a.png")

0a.png is the alpha mask.


Ok I am not familiar with openLayer, but why you need 2 images ? The alpha of png can be saved within the first image. Anyway if you are loading them right, try to check that the images and especially alpha image has correct alpha mask.
I am loading them right, and they do have a correct alpha mask. If I don't use blenders, the image looks fine.
So... any particular way that would help me solve this problem? I really could use that type of lighting in my game.

This topic is closed to new replies.

Advertisement