Sign in to follow this  

Convert float to float4

This topic is 2957 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

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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

This topic is 2957 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this