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
0
Question by ArtemAppside · Dec 24, 2020 at 10:51 AM · shadersmaterialsdrawcallstiling

Is there an any way to use batching with UV tiling?

Hey. I will have a lot of object (1000+) in the scene with the same material but different tiling values. I have created a shader for it in the shader graph and assign a script with MaterialPropertyBlock to change tiling. Everything is working fine except the batching. Is there an any way to have 1 batch for 1000 objects with the same material but different tiling values? Thanks!

UPDATE: I have found this https://docs.unity3d.com/Manual/GPUInstancing.html? but have no idea how to right this type of shader with texture and tiling instead of color

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

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

Answer by ArtemAppside · Jan 11, 2021 at 10:56 AM

Guy with nickname fiveampsoftware shared with me this shader

 Shader "Test/TestShader"
 {
     Properties
     {
         _MainTex ("MainTexture", 2D) = "white" {}
         _MainScaleOffset ("Main Scale (XY) Offset (ZW)", Vector) = (1,1,0,0)
     }
     SubShader
     {
         Tags
         {
             "RenderType"="Opaque"
         }
         LOD 200
  
         CGPROGRAM
         #pragma surface surf Lambert
         sampler2D _MainTex;
  
         UNITY_INSTANCING_BUFFER_START(Props)
         UNITY_DEFINE_INSTANCED_PROP(float4, _MainScaleOffset)
         UNITY_INSTANCING_BUFFER_END(Props)
  
         struct Input
         {
             float2 uv_MainTex;
         };
  
         void surf(Input IN, inout SurfaceOutput o)
         {
             float4 scaleOffset = UNITY_ACCESS_INSTANCED_PROP(Props, _MainScaleOffset);
             float2 uv = IN.uv_MainTex * scaleOffset.xy + scaleOffset.zw;
             o.Albedo = tex2D(_MainTex, uv).rgb;
         }
         ENDCG
     }
     FallBack "Mobile/Diffuse"
 }

I have used GPU Instancing and this code

     [SerializeField]
     private Vector4 _size;
     
     private MaterialPropertyBlock _myMatBlock;
     void Start()
     {
         _myMatBlock = new MaterialPropertyBlock();
         _myMatBlock.SetVector("_MainScaleOffset", new Vector4(_size.x,_size.y , _size.z, _size.w)); 
         GetComponent<MeshRenderer>().SetPropertyBlock(_myMatBlock);
     }

alt text


12.jpg (367.9 kB)
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

128 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 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 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

Custom Shader with Canvas Renderer limit draw calls. 0 Answers

Polybrush Shaders 0 Answers

Manually z-sorting opaque geometry 1 Answer

Multiple Shaders vs. Single Texture - Please help me overthink this. 2 Answers

Shader: get back scene pixel color? 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