- Home /
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!
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.
@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?
Well you don't put C# code into shader code. What are you trying to achieve?
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
But I want to make that whatever shader unity use it fallback to Diffuse.
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.