• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.Shader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.Shader的典型用法代码示例。如果您正苦于以下问题:C# Shader类的具体用法?C# Shader怎么用?C# Shader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Shader类属于UnityEngine命名空间,在下文中一共展示了Shader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ShowShaderCodeArea

 private void ShowShaderCodeArea(Shader s)
 {
   ShaderInspector.ShowSurfaceShaderButton(s);
   ShaderInspector.ShowFixedFunctionShaderButton(s);
   this.ShowCompiledCodeButton(s);
   this.ShowShaderErrors(s);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:7,代码来源:ShaderInspector.cs


示例2: SimpleCube

        public SimpleCube(float size, ref Material material, Shader shader)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            GameObject.Destroy(cube.GetComponent<Collider>());
            cube.transform.localScale = Vector3.one;
            meshContainer = cube;

            MeshFilter mf = cube.GetComponent<MeshFilter>();
            Vector3[] verts = mf.mesh.vertices;
            for (int i = 0; i < verts.Length; i++)
            {
                verts[i] *= 2*size;
            }
            mf.mesh.vertices = verts;
            mf.mesh.RecalculateBounds();
            mf.mesh.RecalculateNormals();

            MeshRenderer mr = cube.GetComponent<MeshRenderer>();
            material = mr.material;
            material.shader = shader;

            mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            mr.receiveShadows = false;
            mr.enabled = true;
        }
开发者ID:Kerbas-ad-astra,项目名称:EnvironmentalVisualEnhancements,代码行数:25,代码来源:SimpleCube.cs


示例3: ShaderVariant

			public ShaderVariant(Shader shader, PassType passType, params string[] keywords)
			{
				this.shader = shader;
				this.passType = passType;
				this.keywords = keywords;
				ShaderVariantCollection.ShaderVariant.Internal_CheckVariant(shader, passType, keywords);
			}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:7,代码来源:ShaderVariantCollection.cs


示例4: LoadBundleAssets

        public IEnumerator LoadBundleAssets()
        {
            while (!Caching.ready)
                yield return null;
            Debug.Log("[B9PW] Aquiring bundle data");
            using (WWW www = WWW.LoadFromCacheOrDownload("file://" + KSPUtil.ApplicationRootPath + Path.DirectorySeparatorChar + "GameData"
                                                                            + Path.DirectorySeparatorChar + "B9_Aerospace_ProceduralWings" + Path.DirectorySeparatorChar + "wingshader.ksp", 1))
            {
                yield return www;

                AssetBundle shaderBundle = www.assetBundle;
                Shader[] objects = shaderBundle.LoadAllAssets<Shader>();
                for (int i = 0; i < objects.Length; ++i)
                {
                    Debug.Log($"[B9PW]  {objects[i].name}");
                    if (objects[i].name == "KSP/Specular Layered")
                    {
                        wingShader = objects[i] as Shader;
                        Debug.Log($"[B9 PWings] Wing shader \"{objects[i].name}\" loaded");
                    }
                }

                yield return new WaitForSeconds(1.0f); // unknown how neccesary this is
                Debug.Log("[B9PW] unloading bundle");
                shaderBundle.Unload(false); // unload the raw asset bundle
            }
        }
开发者ID:RichardDastardly,项目名称:B9-PWings-Fork,代码行数:27,代码来源:StaticWingGlobals.cs


示例5: IsSupported

        public static bool IsSupported(Shader s, bool needDepth, bool needHdr, MonoBehaviour effect)
        {
            if (s == null || !s.isSupported)
            {
                Debug.LogWarningFormat("Missing shader for image effect {0}", effect);
                return false;
            }

            if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures)
            {
                Debug.LogWarningFormat("Image effects aren't supported on this device ({0})", effect);
                return false;
            }

            if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
            {
                Debug.LogWarningFormat("Depth textures aren't supported on this device ({0})", effect);
                return false;
            }

            if (needHdr && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
            {
                Debug.LogWarningFormat("Floating point textures aren't supported on this device ({0})", effect);
                return false;
            }

            return true;
        }
开发者ID:XuTenTen,项目名称:MultiThreadComponent,代码行数:28,代码来源:ImageEffectHelper.cs


示例6: OnDisable

 void OnDisable()
 {
     _target = null;
     _propertyName = null;
     _propertyList = null;
     _cachedShader = null;
 }
开发者ID:keijiro,项目名称:Klak,代码行数:7,代码来源:MaterialFloatOutEditor.cs


示例7: FourierGPU

        public FourierGPU(int size, Shader sdr)
        {
            if (!Mathf.IsPowerOfTwo(size))
                throw new ArgumentException("Fourier grid size must be pow2 number");

            m_fourier = new Material(sdr);

            m_size = size; //must be pow2 num
            m_fsize = (float)m_size;
            m_passes = (int)(Mathf.Log(m_fsize) / Mathf.Log(2.0f));

            m_butterflyLookupTable = new Texture2D[m_passes];

            ComputeButterflyLookupTable();

            m_fourier.SetFloat("Ceto_FourierSize", m_fsize);

            m_pass0RT2 = new RenderBuffer[2];
            m_pass1RT2 = new RenderBuffer[2];

            m_pass0RT3 = new RenderBuffer[3];
            m_pass1RT3 = new RenderBuffer[3];

            m_pass0RT4 = new RenderBuffer[4];
            m_pass1RT4 = new RenderBuffer[4];
        }
开发者ID:BenjaminLovegrove,项目名称:ATR,代码行数:26,代码来源:FourierGPU.cs


示例8: PlanetProperties

        public PlanetProperties(string shader, string landTex, string cliffTex, string snowTex, string landHeightTex = null, string landSubTex = null, float heightScaleFactor=1.5f, int landTexScale = 1)
        {
            landMaterial = Resources.Load<Material> ("Materials/Terrain/Diffuse");
            terrainShader = Resources.Load<Shader> (shader);
            landTexture = Resources.Load<Texture2D> (landTex);
            if (cliffTex != null) {
                cliffTexture = Resources.Load<Texture2D> (cliffTex);
            } else {
                cliffTexture = landTexture;
            }
            if (snowTex != null) {
                snowTexture = Resources.Load<Texture2D> (snowTex);
            } else {
                snowTexture = null;
            }

            if (landHeightTex != null) {
                if (landTexture != null && landHeightTex == landTex) {
                    landHeightTexture = landTexture;
                } else {
                    landHeightTexture = Resources.Load<Texture2D> (landHeightTex);
                }
            }

            if (landSubTex != null) {
                if (landHeightTexture != null && landSubTex == landHeightTex) {
                    landSubTexture = landHeightTexture;
                } else {
                    landSubTexture = Resources.Load<Texture2D> (landSubTex);
                }
            }

            this.heightScaleFactor = heightScaleFactor;
            this.landTextureScale = landTexScale;
        }
开发者ID:Moxcr,项目名称:armage,代码行数:35,代码来源:PlanetProperties.cs


示例9: AssignNewShaderToMaterial

 public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
 {
     if (material.HasProperty("_Emission"))
     {
         material.SetColor("_EmissionColor", material.GetColor("_Emission"));
     }
     base.AssignNewShaderToMaterial(material, oldShader, newShader);
     if ((oldShader == null) || !oldShader.name.Contains("Legacy Shaders/"))
     {
         SetupMaterialWithBlendMode(material, (BlendMode) ((int) material.GetFloat("_Mode")));
     }
     else
     {
         BlendMode opaque = BlendMode.Opaque;
         if (oldShader.name.Contains("/Transparent/Cutout/"))
         {
             opaque = BlendMode.Cutout;
         }
         else if (oldShader.name.Contains("/Transparent/"))
         {
             opaque = BlendMode.Fade;
         }
         material.SetFloat("_Mode", (float) opaque);
         Material[] mats = new Material[] { material };
         this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
         MaterialChanged(material, this.m_WorkflowMode);
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:28,代码来源:StandardShaderGUI.cs


示例10: ChangeShaderOnMaterial

 private static void ChangeShaderOnMaterial(Material material, Shader shader)
 {
     if ((material != null) && (shader != null))
     {
         material.shader = shader;
     }
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:TreeEditorHelper.cs


示例11: SetupRadarCamera

		public static void SetupRadarCamera()
		{
			if(radarRT && radarTex2D && radarCam && radarShader)
			{
				return;
			}

			//setup shader first
			if(!radarShader)
			{
				radarShader = BDAShaderLoader.UnlitBlackShader;//.LoadManifestShader("BahaTurret.UnlitBlack.shader");
			}

			//then setup textures
			radarRT = new RenderTexture(radarResolution,radarResolution,16);
			radarTex2D = new Texture2D(radarResolution,radarResolution, TextureFormat.ARGB32, false);

			//set up camera
			radarCam = (new GameObject("RadarCamera")).AddComponent<Camera>();
			radarCam.enabled = false;
			radarCam.clearFlags = CameraClearFlags.SolidColor;
			radarCam.backgroundColor = Color.white;
			radarCam.SetReplacementShader(radarShader, string.Empty);
			radarCam.cullingMask = 1<<0;
			radarCam.targetTexture = radarRT;
			//radarCam.nearClipPlane = 75;
			//radarCam.farClipPlane = 40000;
		}
开发者ID:tetryds,项目名称:BDArmory,代码行数:28,代码来源:RadarUtils.cs


示例12: GasOverlayMats

 static GasOverlayMats()
 {
     TransmitterShader = ShaderDatabase.MetaOverlay;
     Graphic subGraphic = GraphicDatabase.Get<Graphic_Single>(TransmitterAtlasPath, TransmitterShader);
     LinkedOverlayGraphic = new Graphic_LinkedGasPipe(subGraphic);
     subGraphic.MatSingle.renderQueue = 3800;
 }
开发者ID:isistoy,项目名称:DevLib,代码行数:7,代码来源:GasNetGraphics.cs


示例13: CreateAtlas

        // with material
        public static MadMeshCombinerAtlas CreateAtlas(string texturePath, Texture2D[] textures, Shader shader)
        {
            var madeReadable = PrepareTextures(textures);
            try {
            List<MadMeshCombinerAtlas.Item> items = new List<MadMeshCombinerAtlas.Item>();

            PackTextures(textures, texturePath, ref items);

            var atlas = new MadMeshCombinerAtlas();
            atlas.atlasTexture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
            atlas.AddItemRange(items);

            // create material out of atlas
            var materialPath = System.IO.Path.ChangeExtension(texturePath, "mat");
            //var atlasMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
            var atlasMaterial = new Material(shader);
            atlasMaterial.mainTexture = atlas.atlasTexture;
            atlas.atlasMaterial = atlasMaterial;

            AssetDatabase.CreateAsset(atlasMaterial, materialPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return atlas;
            } finally {
            RevertAll(madeReadable);
            }
        }
开发者ID:cwp10,项目名称:MyFPSGameProject,代码行数:29,代码来源:MadMeshCombinerAtlasBuilder.cs


示例14: CheckShaderAndCreateMaterial

        protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
        {
            if (!s)
            {
                Debug.Log("Missing shader in " + this.ToString());
                enabled = false;
                return null;
            }

            if (s.isSupported && m2Create && m2Create.shader == s)
                return m2Create;

            if (!s.isSupported)
            {
                enabled = false;
                isSupported = false;
                Debug.Log("The shader " + s.ToString() + " on effect " + this.ToString() + " is not supported on this platform!");
                return null;
            }
            else
            {
                //Debug.Log("Creating material");
                m2Create = new Material(s);
                m2Create.hideFlags = HideFlags.DontSave;
                if (m2Create)
                {
                    return m2Create;
                }
                else
                    return null;
            }
        }
开发者ID:Waffletech,项目名称:KerbalKwality,代码行数:32,代码来源:ImageEffectBase.cs


示例15: GetPropertyType

		/*
		private static string[] kShaderLevels = new string[]
		{
			"Fixed function",
			"SM1.x",
			"SM2.0",
			"SM3.0",
			"SM4.0",
			"SM5.0"
		};
		*/
		private static string GetPropertyType( Shader s, int index ) {
			ShaderUtil.ShaderPropertyType propertyType = ShaderUtil.GetPropertyType( s, index );
			if( propertyType == ShaderUtil.ShaderPropertyType.TexEnv ) {
				return ShaderForgeInspector.kTextureTypes[(int)ShaderUtil.GetTexDim( s, index )];
			}
			return ShaderForgeInspector.kPropertyTypes[(int)propertyType];
		}
开发者ID:decentninja,项目名称:Bird-Mating-Dancy,代码行数:18,代码来源:ShaderForgeInspector.cs


示例16: GetOptimizedShaderName

		public static string GetOptimizedShaderName(Shader shader)
		{
			if (shader)
			{
				return ShaderUtil.GetDependency(shader, "OptimizedShader");
			}
			return null;
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:8,代码来源:TreeEditorHelper.cs


示例17: GetPropertyString

 private static string GetPropertyString(Shader shader, string name)
 {
     if (shader == null)
     {
         return string.Empty;
     }
     return (shader.GetInstanceID() + "_" + name);
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:8,代码来源:MaterialPropertyHandler.cs


示例18: ShowShaderProperties

 private static void ShowShaderProperties(Shader s)
 {
   GUILayout.Space(5f);
   GUILayout.Label("Properties:", EditorStyles.boldLabel, new GUILayoutOption[0]);
   int propertyCount = ShaderUtil.GetPropertyCount(s);
   for (int index = 0; index < propertyCount; ++index)
     EditorGUILayout.LabelField(ShaderUtil.GetPropertyName(s, index), ShaderInspector.GetPropertyType(s, index) + ShaderUtil.GetPropertyDescription(s, index), new GUILayoutOption[0]);
 }
开发者ID:BlakeTriana,项目名称:unity-decompiled,代码行数:8,代码来源:ShaderInspector.cs


示例19: GlowEvent

        public GlowEvent(XftEventComponent owner)
            : base(CameraEffectEvent.EType.Glow, owner)
        {

            downsampleShader = owner.GlowDownSampleShader;
            compositeShader = owner.GlowCompositeShader;
            blurShader = owner.GlowBlurShader;
        }
开发者ID:GDxU,项目名称:incomplete-richman,代码行数:8,代码来源:GlowEvent.cs


示例20: CreateMaterial

 private static Material CreateMaterial (Shader shader)
 {
     if (!shader)
         return null;
     Material m = new Material (shader);
     m.hideFlags = HideFlags.HideAndDontSave;
     return m;
 }
开发者ID:CaptainStouf,项目名称:TheKinectAwakens,代码行数:8,代码来源:ScreenSpaceAmbientOcclusion.cs



注:本文中的UnityEngine.Shader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.SkinnedMeshRenderer类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Rigidbody2D类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap