Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 kennypu · Feb 11, 2011 at 11:02 PM · shadertextureruntimereflection

A way to move Texture's offset in runtime?

Hey, I have a mirror like object with a reflective shader on it reflecting a cube map. That works fine as expected. The thing is, the object is a child of the camera, thus because the view angle never changes, you can't see it 'reflecting'. I wanted to fake the reflecting by offsetting the cubemap while the player moved, but I can't seem to find how to do it since the Texture nor Shader class gives the option. Is it not possible to change the offset at runtime? Thanks

EDIT: apparently I can't offset cubemaps so I won't be able to do this, unless some one is nice enough to make a shader where I can offset the cubemap

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
3
Best Answer

Answer by kennypu · Feb 11, 2011 at 11:53 PM

I found the answer, apparently the Material Class had a SetTextureOffset method you can use.

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
avatar image
0

Answer by mrde · Feb 11, 2011 at 11:20 PM

I wrote some shader code, maybe help you

Shader "mapTestSurface" {

Properties {
  _MainTex ("Texture", 2D) = "white" {}
  _MaskTex ("Texture", 2D) = "white" {}
  //_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
  _XOffset ("X offset", Range(0, 1.0)) = 0
  _YOffset ("Y offset", Range(0, 1.0)) = 0
}

SubShader { //Tags { "RenderType" = "Transparent" } //Tags { "RenderType"="Opaque" } Tags {"IgnoreProjector"="True" "RenderType"="TransparentCutout"} Tags { "Queue" = "Geometry+1" } ZWrite Off ZTest Always LOD 200 Lighting Off

CGPROGRAM //#pragma surface surf Lambert alpha #pragma surface surf WrapLambert alpha struct Input { float2 uv_MainTex; }; sampler2D _MainTex; sampler2D _MaskTex; float _XOffset; float _YOffset;

half4 LightingWrapLambert (SurfaceOutput s, half3 lightDir, half atten) { half NdotL = dot (s.Normal, lightDir); half diff = NdotL 0.5; + 0.5; half4 c; //c.rgb = s.Albedo /_LightColor0.rgb/ (diff atten * 2); c.rgb = s.Albedo; c.a = s.Alpha; return c; }

void surf (Input IN, inout SurfaceOutput o) { float2 a = float2( _XOffset, _YOffset); float2 scale = float2(0.3, 0.3); a = a + IN.uv_MainTex * scale;

   half4 c = tex2D (_MainTex, a);
   o.Albedo = c.rgb;
   half4 mask = tex2D (_MaskTex, IN.uv_MainTex);
   o.Alpha = c.a;
   //if (mask.a < 1f)
     o.Alpha = c.a * mask.a;


} ENDCG } Fallback "Diffuse"

}

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 kennypu · Feb 11, 2011 at 11:46 PM 0
Share

this didn't really do what i was looking for. the second texture isn't visible, and you can see the object through other objects. Thanks though

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

1 Person is following this question.

avatar image

Related Questions

Reflective surface/texture bug in build only (works in play mode in editor) 1 Answer

Applying decals / textures to uneven surfaces runtime 1 Answer

How to update texture during runtime to display damage? 0 Answers

Textures different between editor and device 1 Answer

[Closed] Extracting current state of texture as new texture 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