# The gamma value in RenderTarget seem to not work。

**URL:** <https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799>\
**Category:** Rendering\
**Tags:** rendertarget, unreal-engine, question\
**Created:** [March 25, 2018, 7:17am UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799 "2018-03-25T07:17:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_11293419d6b2b0bc25dd65b9f576eea0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_11293419d6b2b0bc25dd65b9f576eea0](https://forums.unrealengine.com/u/Anonymous_11293419d6b2b0bc25dd65b9f576eea0)\
**Post date:** [March 25, 2018, 7:17am UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/1 "2018-03-25T07:17:51Z")

</div>

How many times I change the gamma value in RenderTarget. But the result is not any change. I just want to know if this value is really work.

 ![234947-rendertarget.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/c/79c33de10d3c0f8181c1ecfbbf8b460027c53a9e.png)

 ![234948-result.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/2/67265bf23d42e4da563d99c0ec592f4a6e32bda0.jpeg)

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [October 30, 2024, 9:44am UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/2 "2024-10-30T09:44:52Z")

</div>

Does not work for me in UE5.2 either.

---

<div class="post-metadata">

**Author:** ![comlys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/comlys/32/998665_2.png) [@comlys](https://forums.unrealengine.com/u/comlys)\
**Post date:** [October 30, 2024, 8:21pm UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/3 "2024-10-30T20:21:18Z")

</div>

You need to set your scene capture to final color. IIRC, you need Final Color for the gamma on the render target to be applied since that’s the “Output Device” stage of the post-process pipeline.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/c/77ce155f3bbbc645e05092f6a29965073f30bcc4.png)

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [October 31, 2024, 1:37am UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/4 "2024-10-31T01:37:04Z")

</div>

Thanks for the suggestion. This is the issue I have.

- I am developing a tool that exports scene capture 2Ds from the editor to PNGs.
- When I use _Capture Every Frame_, everything looks correct in the render target, but the exported PNG is empty.
- When I disable _Capture Every Frame_ and call _CaptureScene_ in C++, the shadow in the render target is very darker than in the viewport. However, I can export to PNG using this method.
- I use _Final Color (with tone curve)_ for the scene captures and use _RGBA8\_sRGB_ for the render target. I also tried _Final Color (LDR)_ with both _RGBA8_ and _RGBA8\_sRGB_ but I still have the same issue.

---

<div class="post-metadata">

**Author:** ![comlys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/comlys/32/998665_2.png) [@comlys](https://forums.unrealengine.com/u/comlys)\
**Post date:** [October 31, 2024, 5:53pm UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/5 "2024-10-31T17:53:06Z")

</div>

I’m not sure off hand. Could it be Lumen? Have you enabled it in your scene capture?

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [November 1, 2024, 1:02am UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/6 "2024-11-01T01:02:55Z")

</div>

Yes, I enabled and it looked correct when _Capture Every Frame_ is enabled.

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [November 1, 2024, 12:32pm UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/7 "2024-11-01T12:32:08Z")

</div>

I think this is the problem.

The engine makes the view state null when _Capture Every Frame_ turned off.  
[https://github.com/EpicGames/UnrealEngine/blob/02dc8dbdd89f749cd5500376e9bb87271bf64848/Engine/Source/Runtime/Engine/Private/Components/SceneCaptureComponent.cpp#L390-L394](https://github.com/EpicGames/UnrealEngine/blob/02dc8dbdd89f749cd5500376e9bb87271bf64848/Engine/Source/Runtime/Engine/Private/Components/SceneCaptureComponent.cpp#L390-L394)

And the engine only adds lumen data to scene capture rendering when the view state is not null with other conditions.  
[https://github.com/EpicGames/UnrealEngine/blob/02dc8dbdd89f749cd5500376e9bb87271bf64848/Engine/Source/Runtime/Renderer/Private/SceneCaptureRendering.cpp#L866-L876](https://github.com/EpicGames/UnrealEngine/blob/02dc8dbdd89f749cd5500376e9bb87271bf64848/Engine/Source/Runtime/Renderer/Private/SceneCaptureRendering.cpp#L866-L876)

This explains why I only have correct shadows when enabling _Capture Every Frame_. But doing so prevent me from exporting the PNG properly.

---

<div class="post-metadata">

**Author:** ![lehuan5062](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@lehuan5062](https://forums.unrealengine.com/u/lehuan5062)\
**Post date:** [November 1, 2024, 1:14pm UTC](https://forums.unrealengine.com/t/the-gamma-value-in-rendertarget-seem-to-not-work/420799/8 "2024-11-01T13:14:23Z")

</div>

The alpha when _Capture Every Frame_ is enabled is none.

Edit: My workaround is adding alpha in C++ before saving. The PNG now looks correct when _Always Persist Rendering State_ or _Capture Every Frame_ is enabled.

```auto
if (format == ETextureRenderTargetFormat::RTF_RGBA8 || format == ETextureRenderTargetFormat::RTF_RGBA8_SRGB)
{
	const auto colors{ reinterpret_cast<FColor*>(image.RawData.GetData()) };

	if (colors)
	{
		for (int64 index{ 0 }; index < image.GetNumPixels(); index++)
		{
			colors[index].A = 255u;
		}
	}
}

```

Edit: not really, **it only works at day time**. Morning time is still very dark

Edit: I think the UDS is messing with the post process of the scene and the scene capture will have to adapt to it.
