The problem IS with the TerFX shader. I just took it out, and lo and behold, my terrain turned white, with some parts of yellow (awkward o.o).
So it's SMAAS's messup. NOT mine.
LGTerrain.FX:
float4x4 WorldViewProj : WorldViewProjection;
float4x4 World : World;
float4x4 WorldView : WorldView;
float4x4 View : View;
float4x4 WorldInverse : WorldInverse;
float3 viewpos : CameraPosition;
float3 lightpos = { -150.0, 200.0, -125.0 };
float3 ambientColor = {.2f, .2f, .2f};
float3 lightColor = {1, 1, 1};
float FogMin = 0.00f;
float FogMax = 0.60f;
float FogStart = 1000.00f;
float FogEnd = 3000.00f;
float FogDensity = 10.00f;
float3 FogColor = {0.78f, 0.78f, 0.78f};
float DetailScale = 50.0f;
float TextureScale = 2000.00f;
float RoadScale = 2000.00f;
float DetailFac = 0.8;
float NormStart = 50;
float NormEnd = 100;
float Brightness = 4.0f;
const float3 diffPackFactors = float3(0.25 , 256.0, 8.0);
Texture WM0Map
<
string ResourceName = "WM0_0000.png";
string ResourceType = "2D";
>;
sampler WM0Samp = sampler_state
{
Texture = <WM0Map>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture WM1Map
<
string ResourceName = "WM1_0000.png";
string ResourceType = "2D";
>;
sampler WM1Samp = sampler_state
{
Texture = <WM1Map>;
MinFilter = none;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture WM2Map
<
string ResourceName = "WM2_0000.png";
string ResourceType = "2D";
>;
sampler WM2Samp = sampler_state
{
Texture = <WM2Map>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture WM3Map
<
string ResourceName = "WM3_0000.png";
string ResourceType = "2D";
>;
sampler WM3Samp = sampler_state
{
Texture = <WM3Map>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture Atlas0Map
<
string ResourceName = "Atlas0.dds";
string ResourceType = "2D";
>;
sampler Atlas0Samp = sampler_state
{
Texture = <Atlas0Map>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture Atlas1Map
<
string ResourceName = "Atlas1.dds";
string ResourceType = "2D";
>;
sampler Atlas1Samp = sampler_state
{
Texture = <Atlas1Map>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
};
Texture Detail
<
string ResourceName = "Detail.jpg";
string ResourceType = "2D";
>;
sampler DetailSamp = sampler_state
{
Texture = <Detail>;
MinFilter = Anisotropic;
MagFilter = LINEAR;
MaxAnisotropy = 8;
AddressU = Wrap;
AddressV = Wrap;
};
struct app_in
{
float4 pos : POSITION0;
float2 uv : TEXCOORD0;
float3 Normal : NORMAL0;
};
struct vs_out
{
float4 pos : POSITION0;
float2 uv : TEXCOORD0;
float2 uvTex : TEXCOORD1;
float2 uvRoad : TEXCOORD2;
float3 Normal : TEXCOORD3;
float3 Cam : TEXCOORD4;
float4 lightpos : TEXCOORD5;
};
vs_out LGVertexShader( app_in IN )
{
vs_out OUT;
OUT.pos = mul(IN.pos, WorldViewProj);
OUT.uv = IN.uv;
OUT.uvTex = IN.uv * TextureScale;
OUT.uvRoad = IN.uv * RoadScale;
OUT.Normal = normalize(mul(WorldInverse, IN.Normal));
float4 lp=float4(lightpos.x,lightpos.y,lightpos.z,1);
OUT.lightpos=lp; //mul(lp,View);
float4 pos = float4(IN.pos.x, IN.pos.y, IN.pos.z, 1.0);
OUT.Cam = mul(pos, WorldView).xyz;
return OUT;
}
float4 cTexM(const in sampler2D tex, in float2 uv, float tx, float ty, float lod, float size)
{
float4 uv0;
uv0.xy = uv;
uv0.z = 0;
uv0.w = 0;
uv0 = frac(uv0);
uv0.w = lod;
uv0.z = lod;
uv0.x = uv0.x * ((size * diffPackFactors.x - 1.0) / size) + 0.5 / size + diffPackFactors.x * tx;
uv0.y = uv0.y * ((size * diffPackFactors.x - 1.0) / size) + 0.5 / size + diffPackFactors.x * ty;
return(tex2Dlod(tex, uv0));
}
float4 LGPixelShader(vs_out IN) : COLOR
{
float fog = (IN.Cam.z - FogStart) / (FogEnd - FogStart);
float4 Normal = 0;
float4 pixCol = 0;
if (fog < 1) {
fog *= FogDensity;
fog = clamp(fog, FogMin, FogMax);
float3 lightDir = normalize(IN.lightpos.xyz-IN.Cam);
float3 normal = normalize(IN.Normal);
float3 lightMod = saturate(dot(lightDir, normal));
lightMod.r = clamp(lightMod.r * lightColor.r, ambientColor.r, 1);
lightMod.g = clamp(lightMod.g * lightColor.g, ambientColor.g, 1);
lightMod.b = clamp(lightMod.b * lightColor.b, ambientColor.b, 1);
float2 uv0;
uv0.xy = IN.uvTex;
float2 dx = ddx(uv0 * diffPackFactors.y);
float2 dy = ddy(uv0 * diffPackFactors.y);
float d = max(dot(dx, dx), dot(dy, dy));
float mipLevel = 0.4 * log2(d);
mipLevel = clamp(mipLevel, 0.0, diffPackFactors.z);
float size = pow(2.0, diffPackFactors.z - mipLevel) / diffPackFactors.x;
float4 weight = 0;
weight = tex2D(WM0Samp, IN.uv);
if (weight.r != 0) {
pixCol += weight.r * cTexM(Atlas0Samp,IN.uvTex,0,0, mipLevel, size);
};
if (weight.g != 0) {
pixCol += weight.g * cTexM(Atlas0Samp,IN.uvTex,0,1, mipLevel, size);
};
if (weight.b != 0) {
pixCol += weight.b * cTexM(Atlas0Samp,IN.uvTex,0,2, mipLevel, size);
};
if (weight.a != 0) {
pixCol += weight.a * cTexM(Atlas0Samp,IN.uvTex,0,3, mipLevel, size);
};
weight = tex2D(WM1Samp, IN.uv);
if (weight.r != 0) {
pixCol += weight.r * cTexM(Atlas0Samp,IN.uvRoad,2,0, mipLevel, size);
};
if (weight.g != 0) {
pixCol += weight.g * cTexM(Atlas0Samp,IN.uvRoad,2,1, mipLevel, size);
};
if (weight.b != 0) {
pixCol += weight.b * cTexM(Atlas0Samp,IN.uvRoad,2,2, mipLevel, size);
};
if (weight.a != 0) {
pixCol += weight.a * cTexM(Atlas0Samp,IN.uvTex,2,3, mipLevel, size);
};
weight = tex2D(WM2Samp, IN.uv);
if (weight.r != 0) {
pixCol += weight.r * cTexM(Atlas1Samp,IN.uvTex,0,0, mipLevel, size);
};
if (weight.g != 0) {
pixCol += weight.g * cTexM(Atlas1Samp,IN.uvTex,0,1, mipLevel, size);
};
if (weight.b != 0) {
pixCol += weight.b * cTexM(Atlas1Samp,IN.uvTex,0,2, mipLevel, size);
};
if (weight.a != 0) {
pixCol += weight.a * cTexM(Atlas1Samp,IN.uvTex,0,3, mipLevel, size);
};
weight = tex2D(WM3Samp, IN.uv);
if (weight.r != 0) {
pixCol += weight.r * cTexM(Atlas1Samp,IN.uvTex,2,0, mipLevel, size);
};
if (weight.g != 0) {
pixCol += weight.g * cTexM(Atlas1Samp,IN.uvTex,2,1, mipLevel, size);
};
if (weight.b != 0) {
pixCol += weight.b * cTexM(Atlas1Samp,IN.uvTex,2,2, mipLevel, size);
};
if (weight.a != 0) {
pixCol += weight.a * cTexM(Atlas1Samp,IN.uvTex,2,3, mipLevel, size);
};
if (IN.Cam.z < NormEnd) {
float4 weight = 0;
weight = tex2D(WM0Samp, IN.uv);
Normal += weight.r * cTexM(Atlas0Samp,IN.uvTex,1,0, mipLevel, size);
Normal += weight.g * cTexM(Atlas0Samp,IN.uvTex,1,1, mipLevel, size);
Normal += weight.b * cTexM(Atlas0Samp,IN.uvTex,1,2, mipLevel, size);
Normal += weight.a * cTexM(Atlas0Samp,IN.uvTex,1,3, mipLevel, size);
weight = tex2D(WM1Samp, IN.uv);
Normal += weight.r * cTexM(Atlas0Samp,IN.uvRoad,3,0, mipLevel, size);
Normal += weight.g * cTexM(Atlas0Samp,IN.uvRoad,3,1, mipLevel, size);
Normal += weight.b * cTexM(Atlas0Samp,IN.uvRoad,3,2, mipLevel, size);
Normal += weight.a * cTexM(Atlas0Samp,IN.uvTex,3,3, mipLevel, size);
weight = tex2D(WM2Samp, IN.uv);
Normal += weight.r * cTexM(Atlas1Samp,IN.uvTex,1,0, mipLevel, size);
Normal += weight.g * cTexM(Atlas1Samp,IN.uvTex,1,1, mipLevel, size);
Normal += weight.b * cTexM(Atlas1Samp,IN.uvTex,1,2, mipLevel, size);
Normal += weight.a * cTexM(Atlas1Samp,IN.uvTex,1,3, mipLevel, size);
weight = tex2D(WM3Samp, IN.uv);
Normal += weight.r * cTexM(Atlas1Samp,IN.uvTex,3,0, mipLevel, size);
Normal += weight.g * cTexM(Atlas1Samp,IN.uvTex,3,1, mipLevel, size);
Normal += weight.b * cTexM(Atlas1Samp,IN.uvTex,3,2, mipLevel, size);
Normal += weight.a * cTexM(Atlas1Samp,IN.uvTex,3,3, mipLevel, size);
};
float norm = (IN.Cam.z - NormStart) / (NormEnd - NormStart);
Normal = lerp(Normal, 1, norm);
Normal = saturate(dot(Normal,lightDir));
pixCol = float4(lightMod,1) * pixCol * Normal * Brightness/2;
};
return lerp(pixCol, float4(FogColor, 1), fog);
};
technique MyShader
{
pass p0
{
VertexShader = compile vs_3_0 LGVertexShader( );
PixelShader = compile ps_3_0 LGPixelShader( );
}
}
EDIT: ALSO, where can I find the ChangeTexture() function, so I can compile the LandScape Level Editor?
Do you see anything that would POSSIBLY make the terrain all black?
Thanks!
CHECK OUT MY WEBSITE AT http://imageposeidon.com/ !