[Req] Second skin overlays first with...

Posted By: Anonymous

[Req] Second skin overlays first with... - 10/27/15 19:05

Anyone feel like doing a shader?

Looking for something that overlays the colored(non-black or non-transparent) part of skin2 over skin1 to create self-illumination glowing parts.

I have no idea the level of difficulty so I understand if this work than worth doing quick and dirty for fun.

Thank you for your time.
Mal

EDIT- Looking for image examples, will add soon.




Actual light cast not required but would be nice.

Thank you
Mal
Posted By: sebbi91

Re: [Req] Second skin overlays first with... - 11/27/15 14:57

Sounds and looks interesting.
I think I could need that too.
It would be nice if someone could realize that.
Posted By: txesmi

Re: [Req] Second skin overlays first with... - 11/27/15 18:09

Hi,
Here you get a masked self-lighted solid entity shader. It supports up to eight dyn lights but it has not bloom or emmits light. That is another story. It is the simplest indeed. Save the mask as alpha channel on the texture.

Code:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecViewPos;
float4 vecViewDir;
float4 vecFog;
float4 vecFogColor;
float4 vecLight;
float4 vecColor;
float4 vecAmbient;

int iLights;
float4 vecLightColor[8];
float4 vecLightPos[8];

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

void VS (
	in float4 inposition : POSITION,
	in float3 innormal : NORMAL,
	in float2 intex : TEXCOORD0,
	out float4 outposition : POSITION,
	out float3 outnormal : TEXCOORD0,
	out float2 outtex : TEXCOORD1,
	out float3 outworldPos : TEXCOORD2 )
	{
		inposition.w = 1.0f;
		outposition = mul ( inposition, matWorldViewProj );
		outnormal = mul ( innormal, (float3x3)matWorld );
		outtex.xy = intex.xy;
		outworldPos = mul ( inposition, matWorld ).xyz;
	}

float4 PS (
	float3 normal : TEXCOORD0,
	float2 tex : TEXCOORD1,
	float3 worldPos : TEXCOORD2 ) : COLOR0
	{
		normal.xyz = normalize ( normal.xyz );
		float4 textureColor = tex2D ( ColorSampler, tex.xy );
		float4 finalColor;
		finalColor.rgb = vecAmbient.rgb * vecLight.rgb;
		for ( int i=0; i<iLights; i++ )
		{
			float3 lightDir = normalize ( vecLightPos[i].xyz - worldPos.xyz );
			float Distance = distance ( vecLightPos[i].xyz, worldPos.xyz );
			float Radiance = saturate ( ( vecLightPos[i].w - Distance ) / vecLightPos[i].w );
			finalColor.rgb += vecLightColor[i].rgb * saturate(dot(lightDir.xyz,normal.xyz)) * Radiance;
		}
		finalColor.rgb *= textureColor.rgb;
		finalColor.rgb = lerp ( finalColor.rgb, textureColor.rgb, textureColor.a );
		float Distance = distance ( vecViewPos.xyz, worldPos.xyz );
		float Fog = saturate ( ( Distance - vecFog.x ) * vecFog.z );
		finalColor.rgb = lerp ( color.rgb, vecFogColor, Fog );
		finalColor.a = 1.0f;
	   return finalColor;
	}

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



Salud!

Posted By: Anonymous

Re: [Req] Second skin overlays first with... - 11/27/15 18:25

^--- Awesome! Thanks Txesmi. I'll start the hacking to add any needed things and post the results. Very kind to give us a frame to work from..

Thanks
Mal
Posted By: txesmi

Re: [Req] Second skin overlays first with... - 11/27/15 18:50

Glad of being helpful laugh
Posted By: Dico

Re: [Req] Second skin overlays first with... - 11/27/15 20:52

I think there is a method in med , so you can get nice glowing without shaders just two skins , one normal and the other is colored!
and with shader bloom you can get nice result.
© 2024 lite-C Forums