Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JonPQ · May 18, 2020 at 06:27 PM · renderingshadersshader programming

Manual shaders in URP/HDRP

What are the rules for manually writing shaders that render in the new Render Pipe-lines. The update shaders option just replaces them all.... so all existing custom functionality is lost... but...they still compile ok, they just render magenta? so are they broken or not ? How do we manually write a custom shader that renders properly in URP ? What are the requirements/spec please? I cant find anything in the official documentation. thanks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JonPQ · May 18, 2020 at 06:53 PM 0
Share

also, can you see the performance of the shader that shaderGraph is building ? It would be nice if there was some kind of stats window for the shader.... showing number of texture reads, interpolators, and instructions per pixel and per vertex. Does that exist ?

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Namey5 · May 19, 2020 at 01:55 AM

Here is a good template you can use as a basis for writing shaders for URP;

https://gist.github.com/phi-lira/225cd7c5e8545be602dca4eb5ed111ba

You'll need a few things to get a shader to draw in the new render pipelines. The main thing to note is that the new pipelines now work exclusively with single pass shaders, hence why the old multi-pass lit shaders are disabled.


To start, you'll need to specify what RP you are working with in the subshader tags;

 Tags {"RenderType"="Opaque" "RenderPipeline"="UniversalRenderPipeline" "IgnoreProjector"="True"}

You will also need to specify what each pass does through a LightMode tag;

 //For the main URP lit pass
 Tags { "LightMode"="UniversalForward" }

From there, the only main difference aside from lighting is that shaders are now written in HLSL instead of CG. The syntax is the same, but it won't have the old includes that CGPROGRAM used to use automatically, meaning you may have to rewrite some functions yourself ('LinearEyeDepth', etc). For the above reasons, surface shaders are also no longer compatible.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JonPQ · May 19, 2020 at 04:30 PM 0
Share

awesome! thanks, this is perfect, it should be in the unity docs, in the same section as upgrading shaders.

avatar image JonPQ JonPQ · May 22, 2020 at 04:53 PM 0
Share

do you know of a way to get performance stats of shaderGraph shaders? e.g. number of vert and frag instructions used, number of texture reads, etc... ?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

160 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[Deferred Decals] Add simple specular channel to deffered decals 0 Answers

Problems with Depth Normals and variable CullMode 0 Answers

Rendering volumetric objects and maintaining correct depth 1 Answer

Converting c# function to shader. 0 Answers

Scene Color Node in Shader Graph not working with Unity's 2D Renderer and URP 5 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges