Home » Community » Forums » Graphics Programming and Theory » Convert float to float4
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Convert float to float4
Post New Topic  Post Reply 
Hi,

I'm trying to write the depth on to an offscreen surface, but all I get is white pixels. I tryed to do something like this:

float x;
return float4(floor(x) / 256, frac(x), frac(x), frac(x));

I don't know where I got this from but I found it on my notes, so I guess I must have seen this somewhere.

Could anyone give me a little hint how to do saving of depth in a color surface should be done? Was trolling the internet all day long. Thx a lot.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Use a surface with a floating point format, and just return the depth from the pixel shader. Or do you actually want to view the depth in some color code?
What is this for?

 User Rating: 1538   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

I'm not sure how to do this in FX composer because I want to pass on the buffer to a pixel shader. And I can't give it on to the pixel shader as a depth buffer because I don't have access to the sampler.

DECLARE_QUAD_DEPTH_BUFFER(DepthBuffer, "D24S8")

[...]

float4 PointLightPS(uniform sampler2D norm, uniform sampler2D depth) {...}
PixelShader = compile ps_3_0 PointLightPS(NormalTextureSampler, DepthBuffer);


But on the other hand FX composer gives me an error when I'm trying to create an offscreen surface with a diffrent surface type:

DECLARE_QUAD_TEX(DepthBuffer, DepthBufferSampler, "D24S8")

You are probably right Erik, your appraoch is the right one but I can't get it to work. I only use the depth buffer to recreate the world position in a pixel shader. I do something like this:

1) Render normals, unlit color, and depth to offscreen surfaces.
2) Generate light map from these surfaces and output color.

EDIT: Got it working in XNA but not FX Composer, probably something i do wrong with the SAS stuff...

[Edited by - 5ule1m4n on November 7, 2009 5:28:38 PM]

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: