스플래팅 줄가는 현상 질문드립니다.

2D, 3D, 다각형, 픽셀 등 게임의 그래픽 프로그래밍에 관한 포럼입니다.

Moderator: 류광

Locked
namkh82
Posts: 2
Joined: 2009-07-16 14:05

스플래팅 줄가는 현상 질문드립니다.

Post by namkh82 »

쉐이더 스플래팅을 구현을 했는데, 스플래팅이 제대로 되지 않고 줄이가는 현상이 발생해서
질문올려봅니다.

쉐이더 코드는 다음과 같습니다.



/*
전역변수, 구조체, 샘플러 선언들
*/


VS_OUTPUT VS(VS_INPUT In)
{
VS_OUTPUT Out = (VS_OUTPUT)0;

float4 PosW = mul(In.Pos, World);
float3 N = normalize(mul(In.Normal, World));

float3 L = normalize(PosW - gLight.posW);

float3 Eye = normalize(PosW - gCameraPosition.xyz);
float3 R = reflect(Eye, N);

float4 halfLambert = 0.5f * dot(N, -L) + 0.5f;
float4 specular = pow(max(0, dot(-L, R))*2, 1);
Out.Color = halfLambert + specular;

Out.Diffuse = gMtrl.diffuse + gMtrl.ambient;

Out.Height = In.Pos.y;
Out.Pos = mul(PosW, ViewProjection);

Out.TexUV = In.TexUV;
Out.BlendUV = In.BlendUV;

return Out;
}

float4 PS(VS_OUTPUT In) : COLOR0
{
float4 BaseTexColor, Diffuse1, Diffuse2, Diffuse3, Blend;

if(In.Height > 300.0f)
{
BaseTexColor = tex2D(BaseSamp, In.TexUV);
Diffuse1 = tex2D(HighIntervalSamp1, In.TexUV);
Diffuse2 = tex2D(HighIntervalSamp2, In.TexUV);
Diffuse3 = tex2D(HighIntervalSamp3, In.TexUV);
Blend = tex2D(HighIntervalBlendSamp, In.BlendUV); }
else
{
BaseTexColor = tex2D(BaseSamp, In.TexUV); Diffuse1 = tex2D(LowIntervalSamp1, In.TexUV);
Diffuse2 = tex2D(LowIntervalSamp2, In.TexUV);
Diffuse3 = tex2D(LowIntervalSamp3, In.TexUV);
Blend = tex2D(LowIntervalBlendSamp, In.BlendUV);
}

float4 BlendedTexColor1 = lerp(BaseTexColor, Diffuse1, Blend.r);
float4 BlendedTexColor2 = lerp(BlendedTexColor1, Diffuse2, Blend.g);
float4 BlendedTexColor3 = lerp(BlendedTexColor2, Diffuse3, Blend.b);

return (BlendedTexColor3 * In.Diffuse) * In.Color;
}

// 테크닉 선언(정점 & 픽셀 쉐이더 사용)
technique TqTerrainSplating
{
pass P0
{
// shaders
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();

ZEnable = true;
AlphaBlendEnable = false;
}
}

도저히 이해가 안가서 그러는데 아시는분 계시면 어디가 잘못된건지 가르쳐 주세요[/img]
Locked