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 viktor_k · Nov 12, 2015 at 04:35 PM · terrain shader

Use built in terrain shader for other objects

I am creating a game where I need to replace a small part of a terrain with a plane object in order to manipulate it as I want, I use stencil shaders to not render the terrain object where one of these "tiles" are.

There are two obvious problems, first the shading needs to be exactly the same, the terrain uses the "Nature/Terrain/Standard" shader and I could just use the same shader but the problem is that this shader uses properties which are set by the terrain engine (see the properties box of the "Nature/Terrain/Standard" shader below).

     Properties {
         // set by terrain engine
         _Control ("Control (RGBA)", 2D) = "red" {}
         _Splat3 ("Layer 3 (A)", 2D) = "white" {}
         _Splat2 ("Layer 2 (B)", 2D) = "white" {}
         _Splat1 ("Layer 1 (G)", 2D) = "white" {}
         _Splat0 ("Layer 0 (R)", 2D) = "white" {}
         _Normal3 ("Normal 3 (A)", 2D) = "bump" {}
         _Normal2 ("Normal 2 (B)", 2D) = "bump" {}
         _Normal1 ("Normal 1 (G)", 2D) = "bump" {}
         _Normal0 ("Normal 0 (R)", 2D) = "bump" {}
         [Gamma] _Metallic0 ("Metallic 0", Range(0.0, 1.0)) = 0.0    
         [Gamma] _Metallic1 ("Metallic 1", Range(0.0, 1.0)) = 0.0    
         [Gamma] _Metallic2 ("Metallic 2", Range(0.0, 1.0)) = 0.0    
         [Gamma] _Metallic3 ("Metallic 3", Range(0.0, 1.0)) = 0.0
         _Smoothness0 ("Smoothness 0", Range(0.0, 1.0)) = 1.0    
         _Smoothness1 ("Smoothness 1", Range(0.0, 1.0)) = 1.0    
         _Smoothness2 ("Smoothness 2", Range(0.0, 1.0)) = 1.0    
         _Smoothness3 ("Smoothness 3", Range(0.0, 1.0)) = 1.0
 
         // used in fallback on old cards & base map
         _MainTex ("BaseMap (RGB)", 2D) = "white" {}
         _Color ("Main Color", Color) = (1,1,1,1)
     }

When I try to just use this shader on my tiles it doesn't work because these properties are just the default values and not what is set by the terrain engine. One solution would be to use material.getXXX but it seems impossible to get a reference to the built in material the terrain is using. Any ideas how it can be done?

Secondly I need to get the UV coordinates for each of the splat and the control texture when I replace part of the terrain. How can this be done?

I know this is possible since it is done in the terrain slicing and dynamic loading kit but I have no idea how he's doing it.

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 viktor_k · Nov 12, 2015 at 01:24 PM 0
Share

Ok, getting the metallic, splats, normal and smoothness variables was easy. terrain.terrainData.splatPrototypes[X] contains all that information. I still don't know how to get the control texture and the uv coordinates.

0 Replies

· Add your reply
  • Sort: 

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

Game Crash with WARNING: Shader Unsupported: 'Hidden/Nature/Terrain/Utilities' - All passes removed WARNING: Shader Did you use #pragma only_renderers and omit this platform? 2 Answers

Custom Sun terrain shader 0 Answers

How to change Terrain Shaders at URP 10.4.0 1 Answer

Toon Shading on Terrain Unity 3.4 0 Answers

Terrain not appearing shaded unless very close 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