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 alessandro_88 · Aug 19, 2013 at 01:34 PM · camerashaderprogramminguvprojection

Project UVs from Camera Shader

Hey there. For a project I need a shader that permanently projects the UVs from the view of the camera. So far I could not find a shader preset like this, not in unity and not on the internet. So i tried to program it on my own but guess what, I failed gloriously.

Actually I don't even know how exactly to start or what to connect in the code with each other to get a shader with this effect. Has anyone done something like that before? Or does anybody know how to do it and cloud show me the programcode? I would be very thankful!

Comment
Add comment · Show 3
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 DaveA · Aug 19, 2013 at 01:38 PM 0
Share

Do you have any picture examples of the effect you are trying to achieve? Almost sounds like you want to use world coordinates? I've seen those shaders, nice.

avatar image alessandro_88 · Aug 19, 2013 at 01:56 PM 0
Share

Hi. Thank you for your answer. I don't have pictures, but you can imagine it as a shader that will always show the same picutre in the same angle on an object, because the uv's are projected from the camera. I think the most plausible example would be a sphere where you have a picture on it, that will always look towards you, no matter how you turn your camera to the sphere. $$anonymous$$aybe something like the 'figure in a sphere'-effect, just that the figure is always shown from (for example) the front view :)

avatar image Fattie · Aug 19, 2013 at 02:58 PM 0
Share

PS guys there is no apostrophe on plurals. It is just UVs.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by OP_toss · Aug 19, 2013 at 05:03 PM

You mean like this? (detail texture in screen-space)

 Shader "Example/ScreenPos" {
     Properties {
       _MainTex ("Texture", 2D) = "white" {}
       _Detail ("Detail", 2D) = "gray" {}
     }
     SubShader {
       Tags { "RenderType" = "Opaque" }
       CGPROGRAM
       #pragma surface surf Lambert
       struct Input {
           float2 uv_MainTex;
           float4 screenPos;
       };
       sampler2D _MainTex;
       sampler2D _Detail;
       void surf (Input IN, inout SurfaceOutput o) {
           o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
           float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
           screenUV *= float2(8,6); //half the tiling x/y
           o.Albedo *= tex2D (_Detail, screenUV).rgb * 2;
       }
       ENDCG
     } 
     Fallback "Diffuse"
   }

Directly stolen from Unity's Docs. If this is what you want, please try to look at Unity Docs first before asking a question.

Hope this helps!

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 alessandro_88 · Aug 19, 2013 at 06:32 PM 0
Share

Thank you very much for your answer. Yes, i meant something like this, the texture looking towards me works just fine with it. But I'm trying to get a shader that will leave the size of the tiling and the textures position on the object always the same. So with this shader, if I zoom in and out or if I shift the camera, the tiling ajusts with the distance or the position of the camera (f.e. there will be more tiling if I'm far away). Is there any possibility to make the texture always turn towards me, but if I shift the camera, it will follow it and if I zoom, the tiling stays the same? I think this could work with the sphere, if I calculate the closest point on the object to the camera and this point should always be a specific point on the UV, for example 0.5, 0.5 (the middle). But I just don't know how to program that. Could anyone help?

avatar image
0

Answer by Cec · Apr 10, 2014 at 01:41 PM

Sorry to dig up a height months tread... You might search for Project UV from camera asset on the asset store. https://www.assetstore.unity3d.com/#/content/16133

This is not a shader but it allows you to project UV from camera screen space AND you can do it ones with single button or with the API), or in realtime. So you can project your UVs, then fix it up, and move your camera as you wish, without the UVs to be modified. You can even place the shaders you want on you gameObjects without affecting the projection.

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

19 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

Related Questions

Multiple Cars not working 1 Answer

how to change progection matrix for some objects 0 Answers

Get the screen coordinates of an object altered by Fisheye 0 Answers

How to get points on screen of objects when using Fisheye camera? 0 Answers

Blending/Fading Camera & Pixel Shader 1.1 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