Jump to content

  • Log In with Google      Sign In   
  • Create Account


Lotes

Member Since 08 Nov 2012
Offline Last Active Nov 14 2012 06:53 AM
-----

Posts I've Made

In Topic: Render depth to texture

08 November 2012 - 09:30 AM

It works with this code. But I find it very ugly to use a magic number like 25 as a factor in this case. How can I calculate this factor from my matrices? :-/
VertexToPixel PositionsVS( float4 inPos : POSITION, float3 inNormal: NORMAL, float4 inColor: COLOR)
{
    VertexToPixel Output = (VertexToPixel)0;
    float4x4 preViewProjection = mul (xView, xProjection);
    float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
    Output.Position = mul(inPos, preWorldViewProjection);
    Output.Color = 1;
    Output.Color.rgb = Output.Position.z;
    return Output;
}
PixelToFrame PositionsPS(VertexToPixel PSIn)
{
    PixelToFrame Output = (PixelToFrame)0;
    Output.Color = PSIn.Color/25;
    return Output;
}

My cubes have a dimension of 0.9x0.9x0.9 at positions (0,0,-10), (0,0,-9) ... (0,0,10).
My camera is at (0,10,-20) looking at (0,0,0).

In Topic: Render depth to texture

08 November 2012 - 09:14 AM

they are drawn (black cubes on blue background).
changing 200 to 200.0 did not help. i think in hlsl it does not matter.

In Topic: Render depth to texture

08 November 2012 - 08:43 AM

Here is it...
VertexToPixel PositionsVS( float4 inPos : POSITION)
{
    VertexToPixel Output = (VertexToPixel)0;

    float4x4 preWorldView= mul (xWorld, xView);
    Output.Position = mul(inPos, preWorldView);
    Output.Color = 1;
    Output.Color.rgb = Output.Position.z/200;
    Output.Position = mul(Output.Position,xProjection);
    return Output;
}
PixelToFrame PositionsPS(VertexToPixel PSIn)
{
    PixelToFrame Output = (PixelToFrame)0;
    Output.Color = PSIn.Color;
    return Output;
}

In Topic: Render depth to texture

08 November 2012 - 08:28 AM

Thanks. My far clip plane has a distance of 200.0f. Is that the value for zFar?
When I tried out your code my cubes became entirely black :-/.

PARTNERS