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 /
avatar image
0
Question by hellocld · Sep 09, 2017 at 03:08 AM · unity 5shadershader programmingbillboard

Billboard shader works in scene view but not game view

I'm trying to write a simple billboard shader for application on quads. It appears to be functioning as expected in the scene view, but the camera in the game view is completely wrong (objects clipping in and out of existence, not rotating with the viewpoint, etc.). The code for my shader is below, any help is much appreciated.

 Shader "Custom/BillboardShader"
 {
    Properties{
       _MainTex("Texture Image", 2D) = "white" {}
       _ScaleX("Scale X", Float) = 1.0
       _ScaleY("Scale Y", Float) = 1.0
    }
       SubShader{
          Tags{"Queue" = "Transparent" "RenderType" = "Transparent" }
          Pass{
          CGPROGRAM
          #include "UnityCG.cginc"
          #pragma vertex vert  
          #pragma fragment frag
 
          uniform sampler2D _MainTex;
          uniform float _ScaleX;
          uniform float _ScaleY;
 
          struct vertexInput {
             float4 vertex : POSITION;
             float4 tex : TEXCOORD0;
          };
 
          struct vertexOutput {
             float4 pos : POSITION;
             float4 tex : TEXCOORD0;
          };
 
          vertexOutput vert(vertexInput input)
          {
             vertexOutput output;
 
             output.pos = mul(UNITY_MATRIX_P,
                mul(UNITY_MATRIX_MV, float4(0,0,0,1))
                + float4(input.vertex.xyz, 0));
 
             output.tex = input.tex;
 
             return output;
          }
 
          float4 frag(vertexOutput input) : COLOR
          {
             return tex2D(_MainTex, float2(input.tex.xy));
          }
 
          ENDCG
       }
    }
 }
 
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by IsaiahKelly · Sep 09, 2017 at 03:34 AM

Strange... Shader seems to work perfectly fine for me. Are you sure you have the shader assigned to the material for these objects that are misbehaving?

In any case, maybe this fantastic billboard shader pack can be of some help?

Comment
Add comment · Show 2 · 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 hellocld · Sep 09, 2017 at 02:17 PM 2
Share

UPDATE: Looks like the shader works fine so long as I force the game camera to use Deferred rendering. Not sure why that fixes it, but for now that's good enough for me.

Funnily enough, I downloaded that shader pack and ran into the exact same problem I'm having with my own, haha. Perhaps I'm expecting behavior different from what's intended with these.

https://imgur.com/QxGrvgS

On the left is what I have in the scene view, with all the prefabs pointing directly at the camera. The right is the in-game camera viewpoint, which I've managed to move as closely as possible to match the scene view camera. It looks like the objects aren't adjusting properly in relation to the in-game view space. Is that how these shaders are supposed to work normally, or am I just running into some other weird issue?

avatar image litebox · Sep 01, 2018 at 05:12 PM 0
Share

I have the same problem, did you find a solution? I found that Billboard works in Game View ONLY if it has only one instance. If I create more than one it disappears, and if I delete all copies - it appears again. But for Editor View all is working always.

avatar image
0

Answer by litebox · Sep 01, 2018 at 05:37 PM

Adding a new Tag "DisableBatching"="True" fixed issue.

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

Answer by chantey · Dec 12, 2019 at 06:26 AM

I had the same issue after upgrading to Universal Render Pipeline from inbuilt. After pressing lots of buttons I found enabling "Use Post Processing" in the Camera Component solved the issue. The problem shader uses lots of in-built variables and screen space calculations, maybe post-processing updates these or something.

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

176 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 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

Transparent shader disappears with multiple objects 1 Answer

Unlit terrain shader 0 Answers

Change skybox shader color smoothly 1 Answer

Getting following error in outlog when I`d ran my game in Unity? 1 Answer

How can i combine shaders? 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