Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
This question was closed Mar 04, 2016 at 07:34 PM by Graphics_Dev for the following reason:

The question is answered, right answer was accepted

avatar image
2
Question by Graphics_Dev · Mar 03, 2016 at 09:45 PM · shadercustomgrassbuilt-inoverwrite

How can I overwrite the built-in grass shader?

I am trying to overwrite the built-in terrain grass shader so that I can edit it. I have imported the built-in grass shader to work off of, but my terrain seems to not be using the imported shader. No matter what I do with the shader, my grass still looks the same. I have no errors or warnings, and I have not renamed or changed the built-in shader that I downloaded.

(I am using Unity 5.3.1)

Thank you for your time, I would greatly appreciate any input.

This is the shader I downloaded (I am aware that non-billboarded grass uses a different shader, and my grass is set to billboard):

 Shader "Hidden/TerrainEngine/Details/BillboardWavingDoublePass" {
     Properties {
         _WavingTint ("Fade Color", Color) = (.7,.6,.5, 0)
         _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}
         _WaveAndDistance ("Wave and distance", Vector) = (12, 3.6, 1, 1)
         _Cutoff ("Cutoff", float) = 0.5
     }
     
 CGINCLUDE
 #include "UnityCG.cginc"
 #include "TerrainEngine.cginc"
 
 struct v2f {
     float4 pos : SV_POSITION;
     fixed4 color : COLOR;
     float4 uv : TEXCOORD0;
 };
 v2f BillboardVert (appdata_full v) {
     v2f o;
     WavingGrassBillboardVert (v);
     o.color = v.color;
     
     o.color.rgb *= ShadeVertexLights (v.vertex, v.normal);
         
     o.pos = mul (UNITY_MATRIX_MVP, v.vertex);    
     o.uv = v.texcoord;
     return o;
 }
 ENDCG
 
     SubShader {
         Tags {
             "Queue" = "Geometry+200"
             "IgnoreProjector"="True"
             "RenderType"="GrassBillboard"
             "DisableBatching"="True"
         }
         Cull Off
         LOD 200
         ColorMask RGB
                 
 CGPROGRAM
 #pragma surface surf Lambert vertex:WavingGrassBillboardVert addshadow exclude_path:deferred
             
 sampler2D _MainTex;
 fixed _Cutoff;
 
 struct Input {
     float2 uv_MainTex;
     fixed4 color : COLOR;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
     o.Albedo = c.rgb;
     o.Alpha = c.a;
     clip (o.Alpha - _Cutoff);
     o.Alpha *= IN.color.a;
 }
 
 ENDCG            
     }
 
     Fallback Off
 }
 


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

  • Sort: 
avatar image
1
Best Answer

Answer by phil_me_up · Mar 04, 2016 at 07:20 PM

EDIT: From the comments below: "I found that it needed to refresh the grass somehow. I noticed this because I painted some more grass then hit ctrl-z and my grass refreshed with the new shader."

OK, not sure what's going on here but here's what I did to test:

  1. Made a basic terrain

  2. Created a new 'grass' detail (billboard etc)

  3. Painted it on to test. Everything is fine.

  4. I then created a new shader file (I just called it "MyGrassShader")

  5. Replaced the entire contents with what you provided above and everything was still fine

  6. I then just added 'c.r =1.0'' on line 55 to force the r channel to 1

  7. The detail changed to be more red.

  8. If I make a deliberate mistake then I get errors in the console as you would expect

So, as far as I can see this all works and the only thing I've done different is to basically rename the file as "MyGrassShader".

To confirm, this was a completely new, empty project on unity 5.3.3f1

Not sure if that helps or not, but at least it's something!

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 Graphics_Dev · Mar 04, 2016 at 07:34 PM 0
Share

Thanks for the answer. I tried playing with it some more and I found that it needed to refresh the grass somehow. I noticed this because I painted some more grass then hit ctrl-z and my grass refreshed with the new shader.

I accepted your answer...if you could edit it to specify that you may need to paint then undo to refresh your terrain I'd appreciate it and I'm sure others who see this later will appreciate it too ;)

avatar image Wappenull · Apr 13, 2020 at 06:11 PM 0
Share

Hi from future. Unity 2019.3, still confirmed has to paint detail and Ctrl+Z to refresh shader replacement, even restarting editor didn't help. :/

Follow this Question

Answers Answers and Comments

53 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

Related Questions

SSAO showing through objects with custom shader 2 Answers

replacement grass billboard shader not working in build 0 Answers

Mix two shaders 0 Answers

Disable grass fade 1 Answer

Custom Transparency shader occasionally losing transparency? 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