Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 1 of 5 1 2 3 4 5
pixelshader for overlays without border seams #17217
09/20/03 00:13
09/20/03 00:13
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
i wrote a pixelshader which avoids the disadvantages of d3d_autotransparency.

you have to use a 32bit tga texture. all pixels with alpha values above 0.5 will be rendered completely opaque and all other pixels will be rendered completely transparent. it's possible to enable the z-buffer then, so you won't have any sorting errors!

currently it can't be used for sprites because shaders don't seem to work with them...

in my opinion it looks better than overlays looked in a5.24 because there are no jagged edges!

Code:
...

ZWriteEnable=true;
AlphaTestEnable=true;
...
PixelShader=
asm
{
ps.1.3
def c0,1,1,1,1
def c1,0,0,0,0
tex t0 // sample t0
mov r0,t0
cnd r0.a,r0.a,c0,c1 // if(r0.a>0.5){r0.a=1;}else{r0.a=0;}
mul r0.rgb,r0,v0 // modulate with diffuse vertex lighting
};



entities using this shader should have my.flare=off; and my.transparent=off; so that the engine won't unnecessarily sort them!

here is a screenshot:


Re: pixelshader for overlays without border seams [Re: ventilator] #17218
09/26/03 04:27
09/26/03 04:27
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
i found out that exactly the same can be done without a pixelshader!

Code:
material mat_vegetation

{
effect=
"
texture texSkin1;
dword mtlSkill1;
technique vegetation
{
pass p0
{
Texture[0]=<texSkin1>;

ZWriteEnable=true;
AlphaTestEnable=true;
AlphaRef=<mtlSkill1>;
AlphaFunc=greater;
//CullMode=none;

ColorArg1[0]=Texture;
ColorOp[0]=Modulate2x;
ColorArg2[0]=Diffuse;
}
}
";
}

starter mat_vegetation_init
{
...
mat_vegetation.skill1=pixel_for_vec(vector(127,0,0),0,8888);
}


this version even allows to adjust the threshold via the first value of the vector in the starter function!

Re: pixelshader for overlays without border seams [Re: ventilator] #17219
09/27/03 05:53
09/27/03 05:53
Joined: Jul 2003
Posts: 82
Southern California
lucidman Offline
Junior Member
lucidman  Offline
Junior Member

Joined: Jul 2003
Posts: 82
Southern California
Which version of A6 are you using to do this?



Vision is mind
Mind is emptiness
Empty is clear light
Clear light is union
Union is great bliss
Re: pixelshader for overlays without border seams [Re: lucidman] #17220
09/27/03 06:01
09/27/03 06:01
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
currently it does only work with the beta version. i guess the directx effects will be available in 6.2 commercial/pro!

Re: pixelshader for overlays without border seams [Re: ventilator] #17221
09/29/03 07:54
09/29/03 07:54
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
if you use this material for plant models it could be useful to enable double sided polygons. just add this line:

CullMode=none;

Re: pixelshader for overlays without border seams [Re: ventilator] #17222
10/01/03 08:00
10/01/03 08:00
Joined: Oct 2001
Posts: 678
Alabama
Cameron_Aycock Offline
Developer
Cameron_Aycock  Offline
Developer

Joined: Oct 2001
Posts: 678
Alabama
What type of FPS hit is there for 30-50 of these polys using this technique, vs normal overlays?


Popular media is the opiate of the masses. Think for yourself.
Re: pixelshader for overlays without border seams [Re: Cameron_Aycock] #17223
10/01/03 09:26
10/01/03 09:26
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
i haven't done any serious benchmarks yet but with enabled backface culling (which is also enabled with normal overlays) i haven't observed a performance hit. if two-sided polygons get used (CullMode=none;), the fps seem to drop a little. i have a meadow with 500 grass triangles and fps dropped from ~80 to ~72!

Re: pixelshader for overlays without border seams [Re: ventilator] #17224
12/04/03 16:00
12/04/03 16:00
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Question for ventilator.. do you have an idea how i could add this technique to my diff+spec shader? i have tried several methods.. with no success. If do an extra pass at the bieginngin with this fixed function code the alpha mask works wbut the subsequent passes are nullified. ANyone know how this stuff works.. multi passes and alpha blending etc?


Sphere Engine--the premier A6 graphics plugin.
Re: pixelshader for overlays without border seams [Re: Matt_Aufderheide] #17225
12/04/03 16:10
12/04/03 16:10
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
i don't have much experience with multipass rendering but you could try to add the cnd line

def c0,1,1,1,1
def c1,0,0,0,0
...
cnd r0.a,r0.a,c0,c1 // if(r0.a>0.5){r0.a=1;}else{r0.a=0;}

to both passes? (of course you have to modify it so that it uses the correct alphachannel in both passes...)

Re: pixelshader for overlays without border seams [Re: ventilator] #17226
12/04/03 16:48
12/04/03 16:48
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
hmm.. yes i think you're on the right track.. its sort of working.. now i have to figure out how the blending should be set up


Sphere Engine--the premier A6 graphics plugin.
Page 1 of 5 1 2 3 4 5

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1