This commit is contained in:
王志勋 2025-11-04 16:59:49 +08:00
parent 8536a5808a
commit 2e27bd5491
1 changed files with 19 additions and 22 deletions

View File

@ -294,32 +294,29 @@ namespace RenderHeads.Media.AVProVideo.Editor
GL.sRGBWrite = false;
RenderTexture rt2 = null;
// TODO: move this all into VideoRender as a resolve method
{
Material materialResolve = new Material(Shader.Find(VideoRender.Shader_Resolve));
VideoRender.SetupVerticalFlipMaterial(materialResolve, _thumbnailPlayer.RequiresVerticalFlip());
VideoRender.SetupAlphaPackedMaterial(materialResolve, _thumbnailPlayer.GetTextureAlphaPacking());
VideoRender.SetupGammaMaterial(materialResolve, !_thumbnailPlayer.PlayerSupportsLinearColorSpace());
Material materialResolve = new Material(Shader.Find(VideoRender.Shader_Resolve));
VideoRender.SetupVerticalFlipMaterial(materialResolve, _thumbnailPlayer.RequiresVerticalFlip());
VideoRender.SetupAlphaPackedMaterial(materialResolve, _thumbnailPlayer.GetTextureAlphaPacking());
VideoRender.SetupGammaMaterial(materialResolve, !_thumbnailPlayer.PlayerSupportsLinearColorSpace());
RenderTexture prev = RenderTexture.active;
RenderTexture prev = RenderTexture.active;
// Scale to fit and downsample
rt2 = RenderTexture.GetTemporary(128, 128, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
// Scale to fit and downsample
rt2 = RenderTexture.GetTemporary(128, 128, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
RenderTexture.active = rt2;
GL.Clear(false, true, new Color(0f, 0f, 0f, 0f));
ScaleMode scaleMode = ScaleMode.ScaleToFit;
if (_zoomToFill)
{
scaleMode = ScaleMode.ScaleAndCrop;
}
VideoRender.DrawTexture(new Rect(0f, 0f, 128f, 128f), _thumbnailPlayer.GetTexture(), scaleMode, _thumbnailPlayer.GetTextureAlphaPacking(), _thumbnailPlayer.GetTexturePixelAspectRatio(), materialResolve);
RenderTexture.active = prev;
RenderTexture.active = rt2;
GL.Clear(false, true, new Color(0f, 0f, 0f, 0f));
ScaleMode scaleMode = ScaleMode.ScaleToFit;
if (_zoomToFill)
{
scaleMode = ScaleMode.ScaleAndCrop;
}
VideoRender.DrawTexture(new Rect(0f, 0f, 128f, 128f), _thumbnailPlayer.GetTexture(), scaleMode, _thumbnailPlayer.GetTextureAlphaPacking(), _thumbnailPlayer.GetTexturePixelAspectRatio(), materialResolve);
RenderTexture.active = prev;
Material.DestroyImmediate(materialResolve); materialResolve = null;
}
Texture2D readTexture = new Texture2D(128, 128, TextureFormat.RGBA32, true, false);
Material.DestroyImmediate(materialResolve); materialResolve = null;
Texture2D readTexture = new Texture2D(128, 128, TextureFormat.RGBA32, true, false);
Helper.GetReadableTexture(rt2, readTexture);
MediaReference mediaRef = (this.targets[_targetIndex]) as MediaReference;
mediaRef.GeneratePreview(readTexture);