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 Socapex · Jul 26, 2016 at 02:48 PM · shadersshaderlabsurface shadervertex shaderfragment

Can you specify both Surface and Vertex/Fragment shaders?

So I am working on a super basic shader. Is it possible to use both surface and vert+frag? From surface -> vert -> frag.

Basically, I want the shader to be physically based, support most features of unity lighting for my artist. All I need is to add a few things on top of a "traditional" unity shader.

Thx

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

3 Replies

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

Answer by Socapex · Jul 27, 2016 at 12:22 AM

Yes you can, I found the answer here (thank you Farfarer)

 Shader "Blee" {
     Properties {
     }
     SubShader{
         Pass
         {
             CGPROGRAM
             // Vertex and fragment shader here.
             ENDCG
         }
  
         Pass
         {
             CGPROGRAM
             // More if you want, you can use Blend and all.
             ENDCG
         }
  
         CGPROGRAM
         // Surface shader here.
         ENDCG
     }
    
     Fallback "Blou"
 }


You can also control when the passes are applied by writing your surface shader before (I haven't tried in between though).

Using this method, you can use the nice Standard Shader with all the fancy physically based stuff, and add/blend specialized things your artist demands.

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

Answer by Bunny83 · Jul 26, 2016 at 04:09 PM

Surface shaders are a highlevel method of writing shaders. The compiler actually creates a vertex and a fragment shader out of your surface shader since that's the only thing the GPU understands / supports. However a surface shader can result even in several passes with different vert/frag shaders.

You might want to take a look at Writing SurfaceShaders.

It's hard to answer your question without anything more concrete. Unity's lighting models are quite complex. Depending on the renderpath lighting might be done in seperate shader passes. "Traditional" shader code might not be compatible with that.

Also see Aras answer over here.

Comment
Add comment · Show 1 · 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 Socapex · Jul 27, 2016 at 12:16 AM 0
Share

I wanted to mix a surface shader for the base pass, then mix fragment additions. I found the answer I was looking for (adding it here).

avatar image
0

Answer by RJ45 · Jul 31, 2016 at 06:51 PM

You can in multiple passes but one pass will write on top of the other obviously. What you probably want. what your question actually is, is how to write to some frag pass which the surface shader takes in as albedo texture (mainTex). That I don't know how to do off the top of my head but would be interested in knowing how. Should be able to do it somehow now that you said it this way.

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

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

55 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

Related Questions

Is it possible to read light value per vertex with a shader? 0 Answers

Issue with the merging of a surface shader and vert/frag shader using UNITY_MATRIX_MVP 0 Answers

viewDir changes with o.Normal 1 Answer

Can I have a surface shader and a fragment shader on the same mesh? 0 Answers

How to convert surface shader to Vertex/Fragment code? 0 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