Author: Ketzerfreund
Original Thread: ~ Ketzer's Guide On Getting Rid Of Projectile Clairvoyance ~

~ Ketzer's Guide On Getting Rid Of Projectile Clairvoyance ~
~ Ketzer's Guide On Getting Rid Of Projectile Clairvoyance ~


Greetings.
I will tell you here, how to get rid of projectile trails.


You need to unpack main.pack into Empire's data folder and rename it's extension (".pack") for this to work or move it out of that folder! Only when Empire can't find certain files in any of the .packs, it'll use the unpacked files!
Patch.pack contains some replacements for files in main.pack, but Empire will use it's replacements since, as I said, Empire always gives preference to packs. Patch.pack doesn't contain a replacement for the file this guide deals with.



After having done that, find ..\data\fx\projectiletrail.fx, and open it with a text editor.

It should look like this:
Code:
#include "FXConfig.h"

#include "Camera.fx_fragment"
#include "ScreenEffects.fx_fragment"
#include "fog.fx_fragment"

struct VS_INPUT
{
	float4	position					: POSITION;
	float3	tangent						: NORMAL;
	float4	colour						: COLOR0;
	float	width						: TEXCOORD0;
	float	t							: TEXCOORD1;
	float	u							: TEXCOORD2;
	float	min_apparent_width_distance	: TEXCOORD3;
	float	fade_out_distance			: TEXCOORD4;
	float	cross_fade_start_distance	: TEXCOORD5;
	float	cross_fade_range			: TEXCOORD6;
};

struct VS_OUTPUT
{
	float4		position					: POSITION;
	float4		colour						: COLOR;
	float		u							: TEXCOORD0;
	float		fade_out_distance			: TEXCOORD1;
	float		distance					: TEXCOORD2;	
	float		t							: TEXCOORD3;
	float4		proj_pos					: TEXCOORD4;
	float		cross_fade_start_distance	: TEXCOORD5;
	float		cross_fade_range			: TEXCOORD6;
};


DECLARE_TEXTURE(normal_map);
const bool		render_normal_map;

VS_OUTPUT render_vertex(const VS_INPUT v)
{
    VS_OUTPUT r;

	float3 to_camera	= camera_position - v.position;

	float3 normal		= normalize(cross(to_camera, v.tangent));
	
	float4 position		= v.position;
	
	float distance		= length(to_camera);
	
	float width = v.width;
	
	float apparent_width = width / min(distance, v.min_apparent_width_distance);

	width = apparent_width * distance;
	
	width *= 1.0f - v.t;
	
	position.xyz		+= normal * (width * 0.5f) * v.u; 

	r.proj_pos = r.position			= mul(position, view_projection);
	r.colour.rgb		= v.colour.rgb;

	r.colour.a			= lerp(v.colour.a, 0.0f, v.t);
	
	r.u					= v.u;
	r.t					= v.t;
	
	r.fade_out_distance			= v.fade_out_distance;
	r.distance					= distance;
	r.cross_fade_start_distance	= v.cross_fade_start_distance;
	r.cross_fade_range			= v.cross_fade_range;

	return r;
}

float4 render_pixel(VS_OUTPUT v) : COLOR
{
	float dist_fade_out		= v.fade_out_distance / v.distance;
	dist_fade_out			= clamp( dist_fade_out, 0.0f, 1.0f );
	
	float width_fade_out	= 1.0 - abs( v.u );
	
	float4 colour			= v.colour;

	float cross_fade_t		= saturate((v.distance - v.cross_fade_start_distance) / v.cross_fade_range);

	if(render_normal_map)
	{
		float4 nn = tex2D(s_normal_map, v.proj_pos.xy/30 - float2(0, time_in_sec*0.05f));//float2(v.u/40, v.t*1 - time_in_sec*0.05f));
		colour.rgb = nn.rgb;
		cross_fade_t = 1.0f - cross_fade_t;
	}
	
	colour.a			*= width_fade_out * dist_fade_out * cross_fade_t;
	
	return hdr_encode(colour);
}

technique projectile_alpha_sm2
{
	pass p0
    {
		VertexShader = compile vs_2_0 render_vertex();
		PixelShader	 = compile ps_2_0 render_pixel();
		
		ZWRITEENABLE				= false;
		ALPHABLENDENABLE			= TRUE;
		SRCBLEND					= SRCALPHA;
		DESTBLEND					= INVSRCALPHA;
	}
}

technique projectile_add_sm2
{
	pass p0
    {
		VertexShader = compile vs_2_0 render_vertex();
		PixelShader	 = compile ps_2_0 render_pixel();
		
		ZWRITEENABLE				= false;
		ALPHABLENDENABLE			= TRUE;
		SRCBLEND					= SRCALPHA;
		DESTBLEND					= ONE;
	}
}

technique projectile_subtract_sm2
{
	pass p0
    {
		VertexShader = compile vs_2_0 render_vertex();
		PixelShader	 = compile ps_2_0 render_pixel();
		
		ZWRITEENABLE				= false;
		ALPHABLENDENABLE			= TRUE;
		BLENDOP						= REVSUBTRACT;
		SRCBLEND					= SRCALPHA;
		DESTBLEND					= ONE;
	}
}




Empty the actual functions in this file, like this (you can of course just delete everything it the file and copy/paste the content of the following code box into the editor):
Code:
#include "FXConfig.h"

#include "Camera.fx_fragment"
#include "ScreenEffects.fx_fragment"
#include "fog.fx_fragment"

struct VS_INPUT
{
	float4	position					: POSITION;
	float3	tangent						: NORMAL;
	float4	colour						: COLOR0;
	float	width						: TEXCOORD0;
	float	t							: TEXCOORD1;
	float	u							: TEXCOORD2;
	float	min_apparent_width_distance	: TEXCOORD3;
	float	fade_out_distance			: TEXCOORD4;
	float	cross_fade_start_distance	: TEXCOORD5;
	float	cross_fade_range			: TEXCOORD6;
};

struct VS_OUTPUT
{
	float4		position					: POSITION;
	float4		colour						: COLOR;
	float		u							: TEXCOORD0;
	float		fade_out_distance			: TEXCOORD1;
	float		distance					: TEXCOORD2;	
	float		t							: TEXCOORD3;
	float4		proj_pos					: TEXCOORD4;
	float		cross_fade_start_distance	: TEXCOORD5;
	float		cross_fade_range			: TEXCOORD6;
};


DECLARE_TEXTURE(normal_map);
const bool		render_normal_map;

VS_OUTPUT render_vertex(const VS_INPUT v)
{
}

float4 render_pixel(VS_OUTPUT v) : COLOR
{
}

technique projectile_alpha_sm2
{
}

technique projectile_add_sm2
{
}

technique projectile_subtract_sm2
{
}
First, I've tested it with a small custom battle using a line infantry unit and a cannon on each side.
Do not just empty the file altogether, or Empire will crash when trying to load a battle!


Update: In the meantime, I've played my grand campaign on for a few turns and had some battles. Everything works as intended. No trails to be seen, yet. Since there is no other file bearing a name that points to anything regarding projectile trails, I'm sure doing as told in this guide will remove all projectile trails, that means also those in ship battles.


~ Enjoy the proper battlefield view! ~