• Advertisement
Sign in to follow this  

How to create a texture of 128bits

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

How to create a texture of 128bits? Should I modify the Format in CreateTexture from D3DFMT_R32F to D3DFMT_A32B32G32R32F? V_RETURN(pd3dDevice->CreateTexture( SHADOW_MAP_SIZE, SHADOW_MAP_SIZE, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R32F, D3DPOOL_DEFAULT, &m_pShadowMap_QVSM_TexNormal, NULL )); Another question: If I want to fill the 128bits texture in Shader. How do I define the 128bits color?(32bits using float4) Shader Code about Creating the Shadow Map as below: VS_OUTPUTCREATESHADOWMAP VSCreateShadowMap(float4 Pos : POSITION, float3 Normal : NORMAL) { VS_OUTPUTCREATESHADOWMAP Out = (VS_OUTPUTCREATESHADOWMAP)0; // transform light source // mScale * mTransform * mRotate * mView * mProj float4 Position = mul( Pos, mLightViewProj); // output position Out.Pos = Position; // depth value Out.Depth = ((Position.z + fNear) / (fFar - fNear)); Out.Pos.z = Out.Depth * Position.w; return Out; } // ------------------------------------------------------------- // Pixel shader that creates shadow map // ------------------------------------------------------------- float4 PSCreateShadowMap(float Depth : TEXCOORD0) : COLOR { return Depth; }

Share this post


Link to post
Share on other sites
Advertisement
Obviously you need to check the format is supported by your hardware (note that filtering and blending is most likely not supported) [wink]

But yes, changing the D3DFORMAT enumeration in the CreateTexture() call is all that is necessary.

The only thing you really need to worry about with your shader is the number of channels - the GPU will handle the conversion to/from the underlying storage format. So going from R32F to ARGB32F only really requires to change from a <T> to a <T>4 declaration - assuming you want to write to all 4 channels.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement