Sign in to follow this  

How to create a texture of 128bits

Recommended Posts

akira32    112
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
jollyjeffers    1570
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.


Share this post

Link to post
Share on other sites

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