Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 /
avatar image
1
Question by Magnus Wolffelt · Aug 19, 2010 at 08:45 PM · shaderterrainemissivesplatmapreplacement

Can you change terrain material?

Hi hi,

is it possible to change the material of a terrain, to.. say for example an emissive shader?

I suspect it's hard due to the terrain shader being specialized for the splatmap stuff, correct?

Would it be possible to write a terrain shader that, instead of blending textures based on the splatmap, blended materials based on the splatmap?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Kansokusha · Jan 09, 2014 at 02:47 PM

Hello guys.

First of all, for @Magnus Wolffelt 's questions:

Yes it is possible to write your own shaders for Terrain. It is a bit complicated but not too much. Basically you should base it on an existing Terrain shader.

There is an article here which is very helpfull: Custom Unity Terrain Material Shaders.

Also check on the wiki, there is an example tweaked shader that allows you to paint transparent textures on your terrain to make portions...well transparent. http://wiki.unity3d.com/index.php/TerrainTransparency

Would it be possible to write a terrain shader that, instead of blending textures based on the splatmap, blended materials based on the splatmap?

Well this one I don't know, @n8 must be correct that it is not possible but it would be interesting if it was. If anyone knows better it would be great to post an answer here :)

As for what @Dagan asked:

I was Looking for the answer to this myself and couldn't find much in my searches. After some testing and trial and error (lots of errors) I finally found something that actually works.

There is a property on Terrain called materialTemplate. It is actually missing form the Reference Documentation on the site, don't know why. So if you have a material called "myMaterial" that uses your own shader you can do something like this:

 public Material referencedMaterial;
 public Terrain referencedTerrain;

and assign "myMaterial" to "Referenced Material" slot of your script (in the inspector). Then later in your code when you want to change your terrain's material just do:

 referencedTerrain.materialTemplate = referencedMaterial;

Hope this helps you, it worked for me :)

NOTE: This works for Unity 4 Pro/Free. Haven't tried in older versions.

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 n8 · Aug 19, 2010 at 09:41 PM

I am no expert by any means but i believe you are trying to use shaders in the wrong way. Shaders blend textures not materials (see here).

if you really wanted to change the material of the terrain you could prob export the material as an .obj import it into an external 3d editor and then tweak it there and reimport as a mesh. from there you can assign any material/shader/texture combo that you want.

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 Magnus Wolffelt · Aug 19, 2010 at 09:57 PM 0
Share

Humm yeah, but then you would lose all the advantages with the terrain engine, such as LODing and the splatmap stuff.

avatar image Magnus Wolffelt · Aug 19, 2010 at 09:58 PM 0
Share

I was actually thinking that the splatmap components could be sub shaders somehow.

avatar image
0

Answer by Dagan · Dec 30, 2013 at 12:19 PM

Hello,

I've have a shader that i modified to work with the terrain. Splats etc.. I can assign it quite easily to the terrain base material slot. Does anyone know if i can do this with c#.

Many Thanks

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 RamiT · Jan 09, 2014 at 07:29 PM

Yes you can, while terrain is selected go to inspector and add texture. Then go to terrain settings and there is material selection.

there is guide http://alastaira.wordpress.com/2013/12/07/custom-unity-terrain-material-shaders/

hope this help. :)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to modify output color of built-in Terrain Shader with more than 4 Splat Textures? 2 Answers

Splat Map with transition texture? 0 Answers

change terrain built in shaders 1 Answer

Adding BRDF lighting to custom Terrain Shader. 0 Answers

Procedural heightmap shader - Normals and tangents 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