In an HTML5 build, rendering a UTexture2D
to a URenderTarget2D
causes the image to lose color. I’m not familiar with linear color terminology, but it has something to do with that and sRGB. If I took that URenderTarget2D
and render it to another URenderTarget2D
, eventually the image will be solid black. UCanvasRenderTarget2D
exhibits the same behavior as the URenderTarget2D
.
In these example images, the plane on the left is the unlit image, the plane in the middle is the lit image, and the plane on the right is after rendering that image to a URenderTarget2D
.
HTML5 Chrome Version 62.0.3202.75 (Official Build) (64-bit) & Firefox 56.0.2 (64-bit)
PIE/Win10 64-bit Build
Notice how the third plane has less color in the HTML5 build vs the Editor/Win64 build. I would expect them to be the same.
Steps to reproduce:
- Make a new project. I chose C++ Third Person with no Starter Content.
- Add a plane to the scene with the material that has the render target.
- Add a button to the HUD or some other way to trigger the render to the render target.
- Create a 512x512
URenderTarget2D
- Add the code to do the render target rendering.
- Package for HTML5 and try in Chrome or Firefox. Compare that to PIE/Win10 64-bit.
Code for render target rendering:
Plane3Material->GetTextureParameterValue(FName("RT"), RT);
BrushRenderMat_Dynamic = UMaterialInstanceDynamic::Create(BrushRenderMat, this);
BrushRenderMat_Dynamic->SetTextureParameterValue("Tex", TestTexture);
UKismetRenderingLibrary::DrawMaterialToRenderTarget(this, Cast<UTextureRenderTarget2D>(RT), BrushRenderMat_Dynamic);
Material on the Plane
Material for rendering to the render target
Image that I’m using