Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mythar

BumpMap ? , plz help !

This topic is 5618 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, i have been trying to create a BumpMap. What i want to do, is convert a normal texture surface to a bumpmap. When i call my function it simply returns a "white" bumpmap, insted of the one it should, using PhotoShop to create the bumpmap. Been having trouble with this for some time now, and getting close to giving up. Im probly just doing something stupid. Hope someone can help. Texture = IDirectDrawSurface7 = Texture to be converted to a bumpmap BumpMap = IDirectDrawSurface7 = The resulting bumpmap. Format = bfU8V8,bfU5V5L6,bfU8V8L8 Code is in Delphi, but its not that mush diffrence to c++
Var ddsd,
    ddsd2     : TDDSurfaceDesc2;
    HR        : HResult;
    r         : TRect;
Begin
  ZeroMemory(@ddsd, sizeof(TDDSurfaceDesc2));
  ZeroMemory(@ddsd2, sizeof(TDDSurfaceDesc2));
  ddsd.dwSize := sizeof(TDDSurfaceDesc2);
  ddsd2.dwSize := sizeof(TDDSurfaceDesc2);
  Texture.GetSurfaceDesc(ddsd);

  ddsd.dwFlags := DDSD_CAPS or DDSD_HEIGHT or DDSD_WIDTH or
                  DDSD_PIXELFORMAT or DDSD_TEXTURESTAGE;
  ddsd.ddsCaps.dwCaps  := DDSCAPS_TEXTURE or DDSCAPS_SYSTEMMEMORY;
  ddsd.ddsCaps.dwCaps2 := 0;
  ddsd.ddsCaps.dwCaps3 := 0;
  ddsd.ddsCaps.dwCaps4 := 0;
  ddsd.dwTextureStage  := 0;
  ddsd.ddpfPixelFormat.dwSize  := sizeof(TDDPIXELFORMAT);
  ddsd.ddpfPixelFormat.dwRGBBitCount := 32;
  ddsd.ddpfPixelFormat.dwFlags := DDPF_BUMPDUDV;

  Case Format of
  bfU8V8   : Begin
               ddsd.ddpfPixelFormat.dwBumpBitCount  := 16;
               ddsd.ddpfPixelFormat.dwBumpDuBitMask := $000000ff;
               ddsd.ddpfPixelFormat.dwBumpDvBitMask := $0000ff00;
               ddsd.ddpfPixelFormat.dwBumpLuminanceBitMask := $00000000;
             End;
  bfU5V5L6 : Begin
               ddsd.ddpfPixelFormat.dwFlags := ddsd.ddpfPixelFormat.dwFlags or DDPF_BUMPLUMINANCE;
               ddsd.ddpfPixelFormat.dwBumpBitCount  := 16;
               ddsd.ddpfPixelFormat.dwBumpDuBitMask := $0000001f;
               ddsd.ddpfPixelFormat.dwBumpDvBitMask := $000003e0;
               ddsd.ddpfPixelFormat.dwBumpLuminanceBitMask := $0000fc00;
             End;
  bfU8V8L8 : Begin
               ddsd.ddpfPixelFormat.dwFlags := ddsd.ddpfPixelFormat.dwFlags or DDPF_BUMPLUMINANCE;
               ddsd.ddpfPixelFormat.dwBumpBitCount  := 24;
               ddsd.ddpfPixelFormat.dwBumpDuBitMask := $000000ff;
               ddsd.ddpfPixelFormat.dwBumpDvBitMask := $0000ff00;
               ddsd.ddpfPixelFormat.dwBumpLuminanceBitMask := $00ff0000;
             End;
  End;

  HR:=DirectDraw.CreateSurface(ddsd, BumpMap, nil);

  BumpMap.GetSurfaceDesc(ddsd);
  BumpMap.Lock( PRect(nil), ddsd, DDLOCK_WAIT, 0);
  Texture.GetSurfaceDesc(ddsd2);
  Texture.Lock( PRect(nil), ddsd2, DDLOCK_WAIT, 0);

  R.Top:=0;
  R.Left:=0;
  R.Bottom:=ddsd.dwHeight-1;
  R.Right:=ddsd.dwWidth-1;

  BumpMap.BltFast(0,0,Texture,@R,0);

  Texture.Unlock(nil);
  BumpMap.Unlock(nil);
End;

  
[edited by - Mythar on June 2, 2003 1:01:22 PM]

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!