Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by tedbox39 · Aug 08, 2018 at 09:51 PM · 2d gametransparencylayersmesh renderer

Cannot make transparent plane work in 2D game with several layers

I am creating a side-to-side scrolling 2D game with a number of environment layers and am having problems getting one of the layers to be semi-transparent to create a sort of distance haze effect. The layers I have include (from back to front):

  1. Stars –Sphere MeshFilter, Mesh Renderer, Sprites/Default Shader

  2. Mountains - Mesh Filter (procedurally generated), Mesh Renderer, Sprites/Default Shader

  3. Haze – Plane Mesh Filter, Mesh Renderer, custom material

  4. Landscape - Mesh Filter (procedurally generated), Mesh Renderer, Sprites/Default Shader


    I am trying to set up the Haze layer with some transparency as a simple, or not so simple as it turns out, distance haze effect. Using a standard shader on the material the layer either does or does not render at all depending on the alpha value, but is not transparent, i.e. if it renders then it blocks the stars/mountains completely. I can get a transparent looking effect if I use the Skybox/Panoramic shader although the mountains are still rendered in front of the Haze layer even though they are physically behind it in the z-dimension.

    I have read a page on how to fix transparent rendering problems here: [https://answers.unity.com/questions/609021/how-to-fix-transparent-rendering-problem.html][1] and tried using a Standard shader with Rendering Mode set to cutout, but get the same problem that the Haze layer is either solid or invisible.

    I am a total noob when it comes to this stuff so am just groping in the dark changing options to see what happens. I don’t know enough about the suggestions on the ”how to fix transparent rendering problems” page to understand how to implement the solutions or if they will work for me. I've read lots of other pages, but am none the wiser.

    Can anyone give me any suggestions about how I might fix this problem so that my Haze layer is rendered semi-transparently in front of the stars/mountains? If I haven’t provided enough information here then let me know (not sure what is relevant/isn’t!)

    Just for completeness, I have tried another approach by making the mountains transparent (which works fine... so not sure why the Haze layer doesn’t!) and using a script to selectively disable my stars if they are behind the mountains using a raycast, however this is not 100% accurate and can lead to parallax errors where the stars are something visible behind the semi-transparent mountains. It seemed like it would be easier just to have a semi-transparent plane in from of the mountains that tracked the camera, but can't work out what I am doing wrong.

    ps apologies for the bad paragraph spacing, but I can't get the line breaks to work for some reason. :s

pps I fixed the paragraph spacing using basic html.

[1]: https://answers.unity.com/questions/609021/how-to-fix-transparent-rendering-problem.html

Comment
Add comment · Show 9
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 NoDumbQuestion · Aug 09, 2018 at 01:47 AM 0
Share

Double Enter for paragraph

Like this.

For multi layer of mesh + shader for haze effects, it sound dumb.Especially for custom shader.

Use Post processing.

https://assetstore.unity.com/packages/essentials/post-processing-stack-83912

avatar image tedbox39 · Aug 09, 2018 at 06:40 AM 0
Share

Thanks @NoDumbQuestion. I tried double enter and double space+enter as per the markdown instructions. Neither worked. I have fixed it using html markers ins$$anonymous$$d.

Can you expand on "it sound dumb" (especially since your name implies there are no dumb questions!)? It would be useful to know what you think the problem with my approach is to that I can learn something about the underlying technology. Why is post-processing a better solution?

avatar image NoDumbQuestion tedbox39 · Aug 09, 2018 at 06:49 AM 0
Share

Press Ctrl + R for Line Break.


Sorry I didn't notice you are making 2D games. So Post processing is out of question.

The problem here could be:

  • Custom $$anonymous$$aterial + Shader (if you use unity standard shader for sprite. Set it to opaque and set alpha color of picture down), it didn't support transparent. Due to lack of alpha channel or missing property for cutout alpha. If you know how to post shader code here, then I maybe can help somewhat.

  • Simply your texture(image) for haze do not have alpha channel.

avatar image tedbox39 NoDumbQuestion · Aug 09, 2018 at 08:09 PM 0
Share

Ok, I don't know how to post the shader code. I'm just using a standard one (sprite/default) and from what I've read online I can't get the code to that from within Unity. Do you know how I get that? I can download a version from the asset store. I assume it's the same thing... is that right?

$$anonymous$$eanwhile, I have set my Haze plane up to have the same set up as the $$anonymous$$ountains and added a script to set the colour of the attached $$anonymous$$esh Renderer including a transparency. This works in that it makes the Haze layer transparent (if I make it red I can set it from solid red through to invisible and all points in between), however the $$anonymous$$ountains and Stars are still visible behind the Haze layer even if it is set to 100% opaque. So I think I am having the problems referred to in the link I put in my original post ("how to fix transparent rendering problems") rather than being unable to set up a semi-transparent layer.

Show more comments

1 Reply

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

Answer by tedbox39 · Aug 13, 2018 at 07:37 PM

Workaround suggested by @NoDumbQuestion : "... you can do some hack. Like using Unity UI or sprite instead of plane for haze. Since they come with transparent support by default. UI would just be a World canvas with an image of haze texture."

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

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

Related Questions

Is it Possible to Layer Sprites More Accurately 0 Answers

Problems when transparency axis meets multiple tiles in 2D 0 Answers

How can I layer images and mesh? 0 Answers

2D: Erase a part of top layer to see the background 0 Answers

Layer Collision 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