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
2 registered members (vicknick, AndrewAMD), 1,292 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: toon shader (post processing) [Re: xXxGuitar511] #152090
09/06/07 16:59
09/06/07 16:59
Joined: Apr 2006
Posts: 136
San Francisco
T
Tor Offline
Member
Tor  Offline
Member
T

Joined: Apr 2006
Posts: 136
San Francisco
According to the book I have on HLSL, you can make if statements all you want. However, most shader models can only support static branching (if you had a bunch of bools that go into the function this would be ok, as it would cause those branches to NOT execute).

However, only shader model 3.0 has true dynamic branching, all the other models just end up having both the if and else executed and the shader chosing the part you wanted. So in effect, it is not giving you a performance boost in the same way regular code would if you blocked it off with an if.

This is the real difference between optimizing shaders and optimizing regular code.

and xXxGuitar511; totally valid, I failed to realize that he was making a global effect. It should definately be a local material per mesh. That would make the effect significantly easier.


"Towlie, you're the worst character ever." I know...
Re: toon shader (post processing) [Re: Tor] #152091
09/06/07 17:38
09/06/07 17:38
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
well, some time ago i created this shader (postprocess) which wouldnt be possible on a per model base:


imagine you want your whole scene toon like, but u use standard shaders (normal mapping, reflections and others) per model and in the end you give the whole scene a toon touch. thats a case of postprocessing

Re: toon shader (post processing) [Re: ello] #152092
09/12/07 23:56
09/12/07 23:56
Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
openfire2691 Offline OP
Junior Member
openfire2691  Offline OP
Junior Member

Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
Okay, so would I still be able to calculate the dot product with a post-processing effect? Maybe with a vertex shader?


When your script isn't working right, usually it's because it's doing exactly what you told it to. -An Unknown Programmer
Re: toon shader (post processing) [Re: openfire2691] #152093
09/13/07 04:45
09/13/07 04:45
Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
openfire2691 Offline OP
Junior Member
openfire2691  Offline OP
Junior Member

Joined: Sep 2006
Posts: 74
Northwestern Oregon, United St...
Wait! I finally got the right equation! I was trying to change only the red green or blue value based on how much of each was present, but I needed to multiply them all by one universal fraction! Here's my results (by the way I wasn't really looking for an outline):


And the code:

Code:
 material mat_rgb 
{
effect = "
sampler2D g_samSrcColor;

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;
int Color_all;
float multiplyer;
Color = tex2D( g_samSrcColor, Tex.xy);
Color_all = ((Color.r + Color.g + Color.b)/3)/.167;
multiplyer = (Color_all * .167)/((Color.r + Color.g + Color.b)/3);
Color.r = (Color.r * multiplyer);
Color.g = (Color.g * multiplyer);
Color.b = (Color.b * multiplyer);
return Color;
}


technique PostProcess
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_2_0 MyShader();
}

}
";
}




When your script isn't working right, usually it's because it's doing exactly what you told it to. -An Unknown Programmer
Page 2 of 2 1 2

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