Welcome, Guest.
Username: Password: Remember me

TOPIC: Simple Fog

Simple Fog 1 year 5 months ago #1

Depth based fog effect.

My first ever effect. A cheap fog effect that uses depth, multiplys it with a color (uses texture for the color), and does a screen operation over the image.

To change the fog color you need to change the color of the texture.

Feel free to modify, enhance or do whatever you want with this.

EXAMPLE

DOWNLOAD [r1]

DOWNLOAD [r2] (Uses RGB modifier instead of texture, thanks to NoMansReshade).
Last Edit: 1 year 5 months ago by fuze.
The administrator has disabled public write access.
The following user(s) said Thank You: Elimina, Insomnia, andrew, Gar Stazi

Simple Fog 1 year 5 months ago #2

Replaced texture with rbg modifier. Couldn't figure out how to change the distance of the fog, but:


#include "ReShade.fxh"

texture texColorBuffer : COLOR;
texture texDepthBuffer : DEPTH;
texture texFogColor < source = "FogColor.png"; > { Width = 16; Height = 16; Format = RGBA8; };

uniform float Fog_Intensity <
	ui_type = "drag";
	ui_min = 0; ui_max = 2;
	ui_label = "Fog Intensity";
	ui_tooltip = "Intensity of the fog.";
> = 1;

uniform float Fog_Additive <
	ui_type = "drag";
	ui_min = -2; ui_max = 2;
	ui_label = "Additive Fog Multiplier";
	ui_tooltip = "Makes fog Additive (1.0 for non additive)";
> = 1;

uniform float Fog_Length <
	ui_type = "drag";
	ui_min = 0; ui_max = 2000;
	ui_label = "Fog Distance";
	ui_tooltip = "Distance of the fog.";
> = 1;


uniform float3 FogRGBBalance <
	ui_type = "drag";
	ui_min = 0; ui_max = 1;
	ui_label = "RGB Balance";
	ui_tooltip = "A per channel multiplier to the fog strength so you can give more boost to certain colors over others.";
> = float3(1.0, 1.0, 1.0);


sampler samplerDepth
{
	Texture = texDepthBuffer;
};

sampler samplerColor
{
	Texture = texColorBuffer;
};

sampler samplerFogColor
{ 
	Texture = texFogColor; 
};

void Fog(float4 pos : SV_Position, float2 texcoord : TEXCOORD0, out float4 color : SV_Target)
{
	float4 fogcolor = float4(FogRGBBalance.r, FogRGBBalance.g, FogRGBBalance.b,	Fog_Intensity);
	//float4 fogcolor = tex2D(samplerFogColor, texcoord).rgba;
	float depth = tex2D(samplerDepth, texcoord).r;
	depth = Fog_Intensity / (-99.0 * depth + 101.0);
	color = tex2D(samplerColor, texcoord);
	color = depth * fogcolor + (Fog_Additive - depth) * color;
}

technique Fog < enabled = true; >
{		
	pass
	{
		VertexShader = PostProcessVS;
		PixelShader = Fog;	
	}	
}
The administrator has disabled public write access.
The following user(s) said Thank You: fuze, Gar Stazi

Simple Fog 1 year 5 months ago #3

Thank you :)

Updated the download with the updated version (thanks to NoMansReshade).
The administrator has disabled public write access.

Simple Fog 1 year 5 months ago #4

definitely using this
The administrator has disabled public write access.

Simple Fog 1 year 5 months ago #5

Sweet! Will give this a go.
The administrator has disabled public write access.