Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Dragonbane07 · Nov 09, 2017 at 10:20 PM · errorshaderprogrammingskyboxdaycycle

Errors with ENDCG in shaders

I am not new to unity but i have very VERY little experience with the shaders in unity and this question probably has a simple answer. i am trying to have two skyboxes blend together as time passes and to do this i need to connect a day cycle code's "timeOfDay" variable with the "_Blend" property in the shader. my problem is that i need to place code into the shader and by looking at examples im pretty sure you need to start the code with "CGPROGAM" and end it with "ENDCG" but whenever i place "ENDCG" it gives me the error Parse error: Syntax error, unexpected "}" but whenever i remove whatever the error is it gives me another one, either attacking another bracket or attacking the fallback.

  Shader "Custom/SkyboxFading" {
   
     Properties 
     {
      _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
      _Tint1 ("Tint Color one", Color) = (.5, .5, .5, .5)
      _Tint2 ("Tint Color two", Color) = (.5, .5, .5, .5)
      _Blend ("Blend", Range(0.0, 1.0)) = 0.5
      _Skybox1 ("Skybox one", Cube) = ""
      _Skybox2 ("Skybox two", Cube) = ""
 
     }
   
      SubShader 
      {
      Tags { "Queue" = "Background" }
      Cull Off
      Fog { Mode Off }
      Lighting Off        
      Color [_Tint]
      Pass 
      {
          SetTexture [_Skybox1] { combine texture }
          SetTexture [_Skybox2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }
          SetTexture [_Skybox2] { combine previous +- primary, previous * primary }
      }
      CGPROGRAM
      ENDCG
     
 
     }
   
  Fallback "Custom/Skybox", 1
  }

this is whats causing the problem. i have no code in between the CG's but it was causing the problem even when the code was there.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Nov 09, 2017 at 11:32 PM

Uhm, just remove the CGPROGRAM and ENDCG when you don't have any cg code.

In addition +- is no longer supported since Unity version 5+. While for certain things the legacy texture combiners might be enough, it's generally recommended to actually write a cg shader instead.

Comment
Add comment · Show 5 · 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 Dragonbane07 · Nov 09, 2017 at 11:43 PM 0
Share

none of those things are the problem. yes i could just remove the CGPROGRA$$anonymous$$ and ENDCG but then i cannot place code into the shader which was the original point of this. i've tried to edit _Blend outside of the shader but its not possible without CG code. and if it is possible i would love to know.

avatar image Bunny83 Dragonbane07 · Nov 10, 2017 at 01:07 AM 0
Share

Sorry but this comment is very confusing. Your shader uses the Fixed function pipeline of the shader hardware since you use SetTexture.


If you actually want to use a fragment shader you can't use SetTexture. Though if you want to use the fixed function pipeline you can't use a CG fragment shader. It's two different approaches to the same thing. The fixed function pipeline can not be programmed but only configured. So it's quite limited. Nowadays the fixed function pipeline usually isn't used anymore.


It's still not clear what you actually want to do. What do you mean by "i've tried to edit _Blend outside of the shader"


When i copy your shader into my project, remove the CG part and replace the "+-" by a simple "*" the shader works as expected. I can manipulate the _Blend slider in my skybox material and it correctly blends between the two cubemaps.

avatar image Dragonbane07 Bunny83 · Nov 10, 2017 at 06:39 PM 0
Share

that is very strange because when i replace the "+-" with a "*" the shader doesn't work properly yet when i keep the "+-" it works fine, anyway that isnt the problem here. let me try to explain this better. my goal is to make the skybox fade between the two set skyboxes as time of day changes. the skybox fading itself works fine as the "_blend" slider works fine. my problem is that i want the _blend to be affected by a C# code but when i use

         skyboxFading = new $$anonymous$$aterial(Resources.Load("$$anonymous$$aterials/SunBox") as $$anonymous$$aterial);
         skyboxFading.SetFloat("_Blend", currentTime / 24);

it doesnt change the skybox. I have to be doing something wrong here.

Show more comments

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

141 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

Related Questions

Multiple Cars not working 1 Answer

[Solved] False "variable not assigned" error 3 Answers

How do I get objects to render against the skybox? 2 Answers

worldPos in shader giving errors when game is paused 0 Answers

Shader / Compute Shader in Unity 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