Giter VIP home page Giter VIP logo

bakeshader's Introduction

BakeShader

Bake

  • Adds "Bake Shader" window (under Window/Cyanilux/BakeShader)
    • Includes modes : Blit2D (png), Blit3D (Texture3D asset), MeshRenderer
  • Also adds "Bake" options to the "..." context menus on Material asset and MeshRenderer component
    • (If BakeShader window is open, this will use resolution & path settings set there, otherwise uses defaults)
  • Should work in any render pipeline!

Setup:

  • Install via Package Manager โ†’ Add package via git URL :
    • https://github.com/Cyanilux/BakeShader.git
  • Alternatively, download and put the folder in your Assets

Notes :

  • Blit2D : Shader is blit (basically draws a quad) to a Texture2D
    • Result saved as .png
  • Blit3D : Shader is blit to a Texture3D in slices
    • Use "_SliceDepth" Float property in shader. This ranges from 0 to 1 through the depth of the Texture3D
    • Result saved as Texture3D asset
  • MeshRenderer : Renderer is drawn to Texture2D
    • Will bake using first Material only
    • Scene View must be open for Renderer baking to occur
    • For correct results, shader should be unlit and output using UV coordinates instead of vertices - to handle this :
      • For graphs, use the provided Bake Shader Vertex Pos subgraph in the Position port on the Vertex stack. Also use Render Face : Both in graph settings.
      • For cg/hlsl, this should work (though some variables may need renaming). The pass should also specify Cull Off :
#pragma multi_compile _ _BAKESHADER

// in vertex function :
#ifdef _BAKESHADER
    float2 remappedUV = IN.uv.xy * 2 - 1;
    float3 bakeShaderPos = float3(remappedUV.x, remappedUV.y, 0);
#else
    float3 bakeShaderPos = IN.vertex;
#endif

OUT.vertex = UnityObjectToClipPos(bakeShaderPos); // Built-in RP
OUT.positionCS = TransformObjectToHClip(bakeShaderPos); // URP

bakeshader's People

Contributors

cyanilux avatar

Stargazers

Mikaelzhou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.