Sign in to follow this  

write RGB8 values at RGBA16 buffer(unsigned 64bit). PLZ help me :-)

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

hello guys~
I need your help for my recently work. plz give me a tip. :-)
sorry about my poor english.

I attempted to write two values( Diffuse;lit and Illumination;add) at one 64bit unsigned Render Target(D3DFMT_A16B16G16R16) in DX9.
for each two value assign to 8bit. and save to one channel. It's possible 'cause It's Unsigned 16 bit per component of RGBA.

I use multiplication or division by 256 as Bit Shift. Because Can't use Bit Operator( << and >>) at DX9.

=== HLSL code of Write pass: ===

// Convert to 0~255 Unsigned Int
// 00000000 CCCCCCCC
int3 vDiffuseUint = output.color.rgb * 255.0f;
vDiffuseUint = clamp( vDiffuseUint, 0, 255);
// Bit Shift
// CCCCCCCC 00000000
vDiffuseUint *= 256;

// 00000000 AAAAAAAA
int3 vAddUint = vAdd * 255.0f;
vAddUint = clamp( vAddUint, 0, 255);

// Accumulate
// CCCCCCCC AAAAAAAA
int3 vCompressedUint = vDiffuseUint + vAddUint;
// Convert to 0~1 float
OutPut = (float3)vCompressedUint / ( 65535.0f);


=== HLSL code of Read pass: ===

// Comvert to unsigned Int
// CCCCCCCC AAAAAAAA
int3 vReadColorUint = saturate(vReadColor) * ( 65535.0f);

// Bit Shift
// 00000000 CCCCCCCC
int3 vDiffuseUint = vReadColorUint / 256;
// Bit UnShift
// CCCCCCCC 00000000
int3 vDiffuseUintUnShift = vDiffuseUint * 256;

// Get AddClr
// CCCCCCCC AAAAAAAA
// - CCCCCCCC 00000000
// = 00000000 AAAAAAAA
int3 vAddUint = 0;
vAddUint = vReadColorUint - vDiffuseUintUnShift;

// convert to float. and use this value as result OutPut.
vReadColor = (float3)vDiffuseUint / 255.0f;
vAddColor = (float3)vAddUint / 255.0f;


It works!!!!!! Pretty good.
but damn Geforce 7600 T_T. Error in Geforce 7xxx and lower model. I'll try to check Radeons.

Fundamentally, Why this happen?!?! Why symptoms are different for each H/W?
How can i scan standards( Caps, Query, and so on...)?

Give me a piece of hint please.
God bless you.

[Edited by - ozkill on December 30, 2010 6:45:51 AM]

Share this post


Link to post
Share on other sites

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