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
-1
Question by AshwinTheGammer · Feb 04, 2018 at 06:19 AM · shaderscript.shader programmingshader writing

Where to type this line of shader into this shader`s script?

Where should I type this line into this shader file.

var shader = Shader.Find("Hidden/CubeCopy");

 Shader "Hidden/CubeCopy" {
     Properties {
         _MainTex ("Main", CUBE) = "" {}
         _Level ("Level", Float) = 0.
     }
     CGINCLUDE
     #pragma vertex vert
     #pragma fragment frag
             
     #include "UnityCG.cginc"
 
     float _Level;
 
     struct v2f {
         float4 pos : SV_POSITION;
         float4 uvw : TEXCOORD0;
     };
 
     v2f vert(appdata_base v)
     {
         v2f o;
         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
         o.uvw = v.texcoord;
         return o;
     }
 
     UNITY_DECLARE_TEXCUBE(_MainTex);
 
     float4 frag(v2f  i) : SV_Target
     {
         return UNITY_SAMPLE_TEXCUBE_LOD(_MainTex, i.uvw.xyz, _Level);
     }
     ENDCG
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         Pass {
             ZTest Always
             Blend Off
             AlphaTest off
             Cull Off
             ZWrite Off
             Fog { Mode off }
             CGPROGRAM
             #pragma target 3.0
             ENDCG
         }
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         Pass {
             ZTest Always
             Blend Off
             AlphaTest off
             Cull Off
             ZWrite Off
             Fog { Mode off }
             CGPROGRAM
             #pragma target 2.0
             ENDCG
         }
     }
     Fallback "Diffuse"
 }
 

Any solution to these appreciated here!

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

2 Replies

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

Answer by Pangamini · Feb 04, 2018 at 12:04 PM

That is C# line. You can put that into your C# monobehaviour script. Not into the shader code.

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 AshwinTheGammer · Feb 04, 2018 at 01:18 PM 0
Share

@Panga$$anonymous$$i Yeah this i c# line but in shader code where like after float _Level; or

 ubShader {
          Tags { "RenderType"="Opaque" }
          LOD 200
          Pass {
              ZTest Always
              Blend Off
              AlphaTest off
              Cull Off
              ZWrite Off
              Fog { $$anonymous$$ode off }
              CGPROGRA$$anonymous$$
              #pragma target 3.0
              ENDCG
          }

after this in this shader code where?

avatar image Pangamini AshwinTheGammer · Feb 04, 2018 at 05:23 PM 1
Share

Well you don't put C# code into shader code. What are you trying to achieve?

avatar image
1

Answer by meat5000 · Feb 04, 2018 at 01:35 PM

That line doesnt go in the Shader.

You use it to Find your shader of the same name when setting up a Material

https://docs.unity3d.com/ScriptReference/Shader.Find.html

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 AshwinTheGammer · Feb 04, 2018 at 02:46 PM 0
Share

But I want to make that whatever shader unity use it fallback to Diffuse.

avatar image meat5000 ♦ AshwinTheGammer · Feb 04, 2018 at 05:32 PM 1
Share

Set that in the Default Shaders in the Project Prefs. Fallbacks are for if the system cant use the shader for some reason. Diffuse is already the fallback in that shader. If you want to set Diffuse manually follow the example in the link I provided.

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

125 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

Related Questions

How to add Emission to my custom shader? 2 Answers

Standard Surface Shader with fade too dark 0 Answers

How would I go about using the shader graph to create a transparent material that catches and shows shadows? 0 Answers

Need a Shader Solution for lighting a flat vertical mesh horizontally 0 Answers

How effective are glsl shaders in Unity? 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