Assignment Goals
The primary goals of this assignment are:
- Extend the core Unreal Engine code.
- Make a change with minimal guidance.
- Develop your own testing strategy for your change.
Overview
There are several things to decide when representing an image in memory:
- Color space: Gray, Gray/Alpha, Red/Green/Blue, Red/Green/Blue/Alpha, Hue/Saturation/Value, L*a*b*, ...
- Channel order: If there's more than one channel, what order are they: RGBA, BGRA, ABGR, ...
- Range: Low Dynamic Range (LDR), for example bytes with range 0–0xff, typically remapped into the 0-1 on use; or High Dynamic Range (HDR), for example floating point, with range 0–∞.
- Data size/precision: Usually specified per channel (e.g. 5 bits, 6 bits, 8 bits, 16 bits, 32 bits)
- Compression: Though reducing data size also achieves a degree of compression, some compression methods result in the image taking even less space, which can give some significant advantages in both storage and memory bandwidth. There most common ones natively supported by modern GPUs operate on 4x4 blocks of texture, and are often identified by number (BC1-7).
In the Unreal Engine, images are stored in several places on the CPU and GPU, each with some specified set or subset of those decisions. Engine code is responsible for converting between them:
- ETextureSourceFormat (TSF_...): CPU data representations that can be used to initialize a texture. If the data isn't in one of the supported formats, either user code will need to convert it, or a new textures source format will need to be added to the engine. There are currently nine of these.
- ERawImageFormat: Same thing for the FImage class. Conversion can happen between images and textures, so these should match the TSF options.
- TextureCompressionSettings (TC_...): Combined specification of a subset of supported GPU formats, including compression, representation, and size. There are currently 17 of these. You can tell which any particular texture used in the Details tab of the texture asset window.
- Texture Format Name: FName for specific Unreal-supported GPU data formats (e.g. NameG16 — created as a static FName declaration, or GTextureFormatNameG16 — created by a ENUM_SUPPORTED_FORMATS macro). There's no central place were these are declared, but instead are created anew in each cpp file that needs them, relying on the fact that two FNames declared with the same string name will match. I found 19 of these in the current code base.
- Pixel Format (PF_...): Full set of GPU-supported image data formats. Some are widely supported, and some by only a few GPUs. Mobile desktop GPUs also tend to support different subsets of these, and there's a mapping table for each mobile platform to turn common ones they don't support into something they do. There are currently 93 of these in the Unreal code. You can tell which of these a texture is using in the Platforms tab of the texture asset window (though you may need to drag lines between the column headings to see the full format name).
There is a 4-channel 16 bit pixel format that is completely supported by the underlying code that talks to the GPU (PF_R16G16B16A16_UNORM), and a 16-bit per component texture source format (TSF_RGBA16). Both of these map the 16-bit color data into a 0-1 color value. However, the intervening code always converts TSF_RGBA16 to either a float or an 8-bit format before it makes it to the GPU. A few places in the code use PF_R16G16B16A16_UINT, which interprets the data as an integer in the range 0-65535 instead of a float in the range 0-1 that the texture source format and _UNORM. There is no path through the code that allows the 16-bit texture source to end up in the equivalent 16-bit pixel format.
For the similar single-channel TSF_G8 and TSF_G16 formats, if you use TC_Grayscale or TC_DisplacementMap, it'll automatically choose either PF_G8 or PF_G16 based on the source format. Your job for this assignment is to add the necessary code so TSF_RGBA16 data using either the TC_VectorDisplacementmap or TC_EditorIcon texture compression settings will make it through to the GPU into a texture using PF_R16G16B16A16_UNORM. For any other texture source (like TSF_BGRA8), these TC settings should map into the PF_B8G8R8A8 format as they do now. Only worry about changes in the core engine, not in any plugins.
Part B details
Modify the engine to pass the 16-bit texture data through from texture source to pixel format. Be sure to do your git add's from the g4g2026 directory to commit your changed engine code files. We won't be able to grade your project if you forget to submit your code because most of it is in the g4g2026/Engine directory this time.
| Detail and Platforms panes for TSF_RGBA16 texture on unmodified engine | Detail and Platforms panes for TSF_RGBA16 texture on modified engine |
|---|---|
![]() |
![]() |
![]() |
![]() |
The code for this project will end up consisting of just a few lines in a handful of files, so unlike previous projects, you will not be graded on having meaningful incremental commits. Instead, you will need to document in your proj6b.txt file what files you found, why you need each change you made, and how it contributes to the process.
- Texture precision test
- I've created a TestGen.cpp that you can use to generate some test textures.
- To use, copy this into your proj6/Source/proj6 directory, and add "UnrealEd" and "AssetTools" to your the build dependencies in your proj6.Build.cs.
- Remember you are building and running proj6 from the UE5.sln. If Unreal does not automatically refresh the UE5.sln on your next proj6 build after you place these files, you may need to run GenerateProjectFiles again yourself. Quit your IDE before you do this, then re-open the UE5.sln or 'UE5 (Mac).xcworkspace' file after.
- It creates a new 'TestGen' console command that takes a single integer argument. Run it form the console command box at the bottom of the UE5 editor window, or by opening the Output Log window.
- Any time you run it, it'll create or update two textures in your Content window: TestRGBA8 (from a TSF_BGRA8 source) and TestRGBA16 (from a TSF_RGBA16 source). The integer argument is the enum value for which texture compression mode to use. "TestGen 5" and "TestGen 7" are the two texture compression modes for this assignment.
- The red and green components of these test textures will be equal to the U and V texture coordinates, but at the texture precision, and the blue component is a scaled version of U+V.
- Feel free to modify this test, or create your own if you find it necessary or helpful.
- I've created a TestGen.cpp that you can use to generate some test textures.
- Make the changes you think you will need to support 16-bit texture data
- You should not need to make edits to any engine header files for this project. Note that if you do save an edit to a header, you'll have to wait through at least a significant partial engine rebuild.
- You will need to edit several engine cpp files. As usual, edits to cpp files will just cause a rebuild of the module in question, and maybe some link updates.
- Follow what happens to TSF_G6, TSF_G16, TSF_BGRA8, and TSF_RGBA16; and TC_Displacementmap, TC_Grayscale, TC_VectorDisplacementmap, and TC_EditorIcon; any Texture Format Names and ERawImageFormats, and ultimately Pixel Formats.
- Take notes, set breakpoints when clicking the test actor Generate button, to build up some knowledge about how these make it through.
- When debugging, if your code if any of your code should cause a printed error that does not break execution in your IDE, remember you can search the error message, and set a breakpoint there.
- Test
- Update the test case, if necessary.
- Check both the Details and Platforms tag to ensure the format is making it through correctly
Submission
Add a proj6b.txt. Tell us what works and what doesn't, and anything else you think we should know for grading.
As stated above, this time you will not be graded on having multiple incremental commits (though you still can). Instead, make sure your proj6b.txt file tells us what files needed to be changed, and what you think your change in each accomplished.
Be sure to include a pointer to screenshots showing both the Detail and Platforms panels confirming your texture handling, and how it appears with the precision test material
Push to your repository, and tag your final commit with an proj6b tag.



