| Author | Topics » Book an abo for this thread |  |
ShadX  Real addict
  

Status:Offline Date registered: 20.01.2005 Post:266 Send Message | Created on 22.04.2005 - 15:03 |  |
I have had an idea of how to eliminating the black borders when you enable bilinear filtering, studying NEHE Lesson 20 tutorial: nehe.gamedev.net/data/lessons/lesson.asp?lesson=20 The texture mask can be easily obtained from PSX texture with a simple filter (invert the "trasparent" black R0G0B0A0 to white and all other colors to black). The result is similar to what it happens on PS2 when you activate the bilinear filterig with the PSX games: the border become semi-trasparent. Pete, what do you think about? Bye
[Dieser Beitrag wurde am 25.04.2005 - 11:30 von ShadX aktualisiert]
|
PeteBernert Admin
    

Status:Offline Date registered: 04.10.2003 Post:818 Send Message | Created on 23.04.2005 - 10:28 |  |
while the basic idea ("how to do something like an alpha-test without texture alpha values" ) is nice (and, of course, it has certain disadvantages), it will not help very much with the "black border" problem.
First, there are two general "border" issues when texture filtering is enabled in psx emulation:
1) the general color interpolation problem:
example:
the original (not filtered) psx texture is something like that:
BBBBBBBBB BBBBXBBBB BBBXXXBBB BBXXXXXBB BXXXXXXXB BBBBBBBBB
B=Black (in texture, transparent while drawn), X=some color
now you activate filtering, and the gfx card hardware will interpolate the texel colors while drawing:
BBBBBBBBB BBBBGBBBB BBBGXGBBB BBGXXXGBB BGGGGGGGB BBBBBBBBB Those "G"'s are the interpolated colors of the real texture color (the one you want to see) and the surrounding Black (transparent) colors. The "G"s will not be exactly black, but in the final drawing they will appear as some kind of dark color.
2) the background masking problem
Some games, like FF7, are having "background" gfx, and some "front" gfx, for example a table (front) before a kitchen (back). The main character can walk between the table and the background scene.
How is the background scene and the table done?
background (kitchen), A=some colors, B=solid black (not transparent!)
AAAAAAAAA AAABBBAAA AAAABAAAA AAAABAAAA AAAAAAAAA
Foreground table, X=Some color, B=Black (transparent)
XXX BXB BXB
Now the table will be dran on top of the background, without filtering no problem:
AAAAAAAAA AAAXXXAAA AAAAXAAAA AAAAXAAAA AAAAAAAAA
But if you do filtering, the shapes will be not 100% correct anymore, the solid black part of the background will be interpolated in the other bkg colors... tada, a black border around the table.
And both problems will also happen with the "mask transparency" trick.
[Dieser Beitrag wurde am 23.04.2005 - 10:28 von PeteBernert aktualisiert]
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 25.04.2005 - 11:11 |  |
Aye!
Is there a way that textures would get filtered with shader procedures but only textures in background.
Or that even custom shader writers could write separate shader procedures for the OGL2 plugin, like one shader for background (blur filtering for example) and another for the polygons (like for Cloud).
If this filtering would be applied on a "drawn" surface IMHO no dark borders would appear since there would be no transparency values present any more.
|
PeteBernert Admin
    

Status:Offline Date registered: 04.10.2003 Post:818 Send Message | Created on 25.04.2005 - 19:01 |  |
>Is there a way that textures would get filtered with >shader procedures but only textures in background.
no way.
Imagine thousants of textured triangles/quads each frame, all rendered from back to front. That's all info you will get.
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 25.04.2005 - 21:16 |  |
Like ole Sherlock said, when he drunk a little: "When you remove all the bad solutions there might be some good ones left. " 
Perhaps a dynamic dynamic weight-manging scaler would do the job. This means the transparent color is simply ignored in the interpolation and other neighbour or the central pixel would gain on weight and the weight-sum should stay 1.0. And then no HW filtering should be used, of course.
|
ShadX  Real addict
  

Status:Offline Date registered: 20.01.2005 Post:266 Send Message | Created on 26.04.2005 - 10:55 |  |
1) the general color interpolation problem: the mask is filtered too (it is a texture, not an alpha channel) and you can't see any black border with "external black" masking or "internal black" masking... 2) the background masking problem: masking is not required... glBlendFunc(GL_ONE, GL_ONE); Bye
[Dieser Beitrag wurde am 26.04.2005 - 13:33 von ShadX aktualisiert]
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 26.04.2005 - 16:56 |  |
I think a 2x no-interpolation scaler (there are some GPL out there) + a gaussian blur filter would do the job.
1.) scale the texture. 2.) Apply the gaussian filter and count the weight on current pixel. If the weight sum adds up for example 0.75, then divide the result color with 0.75 and the luminance doesen't get screwed up. 
|
PeteBernert Admin
    

Status:Offline Date registered: 04.10.2003 Post:818 Send Message | Created on 26.04.2005 - 19:10 |  |
ShadX,
>1. ... you can't see any black border ...
of course you get still small black borders, mask or no mask... even the NeHe tutorial will show those, simply replace the texture bitmaps with some plained colored ones (for example a solid blue BMP as background texture, and a pure red grid (+ black mask) as forground texture. You will see that the black areas will slightly bleed into the red areas because of the interpolation.
>2. ... masking not required ...
harharhar
guest, if you show me a shader which will do exact the same thing as the HW bilinear texture filtering (that means: not only a simple filter with orthogonal rectangles, but also with all shapes and sizes and texture coords), just without the alpha filtering, I will add it... but I don't think that you will be able to do such a "HW texture filtering replacement" shader, at least I have never seen one 
|
guest  Real addict
  

Status:Offline Date registered: 30.07.2004 Post:856 Send Message | Created on 26.04.2005 - 20:43 |  |
Standard filtering has "problems" in some cases. Therefore the textures might some help. 
I think the size + coordinates are known and some sort of SW filtering could be done (some people have fast 3GHz machines with radeon 9250 cards, for example).
So the idea would be to produce a pseudo-Z filter which would be applied on a Scale2x texture.
IMHO the filtering could be also done with GLSL.  But, as mentioned before, such processings may not go along with shader fullscreen filtering. 
[Dieser Beitrag wurde am 03.07.2005 - 14:54 von guest aktualisiert]
|
ShadX  Real addict
  

Status:Offline Date registered: 20.01.2005 Post:266 Send Message | Created on 27.04.2005 - 11:20 |  |
Pete, i have modified the nehe tutorial for testing your situations (1 & 2). I can't see any black borders... i can send you my source if you want... in my "stupid" example a cloud pass over the sun and rear an UFO... with "M" you can disable the masking and see the background. about 2) Sorry, I had badly understood your example... Bye P.S.: ">1. ... you can't see any black border ...
of course you get still small black borders, mask or no mask... even the NeHe tutorial will show those, simply replace the texture bitmaps with some plained colored ones (for example a solid blue BMP as background texture, and a pure red grid (+ black mask) as forground texture. You will see that the black areas will slightly bleed into the red areas because of the interpolation."
You will see that blu (background) will slightly blend into the red areas because the semi-transparent borders... if you use yellow background you will see a slightly orange (yellow + red) border... but I think that is better than a black (dark) border...
[Dieser Beitrag wurde am 27.04.2005 - 12:44 von ShadX aktualisiert]
|