I try to use the RGB Shader from Steempipe i found in the Forum. Anything works fine but there was no possibility to add a detailmap because of the limitated number of textures.
I tried to change the script by using the first texture as a combination of Mask and Texture shown on the screen. I added to the Terrain Texture red and green areas where i blend the grass and road texture over which frees me one slot for the detail map. It works in general but unfortunately on the edges i still have red and green color.
The question is it possible to work in the way described? And if so can someone help me getting the code running.
Unfortunetaly i do not have any experience on Shaders so far and it is much more complex than expected. So any help would be appreciated.
Result with Red and Green Color on the edges instead of the texture
Maskimage
Source:
sampler sMaskTex = sampler_state
{
Texture = <entSkin1>; // Image with Red/Green areas where i'd like to blend the grass and road texture
MipFilter = LINEAR; // Anything else should be shown unchanged
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
sampler sBaseTex = sampler_state
{
Texture = <mtlSkin1>; // Detail Map Image
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
sampler sRedTex = sampler_state
{
Texture = <entSkin2>; // Grass Texture
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
sampler sGreenTex = sampler_state
{
Texture = <entSkin3>; // Road Texture
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};
float4 TMulti_PS_13(TMULTI_VS_OUT In): COLOR
{
// retrieve the pixels for the textures and the masks
float4 MaskColor = tex2D(sMaskTex,In.MaskCoord);
float4 RedColor = tex2D(sRedTex,In.RedCoord);
float4 GreenColor = tex2D(sGreenTex,In.GreenCoord);
float4 DetailColor = tex2D(sBaseTex,In.BaseCoord);
float4 BaseColor;
BaseColor=MaskColor;
float4 BaseRed = lerp(MaskColor,RedColor,BaseColor.r);
BaseColor=MaskColor;
float4 Fcolor = lerp(BaseRed,GreenColor,BaseColor.g);
float4 FinalColor;
FinalColor =Fcolor + DetailColor - 0.5;
FinalColor.a = 1.0f; // prevent transparency
return FinalColor;
}