Advertisement
Guest User

Untitled

a guest
Aug 1st, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement