SHARE
TWEET

Untitled

a guest Aug 1st, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //baking the material into a texture format we can read... because we can't getpixel on render textures!
  2.             //renderTexture = new RenderTexture(generatorSize, generatorSize, 24, RenderTextureFormat.BGRA32, 0);
  3.             renderTexture = new RenderTexture(generatorSize, generatorSize, 32, RenderTextureFormat.ARGBFloat);
  4.             renderTexture.Create();
  5.             Graphics.Blit(null, renderTexture, generatorMat);
  6.  
  7.             //transfer image from rendertexture to texture
  8.             mapTexture = new Texture2D(generatorSize, generatorSize, TextureFormat.RGBAFloat, false);
  9.             RenderTexture.active = renderTexture;
  10.             mapTexture.ReadPixels(new Rect(Vector2.zero, new Vector2(generatorSize, generatorSize)), 0, 0);
  11.             mapTexture.Apply();
  12.             Shader.SetGlobalTexture("MapTexture", mapTexture);
  13.             shorelinemat.SetTexture("_MapTexture", mapTexture);
  14.             Shader.SetGlobalFloat("MapSize", generatorSize);
  15.             //clean up variables
  16.             RenderTexture.active = null;
  17.             //RenderTexture.ReleaseTemporary(renderTexture);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top