Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 907 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
fade material's skin in/out #449136
03/05/15 10:44
03/05/15 10:44
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I've found a postprocessing shader (I guess it was made by Emre), which blinks the view, adds noise effect and so on.
I tried to remove everything (all effects), but to leave the noise effect, and I guess I've done it correctly, here the .fx:
Code:
texture TargetMap;
texture mtlSkin1;

float4 vecTime;

float noiseSize = 0.9f;

sampler View_Tex = sampler_state {
	texture = <TargetMap>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;  
	AddressU = Clamp;
	AddressV = Clamp;
};

sampler Noise_Tex = sampler_state {
	texture = <mtlSkin1>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;  
	AddressU = wrap;
	AddressV = wrap;
};

float4 Noise_Effect_PS( float2 Tex : TEXCOORD0 ) : COLOR {
	
	float4 Color = float4(1, 1, 1, 1);
	
	Tex.y = Tex.y + 0.05 * 0.01 * cos(vecTime.w);
	
	float4 CAMERA_VIEW = tex2D(View_Tex, Tex);
	
	float4 NOISE_EFFECT = tex2D(Noise_Tex, float3(2 * Tex * noiseSize + vecTime.w, 1)) + 0.5 * tex2D(Noise_Tex, float3(1.05 * Tex * noiseSize - vecTime.w, 1)) + 0.1;

	Color *= CAMERA_VIEW;
	Color *= NOISE_EFFECT;

	return(Color);
}

technique Noise_Effect
{
	pass one
	{
		PixelShader = compile ps_2_0 Noise_Effect_PS();
	}
}

But now, when I've ripped it out, I wanted to know, how to make the skin (Noise_Tex) fade in and out, when I need it to. So f.e. when I walk close up to something in my game, the noise effect will increase, and when I walk away then it should decrease... I'm pretty sure, that this is a very simple task, but I would really appreciate some advice or help (maybe there is a better way to archive what I'm looking for, I'm open for suggestions, I've tried example made by Slin which uses panels, but I didn't like it, so I guess I won't go panels way).

Thanks in advance! And best regards.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: fade material's skin in/out [Re: 3run] #449137
03/05/15 10:53
03/05/15 10:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Create a var variable (fade_progress) in your script which handles the fade in/ out stuff, then write
float fade_progress_var;
at the beginning of your fx file.
Now put
NOISE_EFFECT = lerp(NOISE_EFFECT,1,fade_progress);
before the Color *= NOISE_EFFECT line.

I assume that fade_progress is in 0..1, otherwise (if you want to keep it in the interval 0..100) write (fade_progress/100) as the 3rd argument in lerp.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: fade material's skin in/out [Re: Superku] #449140
03/05/15 14:45
03/05/15 14:45
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Works great, thank you very much!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

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