The way game programmers draw figures

Started by
38 comments, last by wiseman303 19 years, 1 month ago
could you just post a screen shot or something? words are so old fashioned.

I don't understand why you're using a mask color if you could just use an alpha channel.

the bottom line is that you can't use a color mask with a filter because it will slighly offset your mask color as I explained before.
Advertisement
I am using an alpha channel. Before I create the texture I loop through the HBITMAP bits and set all alpha components to 0 that are the pink color.
*C++*->
Oh I understand the problem now, the colour of the transparent pixels is leeching into the opaque pixels. There was an article on the virtual terrain project about this.

http://www.vterrain.org/Plants/Alpha/index.html

When you loop through the pixels setting the pink ones alpha to 0, also set the RGB values for that pixel to 0 (you'll get a black outline, but it's better than pink.)

Another thing you could try is, after setting the alpha values, while there are still pink pixels in the image, set each one's colour to the average of it's (non pink) neighbors. That should remove almost all outline or halo effect.
______________________________________________There are only 10 types of people in the world: Those who understand binary, and those who don't.
wiseman is wise. You understand. Looping will just cause the image to be blocky around the edges instead of pink. But if opengl did the same with the looping except setting those values to the values of what is behind the image then this would be solved. But it does not look like Ogl does that. That's real sad because I made a linear stretch that does that and it was not hard to do.

If I can do it, why can't opengl do it? Does DirectX or Direct3-D have this same problem?
*C++*->
ok its clear from the screenshots whats happening.
as wiseman saiz 'When you loop through the pixels setting the pink ones alpha to 0'
on a related theme
r u using mipmapping, if so this is also gonna happen but even worse, eg mipmap level 0 has 2 pixels by each other rgba 1,0,0,1 and 0,0,0,0 now u drop down a mipmap level (2 pixels become 1 (actually 4become but nevermind) then u will get the average of those pixels ie 0.5,0,0,0.5. the solution is to make all the mipmap level s in an art program yourself or with an algorithm glubuildmipmaps or GL_GENERATE_MIPMAP will not work
Not using mipmapping at all. Thanks everyone. I just don't think ogl was set up for this. Does DirectX do this the way I want or is it the same deal?
*C++*->
d3d does it exactly the same way as opengl
You know, aewarnick, timmie posted the solution to your problem on the first page. Just reread his post, he might not have put up huge billboards explaining what goes on, but he definitely has the right idea.

cu,
Prefect
Widelands - laid back, free software strategy
Thanks zedzeek, thats refreshing.
Perfect, You're right. I tried it out and the results please me.
But it is not the way Gdiplus does it. That is what I was comparing everything to. It works well though. Thanks.
*C++*->
The looping to eliminate the pink texels is done in a preprocessing phase, at the same time the alpha for those texels is set to 0. This will eliminate the halo but still allow you to use smooth blended edges when rendering.

If you turn off blending and look at your linear filtered texture, you'll see the pink "bleeding" into the other colours around the edges. Because the alpha is also being interpolated, those not-quite-pink pixels are also not fully transparent, so their pinkish colour gets blended with the background, giving the pink halo.

If you preprocess the texture to recolour the pink texels at the time you set the alpha values, then instead of blending between pink and the colour of the opaque pixel when you render, you'll get blending between the opaque pixel and a colour closely matching the opaque pixel, which elliminates the visible outline or "halo" effect.
______________________________________________There are only 10 types of people in the world: Those who understand binary, and those who don't.

This topic is closed to new replies.

Advertisement