Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
2
Question by Marnix · Sep 17, 2011 at 11:22 AM · texturetilingrepeat

Repeat texture in mirror mode

Is it possible to set your uv tiling on mirror repeat? I do know that OpenGL supports it and DirectX does so too.

So, instead of just repeating the texture, the texture needs to be flipped instead of just repeated.

http://www.opengl.org/registry/specs/ARB/texture\_mirrored\_repeat.txt

mirror repeated texture

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

2 Replies

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

Answer by Mortennobel · Sep 17, 2011 at 02:19 PM

No it is not possible to change the UV to mirror mode. However if your UVs is set to repeat, you can easily achieve the same effect by writing a custom shader.

I have implemented a simple diffuse shader that does the trick:

 Shader "Custom/DiffuseUVMirrowShader" {
 Properties {
     _Color ("Main Color", Color) = (1,1,1,1)
     _MainTex ("Base (RGB)", 2D) = "white" {}
 }
 SubShader {
     Tags { "RenderType"="Opaque" }
     LOD 200
 
 CGPROGRAM
 #pragma surface surf Lambert
 
 sampler2D _MainTex;
 float4 _Color;
 
 struct Input {
     float2 uv_MainTex;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
     float2 t = frac(IN.uv_MainTex*0.5)*2.0;
     float2 length = {1.0,1.0};
     float2 mirrorTexCoords = length-abs(t-length);
     half4 c = tex2D(_MainTex,  mirrorTexCoords) * _Color;
     o.Albedo = c.rgb;
     o.Alpha = c.a;
 }
 ENDCG
 }
 
 Fallback "VertexLit"
 }
Comment
Add comment · Show 3 · 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 Marnix · Sep 17, 2011 at 02:53 PM 0
Share

Ok thanks for the confirmation and the shader example. That was my second option, but I don't like writing shaders for every different kind of change I want to make. Because I would need to write shaders for every kind of lighting that needs this functionality. So: Diffuse, Specular, Transparent of all... It wouldn't make it better. I think I can better change my texture to make it seamless. That will be an easier solution.

avatar image Mortennobel · Sep 17, 2011 at 07:27 PM 0
Share

I you change your $$anonymous$$d and want to play with shaders: I have written a blog post about how I changed the diffuse shader to use UV mirroring: http://blog.nobel-joergensen.com/2011/09/17/mirror-texture-coordinates-in-unity/

avatar image jnt · Jan 21, 2015 at 04:44 PM 0
Share

Thanks so much for this shader code! I can now halve my texture size for symmetrical objects in my mobile game - every bit of optimization counts ;)

avatar image
1

Answer by xxxMaJaxxx · Mar 01, 2021 at 07:32 PM

https://docs.unity3d.com/Manual/SL-SamplerStates.html

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Texture Tiling Stopped Working in Unity 4? 2 Answers

Repeated Animated Texture on LineRenderer 0 Answers

What do the texture tiling and offset values relate too? 3 Answers

Assigning UV Map to model at runtime 0 Answers

Unity3D - Ammo Texture repeat 2 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