[REQ] Damaged VHS & Analog TV Effects

share shaders here
  • Author
  • Message
Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [REQ] Damaged VHS & Analog TV Effects

Challenge Accepted!!
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: [REQ] Damaged VHS & Analog TV Effects

Can't wait to see what you come up with! I coded some scanlines as part of my Enhanced ENB Night Vision mod.

Global:

Code: Select all

#define ENABLE_SCANLINES

	// Scanlines
	#ifdef ENABLE_SCANLINES
		bool EENV_scanlinesEnable <
			string UIName = "EENV Scanlines Enable";
		> = {true};
		bool EENV_scanlinesWarp <
			string UIName = "EENV Scanlines Warp";
		> = {true};
		float EENV_scanlinesFrequency
		<
			string UIName="EENV Scanlines Frequency";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=5000.0;
		> = {1000.0};
		float EENV_scanlinesSpeed
		<
			string UIName="EENV Scanlines Speed";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=100.0;
		> = {50.0};
		bool EENV_ScannerLinesEnable <
			string UIName = "EENV Scanner Lines Enable";
		> = {true};
		int EENV_ScannerLinesNum <
			string UIName="EENV Scanner Lines Number";
			string UIWidget="Spinner";
			int UIMin = 1;
			int UIMax = 10;
		> = {2};
		float EENV_ScannerLinesIntensity
		<
			string UIName="EENV Scanner Lines Intensity";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=1000.0;
		> = {50.0};
		float EENV_ScannerLinesDistance
		<
			string UIName="EENV Scanner Lines Distance";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=10.0;
		> = {0.1};
		float EENV_ScannerLinesDistancePower
		<
			string UIName="EENV Scanner Lines Distance Power";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=500.0;
		> = {20.0};
		float EENV_ScannerLinesSpeed
		<
			string UIName="EENV Scanner Lines Speed";
			string UIWidget="Spinner";
			float UIMin=0.0;
			float UIMax=500.0;
		> = {10.0};
	#endif // ENABLE_SCANLINES
In Pixel shader:

Code: Select all

			// Scanlines and Scanner Lines
			float scanlinesPattern = 0.0;
			float scannerLinesPattern = 0.0;
			#ifdef ENABLE_SCANLINES
				float2 scanLineCoords = IN.txcoord0;
				if (EENV_scanlinesWarp) scanLineCoords = _v0;
				if (EENV_scanlinesEnable)
				{
					scanlinesPattern = 0.5 + 0.5 * cos((scanLineCoords.y * EENV_scanlinesFrequency) + EENV_scanlinesSpeed * Timer.x * 10000.0);
				}
				if (EENV_ScannerLinesEnable)
				{
					const float offsets[10] = {0.0, 0.342, 0.5231, 0.632, 0.872, 0.2314, 0.4542, 0.75643, 0.93231, 1.0};
					const float speeds[10] = {0.214, 0.342, 0.5231, 0.632, 0.872, .1243, .721, 0.666, 0.151, 0.434};
					for (int i = 0; i < EENV_ScannerLinesNum; i++)
					{
						float linePosition = 0.5 + 0.5 * cos(offsets[i] + EENV_ScannerLinesSpeed * Timer.x * 5000.0 * speeds[i]);
						float dist = abs(scanLineCoords.y - linePosition);
						scannerLinesPattern += EENV_ScannerLinesIntensity * 
							pow(1.0 - EENV_linStep(0.0, EENV_ScannerLinesDistance, dist), EENV_ScannerLinesDistancePower);
					}
				}
			#endif // ENABLE_SCANLINES
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [REQ] Damaged VHS & Analog TV Effects

Isn't "EENV_linStep" one of your functions? You should include it, too, otherwise users won't be able to use it.

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: [REQ] Damaged VHS & Analog TV Effects

Thanks, I overlooked that:

Code: Select all

float EENE_linStep(float minVal, float maxVal, float t)
{
	return saturate((t - minVal) / (maxVal - minVal));
}
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7
Post Reply