• 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 Wesww · Jul 27, 2011 at 02:04 AM · texturenoiseseamlessdirty

Generative seamless textures across multiple planes?

How would you go about generating random textures that can be seamlessly mapped across multiple planes in a grid?

Currently I have a single prefab plane that is instantiated by a for loop to form a grid of identical planes. Certain events cause planes to fade out (thanks to iTween) and then Destroy.

I want the seamless grid to look dirty, without looking repetitive.

I was looking at these questions: http://answers.unity3d.com/questions/135940/how-to-map-texture-across-multiple-objects.html http://answers.unity3d.com/questions/146062/spread-material-over-multiple-objects-or-cubes.html But neither of them suit my purposes.

Any ideas?

Comment
Add comment · Show 2
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 Peter G · Jul 27, 2011 at 02:29 AM 1
Share

Your first link has a good suggestion in one of the answers, you should map the texture based on the object's world position rather than there uvs. Then it should tile more smoothly.

avatar image Wesww · Jul 27, 2011 at 09:37 PM 0
Share

[edit: moving this to comments]

If you think that would work, I will definitely try to approach it that way. What threw me off is that the user Owen who suggested that method also said "The edges all have bad seems, but there's no way around that."

but now that I am reading it again, perhaps that quote was caused by having to do differently angled walls rather than just one plane. Thanks! I'll get back with how my attempts go.

1 Reply

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

Answer by Wesww · Aug 03, 2011 at 07:21 PM

So that was great advice, and I've gotten this working really well for my purposes now. I added a couple lines of code to an answer posted by user "Owen Reynolds" on this question so that I could manually tweak the scale of the world-aligned repeating texture from the GUI side.

Here's the full code of the working shader, hope it helps somebody else:

 Shader "custom_shaders/Transparent_Diffuse_World_Aligned" {

Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _Scale ("Texture Scale Multiplier", Float) = 0.1 }

SubShader { Tags {"Queue"="Transparent-101" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 200 Cull Off Fog {Mode Off}

 CGPROGRAM
 #pragma surface surf Lambert alpha
 
 sampler2D _MainTex;
 float4 _Color;
 float _Scale;
 
 struct Input {
     float2 uv_MainTex; // unused
     float3 worldNormal;
     float3 worldPos;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
   // Guess correct planar map from normal. 0.5 is an arbitrary cutoff
   float2 UV;
   // NOTE: assuming no bottom-facing, otherwise use abs()
   if(IN.worldNormal.y>0.5) UV = IN.worldPos.xz; // top
   else if(abs(IN.worldNormal.x)>0.5) UV = IN.worldPos.yz; // side
   else UV = IN.worldPos.xy; // front
 
   // 0.1 is an arbitrary x10 texture size scale 
   half4 c = tex2D (_MainTex, UV* _Scale)* _Color;
   o.Albedo = c.rgb;
   o.Alpha = c.a;
 }
 
 ENDCG

}

Fallback "Transparent/VertexLit" }

Comment
Add comment · Show 1 · 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 Xare · Jun 16, 2014 at 02:31 PM 0
Share

If you ever read this, I want you to know that you sir are absolutely a hero for writing this shader. Thank you very much!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using noise as texture 2 Answers

3D Mesh Deformer in Unity3D 2 Answers

Removing Line in Texture When Repeating 1 Answer

Assigning UV Map to model at runtime 0 Answers

Procedural Texturing on Multiple Terrain Mesh 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