관리되는 DirectX 2.0 (DirectX9와 같음)을 사용하는 응용 프로그램을 만들고있어 HLSL을 처음 사용하기 때문에 내가 뭘하는지 바보 스럽다면 미안 해요. . 단순히 저장 한 텍스처 (전역 변수로 할당 됨)를 화면에 출력하는 간단한 픽셀 쉐이더를 작성하고 있지만 텍스처 대신 텍스처를 렌더링하는 것으로 나타났습니다 (다른 렌더링 된 텍스처를 전달 중입니다. 이 쉐이더는 테스트 쉐이더이다).DirectX 9 HLSL 텍스처 샘플링 문제
texture inputTex;
sampler2D InputSampler = sampler_state
{
Texture = <inputTex>;
};
texture DepthTexture;
sampler2D DepthSampler = sampler_state
{
Texture = (DepthTexture);
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
float4 testPass(float2 TextureCoordinate : TEXCOORD0) : COLOR0
{
float4 new_color = saturate(tex2D(DepthSampler,TextureCoordinate));
new_color.a=1;
return new_color;
}
technique DoF
{
pass Pass0
{
PixelShader = compile ps_2_0 testPass();
}
}
을하고 내 C#은 다음과 같습니다 : 다음과 같이
내 HLSL 코드는
postProc.SetValue("DepthTexture", DepthTexture);
postProc.Begin(FX.DoNotSaveState);
device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.White, 1.0f, 0);
device.BeginScene();
{
postProc.SetValue("inputTex", RenderTexture);
postProc.CommitChanges();
postProc.BeginPass(0);
sprite.Draw(RenderTexture, new Rectangle(0, 0, WINDOWWIDTH, WINDOWHEIGHT), new Vector3(0, 0, 0), new Vector3(0, 0, 0), Color.Black);
postProc.EndPass();
postProc.End();
sprite.End();
}
device.EndScene();
device.Present();
입니다 DepthTexture에 저장되는 반대로 출력은, RenderTexture에 어떤 저장됩니다 그것이 무엇을 해야하는지.
sprite.Draw(RenderTexture, new Rectangle(0, 0, WINDOWWIDTH, WINDOWHEIGHT), new Vector3(0, 0, 0), new Vector3(0, 0, 0), Color.Black);
및 출력 DepthTexture, 그래서 분명히 거기에서 데이터를 복용하고 질감이 제대로 포맷 :이 줄을 DepthTexture와 RenderTexture를 교환 시도했다.
HLSL에게 전달 된 텍스처를 샘플링 할 때와 그려진 데이터에서 샘플링 할 때를 알려주는 좋은 튜토리얼을 아는 사람이 있습니까?
TBH Managed DX는 지원되지 않습니다. SlimDX를 사용하는 것이 훨씬 낫습니다. – Goz
분명히 셰이더가 텍스처를 샘플링하는 방법에 아무런 영향을 미치지 않고 제 질문과 관련이 없습니까? –