Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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 /
avatar image
0
Question by mofselvi · Aug 08, 2016 at 01:09 PM · shadermaterialnormalmapmesh renderer

Different wall meshes which have same material look different

Hi there

alt text

This is a corner of a room. Those walls both have the same material (Triplanar Shader). And also there is a point light reflecting on the walls differently.

What I don't get: 1) It's triplanar shader. It uses world coordinates. Why does second wall look rotated? 2) Although the walls have the same material, why the shininess is different?

Here is the shader:

 Shader "Custom/Triplanar PBS Ori"
 {
     Properties
     {
         _Color("Color", Color) = (1,1,1,1)
         _MainTex("Albedo", 2D) = "white" {}
 
         _Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
         [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
 
         _BumpMap("Normal Map", 2D) = "bump" {}
 
         _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
         _OcclusionMap("Occlusion", 2D) = "white" {}
 
         _MapScale("Mapping Scale", Float) = 1.0
     }
     SubShader
     {
         Tags { "RenderType"="Opaque" }
         
         CGPROGRAM
 
         #pragma surface surf Standard vertex:vert fullforwardshadows
         #pragma shader_feature _NORMALMAP
         #pragma shader_feature _OCCLUSIONMAP
 
         #pragma target 3.0
 
         half4 _Color;
         sampler2D _MainTex;
 
         half _Glossiness;
         half _Metallic;
 
         sampler2D _BumpMap;
 
         half _OcclusionStrength;
         sampler2D _OcclusionMap;
 
         half _MapScale;
 
         struct Input {
             float3 localCoord;
             float3 localNormal;
         };
 
         void vert(inout appdata_full v, out Input data)
         {
             UNITY_INITIALIZE_OUTPUT(Input, data);
             data.localCoord = v.vertex.xyz;
             data.localNormal = v.normal.xyz;
         }
 
         void surf (Input IN, inout SurfaceOutputStandard o)
         {
             // Calculate a blend factor for triplanar mapping.
             float3 bf = normalize(abs(IN.localNormal));
             bf /= dot(bf, (float3)1);
 
             // Get texture coordinates.
             float2 tx = IN.localCoord.yz * _MapScale;
             float2 ty = IN.localCoord.zx * _MapScale;
             float2 tz = IN.localCoord.xy * _MapScale;
 
             // Base color
             half4 cx = tex2D(_MainTex, tx) * bf.x;
             half4 cy = tex2D(_MainTex, ty) * bf.y;
             half4 cz = tex2D(_MainTex, tz) * bf.z;
             half4 color = (cx + cy + cz) * _Color;
             o.Albedo = color.rgb;
             o.Alpha = color.a;
 
 #ifdef _NORMALMAP
             // Normal map
             half4 nx = tex2D(_BumpMap, tx) * bf.x;
             half4 ny = tex2D(_BumpMap, ty) * bf.y;
             half4 nz = tex2D(_BumpMap, tz) * bf.z;
             o.Normal = UnpackNormal(nx + ny + nz);
 #endif
 
 #ifdef _OCCLUSIONMAP
             // Occlusion map
             half ox = tex2D(_OcclusionMap, tx).g * bf.x;
             half oy = tex2D(_OcclusionMap, ty).g * bf.y;
             half oz = tex2D(_OcclusionMap, tz).g * bf.z;
             o.Occlusion = lerp((half4)1, ox + oy + oz, _OcclusionStrength);
 #endif
 
             // Pass through the other parameters.
             o.Metallic = _Metallic;
             o.Smoothness = _Glossiness;
         }
         ENDCG
     } 
     FallBack "Diffuse"
     CustomEditor "TriplanarPBSGUIOri"
 }
 

By the way, the room model has been exported from sweethome3d.

unity-same-mat-dif-mesh-render.jpg (376.5 kB)
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 Namey5 · Aug 09, 2016 at 10:19 AM 0
Share

I was having similar problems when doing the same thing. I spent a while working on it, and ended up fixing the rotation by moving around some of the projection axis', but I couldn't get the normals fixed.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Material trouble 0 Answers

Material doesn't have a color property '_Color' 4 Answers

Why is Unity generating grayscale normal maps? 0 Answers

How can i get mixed texture from one shader and set it for another object with another shader? 0 Answers

Laser Shader/Material? 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