Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Creating image mip levels

Author
Message
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 30th Aug 2011 22:08
I know that I can make images using 3rd party software and give the image mip levels, but what if I make the image in-game? If I make an image to be used in the game at the start of the game, how can I make the image so that it has mips? Does dbMakeImageFromMemblock(....) do something like that???.....

Any thoughts?

The fastest code is the code never written.
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Sep 2011 18:17
BUMP! Sorry. I would really like to know the answer to this.

The fastest code is the code never written.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 16th Sep 2011 18:37
Not sure if this command might help:

Quote: "dbSetObjectTexture
This command will set different texture modes used by the specified object. Every texture is painted onto an object using an internal set of values called UV data. This data contains a range of real numbers from zero to one. Zero specifying the top/left corner of your texture and one being the bottom/right corner of your texture. When an object uses UV data greater and less than this range, you are permitted a number of texture wrap modes to describe what should happen to paint these areas. Setting the Texture Wrap Mode to zero will use the default wrap mode which repeat the pattern of the texture over and over, a mode of one will mirror the texture to create a seamless texture pattern and a mode of two will set clamping which retains the colour of the last pixel at the textures edge and paint with that throughout the out of range area. The Mipmap Generation Flag is used to ensure the image has a mipmap texture. A mipmap is a texture that has many levels of detail, which the object can select and use based on the objects distance from the camera.

Syntax
void dbSetObjectTexture ( int iObject, int iMode, int iMipMaps ) "



Are mipmaps what you are talking about? If so then I thought DirectX generates these automatically, although I'm not completely sure.

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Sep 2011 18:45
I understand the concept. I just need to know how to create mips of an image I create in-game.

The fastest code is the code never written.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 16th Sep 2011 19:19 Edited at: 16th Sep 2011 19:21
why do you want to do so? i believe it's automatically created by DirectX

anyway, mip maps are just half-sized images of the parent image, can't you just render your image to a texture with half size, then render the half-sized one to another with half-size of the previous half, etc, a number of times till you have n mip levels? i guess it would work, though, i still dunno why you need them for

Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 16th Sep 2011 19:24
Are you sure the images you create do not have mipmaps already?

Once you texture an object I don't think it matters where the image came from, it should be treated the same by DirectX. I'm still mostly guessing though, I have not done a great deal manipulating mipmaps in the past, although I did need to turn them off once

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 16th Sep 2011 20:06 Edited at: 16th Sep 2011 20:07
I think Matty is right, mipmaps are generated by default when texturing an object, and this can also be forced (or disabled) with dbSetObjectTexture

Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 16th Sep 2011 23:19
Quote: "Are you sure the images you create do not have mipmaps already?"

No. That was the point of my post. I have done DX programming:
Quote: "
*** from msdn help *****
HRESULT D3DXCreateTextureFromFileEx(
__in LPDIRECT3DDEVICE9 pDevice,
__in LPCTSTR pSrcFile,
__in UINT Width,
__in UINT Height,
__in UINT MipLevels,
__in DWORD Usage,
__in D3DFORMAT Format,
__in D3DPOOL Pool,
__in DWORD Filter,
__in DWORD MipFilter,
__in D3DCOLOR ColorKey,
__inout D3DXIMAGE_INFO *pSrcInfo,
__out PALETTEENTRY *pPalette,
__out LPDIRECT3DTEXTURE9 *ppTexture
);
"

Note the "UINT MipLevels" parameter. This tells the load funtion to either use the mip levels of the file or create them. I don't know what DGDK does in this case..... Perhaps DGDK has a default mip level it uses...?

The major question is "does DGDK use mip levels?":
Quote: "*** from msdn help *****
HRESULT D3DXCreateTextureFromFileInMemoryEx(
__in LPDIRECT3DDEVICE9 pDevice,
__in LPCVOID pSrcData,
__in UINT SrcDataSize,
__in UINT Width,
__in UINT Height,
__in UINT MipLevels,
__in DWORD Usage,
__in D3DFORMAT Format,
__in D3DPOOL Pool,
__in DWORD Filter,
__in DWORD MipFilter,
__in D3DCOLOR ColorKey,
__inout D3DXIMAGE_INFO *pSrcInfo,
__out PALETTEENTRY *pPalette,
__out LPDIRECT3DTEXTURE9 *ppTexture
);
"

Again, notice the "UINT MipLevels"......

If it does (or doesn't), I would like to know. If it doesn't, I would like to know if there is a way.

@Hassan,
It's not just a matter of making a series of half-sized images, it's a matter of sending those images to the video card to use like a single image. As the object gets further away from the camera (or simply smaller sized in the view), a high-res version of the texture is not needed. Using a smaller mip makes the object render faster.

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-11-19 07:26:15
Your offset time is: 2024-11-19 07:26:15