Shader Graph Baker
  • Shader Graph Baker
  • Node Settings
  • Baking Single Texture
  • Baking Normal Map
  • Baking Image Sequences
  • Runtime Texture Baking
  • Help & Contact
Powered by GitBook
On this page

Runtime Texture Baking

Last updated 6 months ago

For runtime texture baking, first, it is necessary to bake Shader Graph nodes into a .shader file. This is done by the Bake Shader button:

Only the nodes connected to the Shader Graph Baker are used in the generated .shader file.

After baking a .shader, it can be used in runtime scripts by creating a material using this shader. Properties of this material can be adjust in runtime too using Unity methods like , , and etc.

Run-time API for baking material into a texture can be brought into scope with this using directive:

using AmazingAssets.ShaderGraphBaker;

Texture2D BakeTexture2D(int resolution, bool hasMipmap, bool linear)

resolution - Generated texture's resolution.

hasMipmap - should the created texture contain mipmaps?

linear - if baking a Normal or Linear Data type shader, then this value should be true. It is false for Color Map texture.

void UpdateRenderTexture(ref RenderTexture renderTexture)

Renders material into the provided renderTexture. For rendering Normal and Linear Data, make sure the renderTexture is created using the linear flag.

Unity class now will have 2 additional extension methods:

Creates object and renders material into it.

Material
Texture2D
SetFloat
SetVector
SetColor