public Texture MirrorHeightTexture(TextureWithSize textureWithSize) { var renderMaterial = new Material(Shader.Find("Custom/TerGen/MirrorHeightTexture")); renderMaterial.SetTexture("_SourceTexture", textureWithSize.Texture); var textureSize = textureWithSize.Size; return(UltraTextureRenderer.CreateRenderTexture(renderMaterial, new RenderTextureInfo(textureSize.X, textureSize.Y, RenderTextureFormat.ARGB32, true))); }
public Texture FufillOrder(TextureRenderingTemplate template) { var outTextureInfo = template.OutTextureInfo; var shaderName = template.ShaderName; var pack = template.UniformPack; var material = new Material(Shader.Find(shaderName)); template.Keywords.EnableInMaterial(material); if (template.Coords != null) { pack.SetUniform("_Coords", template.Coords.ToVector4()); } pack.SetUniformsToMaterial(material); var renderTextureFormat = template.RenderTextureFormat; Texture outTexture = null; if (template.CreateTexture2D) { Preconditions.Assert(!template.RenderTextureArraySlice.HasValue, "E629 RenderTextureArrays are not supported here"); RenderTextureInfo renderTextureInfo = new RenderTextureInfo(outTextureInfo.Width, outTextureInfo.Height, renderTextureFormat, template.RenderTextureMipMaps); outTexture = UltraTextureRenderer.RenderTextureAtOnce(material, renderTextureInfo, outTextureInfo); } else { if (template.RenderingRectangle == null) { Preconditions.Assert(!template.RenderTextureArraySlice.HasValue, "E629 RenderTextureArrays are not supported here"); RenderTextureInfo renderTextureInfo = new RenderTextureInfo(outTextureInfo.Width, outTextureInfo.Height, renderTextureFormat, template.RenderTextureMipMaps); outTexture = UltraTextureRenderer.CreateRenderTexture(material, renderTextureInfo); } else { if (template.RenderTextureArraySlice.HasValue) { UltraTextureRenderer.ModifyRenderTextureArray(material, template.RenderingRectangle, template.RenderTargetSize , template.RenderTextureToModify, template.RenderTextureArraySlice.Value); } else { UltraTextureRenderer.ModifyRenderTexture(material, template.RenderingRectangle, template.RenderTargetSize, template.RenderTextureToModify); } return(template.RenderTextureToModify); } } //GameObject.Destroy(material); return(outTexture); }
public void MyLateOnRenderImage(RenderTexture src, RenderTexture dest) { if (_requestedScreenshot && (_requestedScreenshotFrame == Time.frameCount)) { var artisticRenderTex = _testingRunner.RenderTargets.ArtisticMainTexture; var artisticTex2D = UltraTextureRenderer.RenderTextureToTexture2D(artisticRenderTex); SavingFileManager.SaveTextureToPngFile($"{_measurementsPath}/ArtisticTex.{_testingRunner.RequestedTestFrame}.png", artisticTex2D); GameObject.Destroy(artisticTex2D); _requestedScreenshot = false; } }
public async Task <Texture> MirrorHeightTextureAsync(TextureWithSize textureWithSize) { return(await _commonExecutor.AddAction(() => { var renderMaterial = new Material(Shader.Find("Custom/TerGen/MirrorHeightTexture")); renderMaterial.SetTexture("_SourceTexture", textureWithSize.Texture); var textureSize = textureWithSize.Size; return UltraTextureRenderer.CreateRenderTexture(renderMaterial, new RenderTextureInfo(textureSize.X, textureSize.Y, RenderTextureFormat.ARGB32, true)); })); }
public RenderTexture EncodedHeightTextureToPlain(TextureWithSize encodedTexture) { var renderMaterial = new Material(Shader.Find("Custom/TerGen/RgbaToRFloat")); renderMaterial.SetTexture("_SourceTexture", encodedTexture.Texture); var textureSize = encodedTexture.Size; var renderTextureInfo = new RenderTextureInfo(textureSize.X, textureSize.Y, RenderTextureFormat.RFloat, true); var tex = UltraTextureRenderer.CreateRenderTexture(renderMaterial, renderTextureInfo); return(tex); }
public async Task <Texture2D> PlainToEncodedHeightTextureAsync(TextureWithSize plainTexture) { return(await _commonExecutor.AddAction(() => { var renderMaterial = new Material(Shader.Find("Custom/TerGen/RFloatToRgba")); renderMaterial.SetTexture("_SourceTexture", plainTexture.Texture); var textureSize = plainTexture.Size; var renderTextureInfo = new RenderTextureInfo(textureSize.X, textureSize.Y, RenderTextureFormat.ARGB32); ConventionalTextureInfo outTextureinfo = new ConventionalTextureInfo(textureSize.X, textureSize.Y, TextureFormat.ARGB32, false); return UltraTextureRenderer.RenderTextureAtOnce(renderMaterial, renderTextureInfo, outTextureinfo); })); }
public LocalTexture Skeletonize(Texture hatchMainTexture) { Graphics.Blit(hatchMainTexture, _outTexture0, _skeletonizerMaterial, 1); for (int i = 0; i < _tapsCount; i++) { var src = CurrentRenderTexture; _currentOutTexture = (_currentOutTexture + 1) % 2; var dst = CurrentRenderTexture; Graphics.Blit(src, dst, _skeletonizerMaterial, 0); } return(LocalTexture.FromTexture2D(UltraTextureRenderer.RenderTextureToTexture2D(CurrentRenderTexture))); }
private void GenerateTexture() { var heightTexture1 = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\temp3.png", 240, 240, TextureFormat.RGBA32, true, true); Material material = new Material(Shader.Find("Custom/TerGen/ErosionThermal")); material.SetTexture("_MainInputTex", heightTexture1); RenderTextureInfo renderTextureInfo = new RenderTextureInfo(240, 240, RenderTextureFormat.ARGB32); ConventionalTextureInfo outTextureInfo = new ConventionalTextureInfo(240, 240, TextureFormat.ARGB32, false); OutputTexture = UltraTextureRenderer.RenderTextureAtOnce(material, renderTextureInfo, outTextureInfo); OutputShowingObject.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", OutputTexture); }
private MeasurementScreenshotsSet GenerateScreenshotsSet() { UltraTextureRenderer.RenderIntoExistingTexture2D(_hatchMainRenderTexture, this._hatchMainTex2D); UltraTextureRenderer.RenderIntoExistingTexture2D(_idRenderTexture, this._hatchIdTex2D); UltraTextureRenderer.RenderIntoExistingTexture2D(_worldPos1RenderTexture, this._worldPos1Tex2D); UltraTextureRenderer.RenderIntoExistingTexture2D(_worldPos2RenderTexture, this._worldPos2Tex2D); return(new MeasurementScreenshotsSet() { HatchIdTexture = LocalTexture.FromTexture2D(_hatchIdTex2D), HatchMainTexture = LocalTexture.FromTexture2D(_hatchMainTex2D), WorldPosition1Texture = LocalTexture.FromTexture2D(_worldPos1Tex2D), WorldPosition2Texture = LocalTexture.FromTexture2D(_worldPos2Tex2D), }); }
private void WriteRenderTargetsToFile() { var targetDirectory = @"C:\tmp\diagrams\mmRenderTargets\"; Directory.CreateDirectory(targetDirectory); SavingFileManager.SaveTextureToPngFile(targetDirectory + "/artistic.png", UltraTextureRenderer.RenderTextureToTexture2D(MeasurementRenderTargets.ArtisticMainTexture)); SavingFileManager.SaveTextureToPngFile(targetDirectory + "/worldPos.png", UltraTextureRenderer.RenderTextureToTexture2D(_worldPositionRenderTarget)); SavingFileManager.SaveTextureToPngFile(targetDirectory + "/vectors.png", UltraTextureRenderer.RenderTextureToTexture2D(_vectorsRenderTarget)); //var dummyTex2D = UltraTextureRenderer.RenderTextureToTexture2D(_dummyStage1Texture); //SavingFileManager.SaveTextureToPngFile(targetDirectory + "/dummy.png", dummyTex2D); //SavingFileManager.SaveTextureToPngFile(targetDirectory + "/dummyL1.png", dummyTex2D.RetriveMipmapAsTexture(1)); //SavingFileManager.SaveTextureToPngFile(targetDirectory + "/dummyL1.png", dummyTex2D.RetriveMipmapAsTexture(2)); }
private async Task <Texture2D> ChangeNormalTextureToTexture2DAsync(Texture inputTexture) { if (inputTexture is Texture2D) { return(inputTexture as Texture2D); } if (inputTexture is RenderTexture) { return(await _commonExecutor.AddAction( () => UltraTextureRenderer.RenderTextureToTexture2D(inputTexture as RenderTexture))); } else { Preconditions.Fail("Cannot change texture " + inputTexture + " to texture2D"); return(null); } }
private async Task <Texture2D> ChangeTextureToTexture2DAsync(Texture inputTexture) { Preconditions.Assert(inputTexture != null, "Input texture is null"); if (inputTexture is Texture2D) { return(inputTexture as Texture2D); } if (inputTexture is RenderTexture) { return(await _commonExecutor.AddAction( () => UltraTextureRenderer.RenderTextureToTexture2D(inputTexture as RenderTexture))); } else { Preconditions.Fail("Cannot change texture " + inputTexture + " to texture2D. Type is " + inputTexture.GetType()); return(null); } }