• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Alundra

Mipmaps in image

8 posts in this topic

Hi all,

Do you think it's bad to store mipmaps in "Image class" with a GenerateMipmaps function or it only should be in "Texture class" ?

Thanks

0

Share this post


Link to post
Share on other sites

They're used by the GPU, so they need to be part of the texture that is sent to the GPU.

 

What is "Image class"? What is "Texture class"? You've given us no context.

0

Share this post


Link to post
Share on other sites

Image class is a class who stores pixel data, you can set or get a pixel if it's a RGBA image format, mirror, flip, change format, load from file, save to file.

Texture class is a class linked with the Renderer class who is renderer dependent, he stores the GPU texture data used for shader.

Image class supports RGBA and BC format.

Edited by Alundra
0

Share this post


Link to post
Share on other sites

Your Image class sounds like something that is (hopefully) only heavily used offline in your tools. It would make sense for your Image class to have a function to generate mipmaps, which can then be saved into the texture file that your game loads and creates a runtime texture from. The runtime Texture class will create a texture that contains the mipmaps that it read off disk, but is unlikely to have any interface for directly modifying those mips.

0

Share this post


Link to post
Share on other sites
The most effective set-up I have found so far is:
  • CImage loads and manipulates any image file (I use some custom loaders for my custom formats and DXT, and FreeImage for the rest).  It can resample (rescale) them, flip them vertically, apply matrix operations (sobel filters for example), convert between formats, swizzle channels, allow direct texel modifications, etc.  It can also create and store chains of mipmaps (since it can natively rescale images anyway), and also perform DXT compression (I use my own modification of Squish (SURPRISE—my own DXT routine has a flaw that needs to be handled, and it basically needs to be rewritten from scratch)).  It also has the ability to save to a custom file format which includes the mipmaps and also to later load that file.
  • CTexture2d::CreateTexture() takes an array of CImage’s or file names.  It takes an array in order to optionally support texture arrays (1 array slice per CImage you pass), and if you pass only 1 CImage it is a non-array regular 2D texture.  If you pass file names it creates temporary internal CImage objects, uses them to load the file(s) you pass, and calls its const CImage * overload.  The format of the texture, number of array slices, number of mipmaps levels, and dimensions are all implicit in this way.
  • Although CImage is part of the engine and can be used at run-time for any of the above operations, it is stupid to do so.  Tools link to the engine.  My LSDxt converter and LSFbx converter link to the necessary parts of the engine and use CImage for offline conversions.  The run-time should only be using CImage to load custom .LSI (L. Spiro Image) files.  Nonetheless it is there for use at run-time just for those very rare special cases.
In the distant past when I was (more) naïve, since textures were so strongly associated with the images in my game I tried to make them do everything (I associated image files with GPU textures).  This was partially influenced by DirectX’s D3DXCreateTextureFromFile() function, which has definitely made more than just myself think it is correct to let textures have direct access to image files and loading therein.
My second attempt made better use of the single-responsibility principle, and I had a CImage as a member of CTexture2d.  But this was still naïve, as a texture should be absolutely nothing more than bridging the gap between an image and the GPU.  It should’t actually have an image.  It should only take 1 or more as a parameter for bridging that gap.
Finally, the correct solution appears to be the above one.
 
 
L. Spiro
1

Share this post


Link to post
Share on other sites

I had the same before, CImage class inside ITexture class but it's bad, only source path is needed.

Do you store the texture sampler inside the texture class ?

One texture file format could store sampler info.

0

Share this post


Link to post
Share on other sites

Do you store the texture sampler inside the texture class ?

A sampler is a separate object from a texture for a reason. Only in OpenGL would you think of them as being related (and even OpenGL makes them separate in recent versions).

No. Samplers are created elsewhere depending on how the textures are used.
If the texture comes from a model, the model will make a sampler at load-time based on the purpose of the texture (bilinear filtering for diffuse maps, specular maps, normal maps, etc.), existence of mipmaps (trilinear filtering), material wrap modes, and system-wide quality settings (level of anisotropy).

There is no reason an image file should have any notion of a sampler; a single image could be drawn for 2 different purposes and be sampled entirely differently (trilinear/wrap for models vs. nearest-neighbor/clamp for the texture-viewer (either for debug purposes or for tools)).


L. Spiro Edited by L. Spiro
0

Share this post


Link to post
Share on other sites

But in editor you like to set wrap mode and filtering and then set it on the material.

Why it should not be stored here if you like to set it in texture editor ?

Look at this image from unreal engine 4 : https://docs.unrealengine.com/latest/images/Engine/Content/Types/Textures/Properties/Interface/Texture_UI.jpg.

It's a good example, you can see on the right params, unity does the same, maybe crytek ?

In API doc of unreal engine, FTexture is :

api_variable_public.png

SamplerStateRHI

The sampler state to use for the texture.

api_variable_public.png

TextureRHI

The texture's RHI resource.

 

Is it bad to allow to open a current compressed DDS ?

Edited by Alundra
0

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  
Followers 0