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 rory.pickering · Dec 05, 2012 at 12:42 PM · c#renderingtexturesplanepositioning

Aligning planes thin gap? c#

Im currently developing a 2d side scrolling game that uses planes to build up the scenery.

For example it will create 10 planes in a row, aligned next to eachother, each with the next texture on. But for some reason there is sometimes little thin lines between the planes!

This is frustrating, as they should be perfectly aligned. Im using the following function to get the position of the next plane

 Vector3 GetNextPosition(GameObject rightPlane)
 {
     GameObject leftPlane = planes[planes.Count-1];
 
     float xPos = leftPlane.transform.position.x + (leftPlane.transform.lossyScale.x*0.5f) + (rightPlane.transform.lossyScale.x*0.5f);
     //this uses the lossyScale.z as the planes are rotated (90,180,0) so theyre upright, and the y scale becomes z
     float yPos = leftPlane.transform.position.y - (leftPlane.transform.lossyScale.z*0.5f) + (rightPlane.transform.lossyScale.z*0.5f);
     float zPos = leftPlane.transform.position.z;
         
     return new Vector3(xPos + leftMargin, yPos, zPos);
 }


The plane is imported from 3dStudioMax and is only 1 unit by 1 unit. I got the same result whilst using the standard unity 10x10 plane, but decided to make it 1x1 to keep hte tri and quad count down a bit.

Also there is a thin line of colours at the edge of my transparent png. I have read alot about this and tried a lot of things to get rid of this line, such as using exporting in GIMP with a new transparent layer behind the png, and unchecking the 'Save color values from transparent pixels' and 'Save background color'!

Any help would be greatly appreciated!

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 rory.pickering · Dec 05, 2012 at 11:57 AM 0
Share

I'm using the perspective camera, if that makes ANY difference!

avatar image sparkzbarca · Dec 05, 2012 at 02:49 PM 0
Share

you should put the image on a transparent background but the background should be colored even though its transparent. It should be NEARLY identical in color to the actual object edge so that whatever pixels bleed through it still looks ok.

what you need to be googling for is

texture edge padding

that will give you some info on what is going on and how to correct it.

3dsmax-> render to texture ->padding

for example.

again though that padding needs to be the same color as the edge.

Whats happening is your graphics card is trying to take a high resolution image and display it at a lower resolution.

it does this by taking a pixel and its nearby neighbors and averaging color values to create a new pixel which roughly represents those several.

near the edge of your texture the neighbors are those "transparent" pixels. But they still count for the purposes of being sampled.

The large difference in color means near the edge its trying to make one pixel out of say pure white and pure red.

That doesn't work out well, you get a stream of different colors because averaging the neighbors means sometimes your averaging more colors together producing a new color each time.

that is why you want the edge to be the same color GOING PAST the edge.

hope this helps. :

avatar image rory.pickering · Dec 06, 2012 at 12:17 PM 0
Share

Thank you for your detailed response. I have tried many things, from many answers on this site regarding the 'texture edge padding' though i didnt know the jargon, so it's easier to search for it now! thanks! I have tried a lot of photoshop batches, that use the gassian blur merging and whatever to create the padding, and then uses the alpha channel to but it just end up with the thin lines still appearing and now a border round each image of about 10 pixels black. or just a totally black background, following this tutorial of unitys site too! I get the same effect http://docs.unity3d.com/Documentation/$$anonymous$$anual/HOWTO-alphamaps.html

Is there a certain blend mode i need to choose for that?

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

10 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

Related Questions

Trying to make a texture fill an entire Plane 0 Answers

2d PNG on Plane Texture padding 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to make a ball jump? 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