Jump to content
  • Advertisement
Sign in to follow this  
belfegor

[DX9] Array of samplers

This topic is 3049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1st question Current code:
sampler samp0 : register(s0) = sampler_state
{
    ...//set filtering, address modes...
};

sampler samp1 : register(s1) = sampler_state
{
    ...//set filtering, address modes...
};
...and so on
Is it possible and how to do that with array of samplers?
sampler arrSamp[4];
2nd question Is this the correct way to clear 4 render targets:
dev->SetRenderTarget(0, rt0);
dev->SetRenderTarget(1, rt1);
dev->SetRenderTarget(2, rt2);
dev->SetRenderTarget(3, rt3);// all rts are of the same size
D3DRECT rcs[4];
rcs[0].x1 = 0;
rcs[0].x2 = rtSize;
rcs[0].y1 = 0;
rcs[0].y2 = rtSize;
rcs[1].x1 = 0;
rcs[1].x2 = rtSize;
rcs[1].y1 = 0;
rcs[1].y2 = rtSize;
rcs[2].x1 = 0;
rcs[2].x2 = rtSize;
rcs[2].y1 = 0;
rcs[2].y2 = rtSize;
rcs[3].x1 = 0;
rcs[3].x2 = rtSize;
rcs[3].y1 = 0;
rcs[3].y2 = rtSize;
HRESULT hr = dev->Clear(4, rcs, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00FFFFFF, 1.0f, 0L);

Share this post


Link to post
Share on other sites
Advertisement
3rd question

First example:

// Vertex shader
// here Depth is float
OUT.Depth = (OUT.Position.z / OUT.Position.w);
//Pixel shader
OUT.Color = float4(IN.Depth, 1.0f, 1.0f, 1.0f);


Second:

// Vertex shader
// here Depth is float2
OUT.Depth.xy = OUT.Position.zw;
//Pixel shader
OUT.Color = float4(IN.Depth.x / IN.Depth.y, 1.0f, 1.0f, 1.0f);


Does it make it any difference, except that pixel shader is
"called" more times then vertex?

Share this post


Link to post
Share on other sites
1: No (assuming D3D9).

2: If you want to clear the whole area of all set render targets, you can call Clear without specifying any rectangles. The rectangles have nothing to do with individual render targets - they just specify which rectangular areas of the render target to clear.

Share this post


Link to post
Share on other sites
For your third question, the first method will give you incorrect depth values. This is because the homogeneous divide is a non-linear operation, which means you can't do it before interpolation. You instead have to interpolate first and then perform the divide in the pixel shader.

Share this post


Link to post
Share on other sites
Note that the hardware can automatically apply perspective correction to texture coordinates.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!