This is what I came up with so far

mtl_shaded.fx
Code
#include <pos>
#include <normal>
#include <lights>

float4x4 matWorldViewProj;
float4 vecViewPos;

float4 vecLightDir[8];

float4 vecFog;
float4 vecFogColor;
float4 vecSkill1;

Texture entSkin1;
Texture entSkin2;

sampler ColorSampler = sampler_state
{
	Texture = <entSkin1>;
	Mipfilter = None;
	Minfilter = None;
	Magfilter = None;
};

sampler ShadowSampler = sampler_state
{
	Texture = <entSkin2>;
	Mipfilter = Linear;
	Minfilter = Linear;
	Magfilter = Linear;
};

struct vertexOut
{
	float4 Pos : POSITION;
	float4 Color : COLOR0;
	float3 Normal : NORMAL;
	float4 Tex : TEXCOORD0;
	float4 WorldPos : TEXCOORD1;
};

vertexOut VS (
in float4 inPos : POSITION,
in float3 inNormal : NORMAL,
in float2 inTex1 : TEXCOORD0,
in float2 inTex2 : TEXCOORD1
)
{
	inPos.w = 1.0f;	
	vertexOut Out;
	
	// vertex snapping
	float4 snapToPixel = mul(inPos, matWorldViewProj);
	float4 vertex = snapToPixel;
	vertex.xyz = snapToPixel.xyz / snapToPixel.w;
	vertex.x = floor((vecSkill1.y + 40) * vertex.x) / (vecSkill1.y + 40); // default 160
	vertex.y = floor(vecSkill1.y * vertex.y) / vecSkill1.y; // default 120
	vertex.xyz *= snapToPixel.w;
	Out.Pos = vertex;
	
	// affine texture mapping
	Out.Pos *= inPos.w / length(mul(inPos, matWorldViewProj));
	
	Out.Normal = normalize (mul(inNormal, (float3x3)matWorld));
	Out.Tex.xy = inTex1.xy;
	Out.Tex.zw = inTex2.xy;
	Out.WorldPos = mul(inPos, matWorld);
	Out.Color = 0;
	
	float3 P = DoPos(inPos);
	float3 N = DoNormal(inNormal);
	
	for(int i = 0; i < 8; i++)
	{
		if(vecLightDir[i].w > 0 && vecLightDir[i].w <= 1000) // spotlight ?
		{
			
		}
		else // pointlight ?
		{
			Out.Color += DoLight(P,N,i);
		}
	}
	
	// cut out polygons
	float distance = length(mul(inPos, matWorldViewProj));
	
	if(vecSkill1.z == 0){ vecSkill1.z = 512; }
	
	if (distance > vecSkill1.z)
	{
		Out.Pos.w = 0;
	}
	
	return Out;
}

float4 PS(vertexOut In) : COLOR0
{
	float4 textureColor = tex2D(ColorSampler, In.Tex.xy);
	float4 color = tex2D(ShadowSampler, In.Tex.zw);
	float fDepth = distance(vecViewPos.xyz, In.WorldPos.xyz);
	
	color += In.Color; // add dynamic lights
	
	color.rgb = saturate(color.rgb);
	color.rgb = pow(color.rgb, vecSkill1.x);
	color.rgb *= textureColor.rgb;
	
	float Fog = saturate((fDepth - vecFog.x) * vecFog.z);
	color.rgb = lerp(color.rgb, vecFogColor, Fog);
	
	color.a = 1;
	
	return color;
}

technique mtl_shaded
{
	pass one
	{
		ZWriteEnable = True;
		AlphaBlendEnable = False;
		AlphaTestEnable = False;
		
		VertexShader = compile vs_3_0 VS();
		PixelShader = compile ps_3_0 PS();
	}
}

Thanks to txesmi, in the past he made perpixel lightning pipeline for me, it helped a lot!
[Linked Image]
Screenshot sadly can't show vertex snapping, but it looks awesome! Next thing to add is a spotlight, but I don't know yet how to do that.

Greets!


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