Assignment Goals

The primary goals of this assignment are:

  1. Extend the core Unreal Engine code.
  2. Make a change with minimal guidance.
  3. Develop your own testing strategy for your change.

Overview

There are several things to decide when representing an image in memory:

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:

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
Details pane without 16-bit support, format is R8G8B8A8 Details pane with 16-bit support, format is RGBA16
Platforms pane without 16-bit support, pixel PF_B8G8R8A8 Platforms pane with 16-bit support, pixel format is PF_R16G16B16A16_UNORM

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.

  1. 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.
  2. 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.
  3. 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.