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 niuage · May 16, 2020 at 05:55 PM · shaderpipelineuniversaltessellation

How to use this tessellation cginc with URP?

Here's the code from Catlike Coding:

https://gist.github.com/niuage/ed730f36423f25b8e1f452a828c68808

I've been trying to look up how to use this for a grass shader for URP, without any luck.

First of all, can I include cginc files in HLSLPROGRAM?

And I'm getting errors about UNITY_domain and company not being defined, but I'm having a hard time finding what they should be replaced with for them to work in HLSLPROGRAM.

Any help or just small pointers would be very appreciated!

ps: what I'm trying to do overall is add tessellation to this shader: https://twitter.com/Cyanilux/status/1255870774558232582

Comment
Add comment
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

1 Reply

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

Answer by Namey5 · May 17, 2020 at 03:55 AM

Whilst you can include CG files in HLSL, that whole include script is already basically in HLSL, so you can just convert the file extension from '.cginc' to '.hlsl' and use that instead. As for the errors, 'UNITY_domain' etc. are macros that expand to the relative tessellation keywords on platforms that support it and are defined in the legacy "HLSLSupport.cginc" which used to be automatically included with any CGPROGRAM. All you need to do to get that to work here however is to just copy those defines into the beginning of the tessellation include;

 // Tessellation programs based on this article by Catlike Coding:
 // https://catlikecoding.com/unity/tutorials/advanced-rendering/tessellation/
 
 #if defined(SHADER_API_D3D11) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL)
 #define UNITY_CAN_COMPILE_TESSELLATION 1
 #   define UNITY_domain                 domain
 #   define UNITY_partitioning           partitioning
 #   define UNITY_outputtopology         outputtopology
 #   define UNITY_patchconstantfunc      patchconstantfunc
 #   define UNITY_outputcontrolpoints    outputcontrolpoints
 #endif
 
 struct vertexInput
 {
     float4 vertex : POSITION;
     float3 normal : NORMAL;
     float4 tangent : TANGENT;
 };
 
 ...
Comment
Add comment · Show 3 · 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 niuage · May 17, 2020 at 06:05 AM 0
Share

Second time you helped me out Namey! thx ;) Funnily enough I had already tried the cginc -> hlsl change as well as trying to define UNITY_domain & co, but didnt go the whole way.

Now, it compiles fine, but... nothing shows up, regardless of the tessellation factor I enter... In case you want to take a look, here's a tiny repo containing a couple files. https://github.com/niuage/Grass-Shader-With-Tessellation - but that's another problem, so dont worry about it if you dont have free time :)

avatar image Namey5 niuage · May 17, 2020 at 09:35 AM 0
Share

I'm not really familiar with URP, but at first glance you have multiple different functions named 'vert' that serve different purposes, so I would go through and make sure you are only using one vertex function and that it does what you need. Also, you will probably need to have a custom shadowcaster/depth pass otherwise it may not be drawn correctly (I'm assu$$anonymous$$g URP uses a depth prepass like the built-in renderer did).

avatar image niuage Namey5 · May 19, 2020 at 08:14 AM 1
Share

https://www.youtube.com/watch?v=8_xCX9mG$$anonymous$$5c

I got it working \o/

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

195 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 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

I would like to know how to make a tessellation shader with LightWeightRenderPipline(Unity2018.2.13) 0 Answers

How to do texture bombing in shader graph 0 Answers

Is it possible to pass scene color to Sample Texture 2D LOD (URP, Shader Graph)? 0 Answers

Edit Offset Values in Unity URP Lit Shader via Script 0 Answers

How to adapt this shader to URP? 1 Answer


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