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
1
Question by MBVerse · Aug 17, 2013 at 09:50 AM · shaderskyboxpass

Is 6-pass skybox shader with different geometry per pass a special case?

The default skybox shader (RenderFX/Skybox) takes 6 cube face textures and specifies 6 passes (1 for each cube face). In each pass it renders a different side of the skybox cube.

I thought that each pass of a shader would redraw the exact same geometry per pass. Is rendering unique geometry in each pass a special case for the skybox, or something that can generally be done with any shader and/or mesh?

Comment
Add comment · Show 5
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 MBVerse · Aug 19, 2013 at 03:34 PM 0
Share

$$anonymous$$ore info on this: If you have 6 passes defined, each cube face is rendered in its own pass. But if you have less than 6 defined, all cube faces will be drawn in each pass. So there must be something special about the skybox setup.

avatar image OP_toss · Aug 19, 2013 at 05:07 PM 0
Share

I would guess they are not rendering pieces of the mesh/geo, but rather rendering the whole mesh with just a piece that has texture. There's many ways you can combine them post-render, but the easiest to me would be adding all the images together, and assuring that the untextured area is black.

But since it's a cube, it could indeed be 6 planes I suppose... Though normally, no, you cannot render pieces of a single mesh from a shader. You'd have to separate them into different meshes.

Does this help at all?

avatar image MBVerse · Aug 20, 2013 at 08:58 PM 0
Share

I'm fairly certain this is always 6 pieces of geometry (1 per face). $$anonymous$$y main question was just about how it knows to do only 1 unique pass for each face ins$$anonymous$$d of doing all passes for each face.

Because if I only have 5 passes defined in the shader, it does all 5 passes for each face. You can tell by making the blendmode additive and see the multiple passes adding on top of each other. But this doesn't happen if you have 6 passes defined.

Unless I hear different, I'll just assume this is some special skybox code done behind the scenes that isn't generally usable.

avatar image OP_toss · Aug 21, 2013 at 12:54 AM 0
Share

If that's the case, then it is 6 different meshes, at least if it adheres to how the rest of Unity works...

Perhaps it uses $$anonymous$$aterial.SetPass to individually set the pass on the material before perfor$$anonymous$$g a render call? That way it could set the pass and visibility for each plane and call render.

You may be correct though, it is black-boxed so it may be a special case. No way to know without asking Unity devs directly I'd guess...

Hope this helped.

avatar image MBVerse · Aug 21, 2013 at 05:32 AM 0
Share

Ah, didn't know about $$anonymous$$aterial.SetPass. That could definitely be what the skybox is using. Thanks for the info.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sirbrialliance · May 05, 2017 at 07:55 PM

Empirically, yes.

Test case: I grabbed the default procedural skybox shader and added a number of these "empty" passes to the end of it:

 Pass {
     CGPROGRAM
     #pragma vertex vert
     #pragma fragment frag
     struct appdata_t { float4 vertex : POSITION; };
     struct v2f { float4 vertex : SV_POSITION; };
     v2f vert(appdata_t v) {v2f o;o.vertex = UnityObjectToClipPos(v.vertex);return o;}
     half4 frag(v2f i) : COLOR { discard; return (float4)0;}
     ENDCG
 }

If I add exactly 5 (for a total of 6 passes) the shader stops rendering correctly: it only renders one side of a cube. If I add 1-4 copies, or 6+ copies it continues to work correctly.

Additionally, normally Unity (5.6.0) renders the skybox with a spherical mesh that has 5040 verts (check the frame debugger or look at it under NSight). If I have exactly 6 passes, it switches from rendering that mesh to a 6-vert (2 tri) quad - one quad per side of a cube.

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

18 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

Related Questions

Errors with ENDCG in shaders 1 Answer

Is it possible to get back data for a specific vertex from a shader ? 0 Answers

Skybox blending 2 Answers

Unity 5 Skybox not Rotating 3 Answers

Represent Land 3D Area End 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