Skip to content

Instantly share code, notes, and snippets.

@pixelmager
Last active October 19, 2022 15:03
Show Gist options
  • Save pixelmager/406b1fdcba02136c836db9663768b871 to your computer and use it in GitHub Desktop.
Save pixelmager/406b1fdcba02136c836db9663768b871 to your computer and use it in GitHub Desktop.
Unity HDR screenshot
if ( DoHDRscreenshot )
{
DoHDRscreenshot = false;
int w = source.width;
int h = source.height;
RenderTexture rt_hdr = RenderTexture.GetTemporary( w, h, 0, RenderTextureFormat.ARGBHalf );
Finalpass( source, rt_hdr, bloom_rt, distortion_rt, distparms ); //note: final posteffects pass
Texture2D tex_hdr = new Texture2D( rt_hdr.width, rt_hdr.height, TextureFormat.RGBAHalf, false );
Graphics.SetRenderTarget( rt_hdr );
tex_hdr.ReadPixels( new Rect(0,0,rt_hdr.width,rt_hdr.height), 0, 0 );
tex_hdr.Apply();
Color[] cols = tex_hdr.GetPixels();
//note: from http://wiki.unity3d.com/index.php/MiniEXR
MiniEXR.MiniEXR.MiniEXRWrite( "hdrshot.exr", (uint)w, (uint)h, cols);
RenderTexture.ReleaseTemporary(rt_hdr);
}
@pixelmager
Copy link
Author

well that was easy..!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment