|
||||||||||||||||||
Add Forum to Favorites | Send Topic To a Friend | View Forum FAQ | Track this topic |
Last Thread Next Thread ![]() |
| Convert float to float4 |
|
![]() 5ule1m4n Banned Member since: 9/7/2008 From: Sankt Gallen, Switzerland |
||||
|
||||
| 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. |
||||
|
||||
![]() Erik Rufelt Member since: 4/17/2002 From: Sweden |
||||
|
|
||||
| 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? |
||||
|
||||
![]() 5ule1m4n Banned Member since: 9/7/2008 From: Sankt Gallen, Switzerland |
||||
|
||||
| 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] |
||||
|
||||
All times are ET (US)![]() |
Last Thread Next Thread ![]() |
|