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 modcreativeinc · Oct 14, 2014 at 09:54 AM · texture2d

How to Add texture image behind or below a 3D model with second camera?

How do I add a background image below a 3D model for augmented reality? I would like to place a graphic below a 3D character, for example a dragon model on a green image. I have tried the following code and only get a solid color on the second camera without the textured panel or GUI. I have also tried the Vuforia Background Texture Access for Unity. Thanks for any help!

You're almost there, with the 2nd camera approach. Here's how to do it:

Create a new camera (GameObject -> Create Other -> Camera), and name it "Background Camera".

Create a new GUI Texture (GameObject -> Create Other -> GUI Texture), and name it "Background Image".

Click the "Layer" dropdown menu in the Background Image's inspector pane, and select "Add Layer".

In the next free "User Layer" slot, create a new layer name called "Background Image". This will be directly under the layer named "Terrain" if you haven't yet added any others.

Select your Background Image in the hierarchy, and give it the desired texture, and set the x, y, width and height under "Pixel Inset" so that it fills the screen appropriately.

Near the top of the inspector window, Use the layer dropdown menu to assign your "Background Image" layer that you defined earlier to this gameobject.

Now select your Background Camera in the hierarchy, and adjust these settings in the inspector:

Un-Check Flare Layer and Audio Listener (but leave GUILayer enabled)

Set Clear Flags to Solid Color

Set Depth to -1

Set Culling Mask, first to "Nothing", and then to "Background Image"

Now Select you other (main) camera, and in the inspector:

Set its Clear Flags to "Depth Only"

Click its culling mask setting, and un-check "Background Image". This should result in the culling mask displaying as "Mixed ..."

Voila, this should give you your GUI Texture rendered by your background camera, behind everything else rendered by your main camera. And for any other additional cameras (eg, other camera angles) that you want to use, just repeat the last two steps on them.

more ▼ answered Jan 05, 2010 at 01:53 PM duck gravatar image duck ♦♦ 47.6k ● 129 ● 189 ● 457 thanks for this Duck, I was looking for the same thing. Query though, is there anyway to stop the clipping for a full background image when aspect ratio is changed?

Mar 23, 2010 at 12:31 PMRobF 4 It's much better if you set all the pixel inset values to 0, and set the scale to (1, 1, 1) instead. Otherwise, the background image doesn't adapt to different screen sizes. The only possible drawback is that the background image will get stretched or squished with different aspect ratios than the one you used to create the game. If this is not desirable, you can use a script like this one: http://www.unifycommunity.com/wiki/index.php?title=GuiRatioFixer

Apr 21, 2010 at 11:16 PMEric5h5 In 3.2, when I do all the above, the 'background' image is drawn really as a 'foreground' image in the Editor, all my other geometry behind the texture. I changed 'depth', no help. Anyone?

Feb 28, 2011 at 09:21 PMDaveA This solution works excellently. My only problem is when I go to actually make the background scroll, it stutters every now and then as it moves.

I am adding an offset*Time.deltaTime every update to the pixelInset.x. Is there a better way to make the background scroll? Code is below.

function Update () { var xVel : float = -xVelocity*Time.deltaTime; background1.pixelInset.x += xVel; background2.pixelInset.x += xVel; }

Aug 25, 2011 at 05:06 PMpaulg568 I had the same problem as DaveA. I finally realized that while my BG camera's culling mask was set correctly, my actual BG image was assigned to layer Default and not layer BackgroundImage.

That step is listed in the instructions but I must have accidentally skipped it or messed it up.

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

UnityEditor - Drawing on a Texture 1 Answer

ReadPixels requires an offset while in the Editor? 2 Answers

How can I save the Bild from a Camera, which not main camera is. 1 Answer

Detect WWW Image bitmap dimensions? 2 Answers

Get RenderTexture 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