Inheritance: UnityEngine.Object
    static void Shader_renderQueue(JSVCall vc)
    {
        UnityEngine.Shader _this = (UnityEngine.Shader)vc.csObj;
        var result = _this.renderQueue;

        JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
    }
 static public int constructor(IntPtr l)
 {
     UnityEngine.Shader o;
     o = new UnityEngine.Shader();
     pushObject(l, o);
     return(1);
 }
Exemple #3
0
		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;
		}
Exemple #4
0
    static int _CreateUnityEngine_Material(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 1 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Material)))
        {
            UnityEngine.Material arg0 = (UnityEngine.Material)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Material));
            UnityEngine.Material obj  = new UnityEngine.Material(arg0);
            ToLua.Push(L, obj);
            return(1);
        }
        else if (count == 1 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.Shader)))
        {
            UnityEngine.Shader   arg0 = (UnityEngine.Shader)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Shader));
            UnityEngine.Material obj  = new UnityEngine.Material(arg0);
            ToLua.Push(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.Material.New");
        }

        return(0);
    }
		/*
		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];
		}
    static int LoadShader(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Shader o    = ShibaInu.ResManager.LoadShader(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                string             arg1 = ToLua.CheckString(L, 2);
                UnityEngine.Shader o    = ShibaInu.ResManager.LoadShader(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ShibaInu.ResManager.LoadShader"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        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
            }
        }
Exemple #8
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.Shader shader = (UnityEngine.Shader)value;
     writer.WriteProperty("name", shader.name);
     writer.WriteProperty("maximumLOD", shader.maximumLOD);
     writer.WriteProperty("hideFlags", shader.hideFlags);
 }
 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);
     }
 }
 private static void ChangeShaderOnMaterial(Material material, Shader shader)
 {
     if ((material != null) && (shader != null))
     {
         material.shader = shader;
     }
 }
        // 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);
            }
        }
Exemple #12
0
 static GasOverlayMats()
 {
     TransmitterShader = ShaderDatabase.MetaOverlay;
     Graphic subGraphic = GraphicDatabase.Get<Graphic_Single>(TransmitterAtlasPath, TransmitterShader);
     LinkedOverlayGraphic = new Graphic_LinkedGasPipe(subGraphic);
     subGraphic.MatSingle.renderQueue = 3800;
 }
        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;
            }
        }
        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;
        }
    static int _CreateUnityEngine_Material(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Material)))
            {
                UnityEngine.Material arg0 = (UnityEngine.Material)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Material));
                UnityEngine.Material obj  = new UnityEngine.Material(arg0);
                ToLua.Push(L, obj);
                return(1);
            }
            else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Shader)))
            {
                UnityEngine.Shader   arg0 = (UnityEngine.Shader)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.Shader));
                UnityEngine.Material obj  = new UnityEngine.Material(arg0);
                ToLua.Push(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Material.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemple #16
0
    static int _CreateUnityEngine_Shader(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Shader.ctor");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.Shader obj = new UnityEngine.Shader();
                ToLua.PushSealed(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.Shader.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
			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);
			}
 void OnDisable()
 {
     _target = null;
     _propertyName = null;
     _propertyList = null;
     _cachedShader = null;
 }
 private void ShowShaderCodeArea(Shader s)
 {
   ShaderInspector.ShowSurfaceShaderButton(s);
   ShaderInspector.ShowFixedFunctionShaderButton(s);
   this.ShowCompiledCodeButton(s);
   this.ShowShaderErrors(s);
 }
Exemple #20
0
    static int LoadShader(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                ResModuleUtility   obj  = (ResModuleUtility)ToLua.CheckObject <ResModuleUtility>(L, 1);
                string             arg0 = ToLua.CheckString(L, 2);
                UnityEngine.Shader o    = obj.LoadShader(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 3)
            {
                ResModuleUtility   obj  = (ResModuleUtility)ToLua.CheckObject <ResModuleUtility>(L, 1);
                string             arg0 = ToLua.CheckString(L, 2);
                bool               arg1 = LuaDLL.luaL_checkboolean(L, 3);
                UnityEngine.Shader o    = obj.LoadShader(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ResModuleUtility.LoadShader"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
        public _GameObjectAndWarning(UnityEngine.GameObject g, string w, LightMapOption ls)
        {
            go = g;
            lightmapSetting = ls;
            UnityEngine.Renderer r = MB_Utility.GetRenderer(g);
            material = r.sharedMaterial;
            if (material != null)
            {
                shader = material.shader;
            }
            materials = r.sharedMaterials;
            shaders   = new UnityEngine.Shader[materials.Length];
            for (int i = 0; i < shaders.Length; i++)
            {
                if (materials[i] != null)
                {
                    shaders[i] = materials[i].shader;
                }
            }
            lightmapIndex = r.lightmapIndex;
            Mesh mesh = MB_Utility.GetMesh(g);

            numVerts = 0;
            if (mesh != null)
            {
                numVerts = mesh.vertexCount;
            }
            isStatic         = go.isStatic;
            numMaterials     = materials.Length;
            warning          = w;
            outOfBoundsUVs   = false;
            submeshesOverlap = false;
        }
Exemple #22
0
        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;
        }
Exemple #23
0
        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];
        }
// fields

// properties
    static void Shader_isSupported(JSVCall vc)
    {
        UnityEngine.Shader _this = (UnityEngine.Shader)vc.csObj;
        var result = _this.isSupported;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
        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;
        }
 private static string GetPropertyString(Shader shader, string name)
 {
     if (shader == null)
     {
         return string.Empty;
     }
     return (shader.GetInstanceID() + "_" + name);
 }
		public static string GetOptimizedShaderName(Shader shader)
		{
			if (shader)
			{
				return ShaderUtil.GetDependency(shader, "OptimizedShader");
			}
			return null;
		}
 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]);
 }
        public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
        {
            base.AssignNewShaderToMaterial(material, oldShader, newShader);

            if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
                return;
            SetMaterialKeywords(material);
        }
 private static Material CreateMaterial (Shader shader)
 {
     if (!shader)
         return null;
     Material m = new Material (shader);
     m.hideFlags = HideFlags.HideAndDontSave;
     return m;
 }
Exemple #31
0
        public GlowEvent(XftEventComponent owner)
            : base(CameraEffectEvent.EType.Glow, owner)
        {

            downsampleShader = owner.GlowDownSampleShader;
            compositeShader = owner.GlowCompositeShader;
            blurShader = owner.GlowBlurShader;
        }
    static public int set_maximumLOD(IntPtr l)
    {
        UnityEngine.Shader o = (UnityEngine.Shader)checkSelf(l);
        int v;

        checkType(l, 2, out v);
        o.maximumLOD = v;
        return(0);
    }
        public static Material CheckShaderAndCreateMaterial(Shader s)
        {
            if (s == null || !s.isSupported)
                return null;

            var material = new Material(s);
            material.hideFlags = HideFlags.DontSave;
            return material;
        }
 /// <summary>
 /// call when added to rendering node list, not able to override
 /// </summary>
 public void BaseInit()
 {
     m_matScreenMat = RenderingMgr.Instance.ScreenInfo.DefaultMat;
     m_defaultShader = RenderingMgr.Instance.ScreenInfo.DefaultShader;
     m_camProcessor = RenderingMgr.Instance.ScreenInfo.ProcessCam;
     Reset();
     SetShaderParam();
     Init();
 }
Exemple #35
0
        public ImageBlur(Shader blurShader)
        {
            BlurIterations = 1;
            BlurSpread = 0.6f;
            BlurMode = BLUR_MODE.DOWNSAMPLE_2;

            if(blurShader != null)
                m_blurMaterial = new Material(blurShader);
        }
        /// <summary>
        /// 
        /// </summary>
        public RefractionCommand(Shader copyDepth)
        {
            GrabName = Ocean.REFRACTION_GRAB_TEXTURE_NAME;

            DepthName = Ocean.DEPTH_GRAB_TEXTURE_NAME;

            m_copyDepthMat = new Material(copyDepth);

            m_data = new Dictionary<Camera, CommandData>();
        }
		/**
		 *	Attempt to read the shader source code to a string.  If source can't be found (built-in shaders are in binary bundles)
		 * 	an empty string is returned.
		 */
		public static string GetSource(Shader shader)
		{
			string path = AssetDatabase.GetAssetPath(shader);

			// built-in shaders don't have a valid path.
			if(File.Exists(path))
				return File.ReadAllText( path );
			else
				return string.Empty;
		}
 public DisplacementBufferGPU(int size, Shader fourierSdr)
     : base(size, fourierSdr, DisplacementBufferGPU.NUM_BUFFERS)
 {
     int gRIDS = QueryDisplacements.GRIDS;
     int cHANNELS = QueryDisplacements.CHANNELS;
     this.m_displacements = new InterpolatedArray2f[gRIDS];
     for (int i = 0; i < gRIDS; i++)
     {
         this.m_displacements[i] = new InterpolatedArray2f(size, size, cHANNELS, true);
     }
 }
 void ValidateSkybox() {
   if (skyShader == null) {
     skyShader = Shader.Find("GVR/Sky");
   }
   if (RenderSettings.skybox == null || RenderSettings.skybox.shader != skyShader) {
     Debug.LogWarning("Auto-Generated Sky Material.");
     Material tmp = new Material(skyShader);
     tmp.name = "Auto-Generated Sky Material";
     RenderSettings.skybox = tmp;
   }
 }
 static public int get_isSupported(IntPtr l)
 {
     try {
         UnityEngine.Shader self = (UnityEngine.Shader)checkSelf(l);
         pushValue(l, self.isSupported);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_renderQueue(IntPtr l)
 {
     try {
         UnityEngine.Shader self = (UnityEngine.Shader)checkSelf(l);
         pushValue(l, self.renderQueue);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 public static Material CheckShaderAndCreateMaterial(Shader s)
 {
     if (s == null || !s.isSupported)
     {
         return null;
     }
     return new Material(s)
     {
         hideFlags = HideFlags.DontSave
     };
 }
	    public static bool ConvertDefaultAssets_DiffuseAlpha_Normal_Specular(string diffuseAlpha, string normal, string specular, string assetFolder, string assetName, string textureFolder, Shader shader)
	    {
	        if (!System.IO.Directory.Exists(textureFolder + '/' + assetFolder))
	        {
	            System.IO.Directory.CreateDirectory(textureFolder + '/' + assetFolder);
	        }
	       
	        var diffuseName = textureFolder + "/" + assetFolder + assetName + "_diffuse.png";
	        if (!CopyTextureToPng(diffuseAlpha, diffuseName)) return false;

	        var normalName = textureFolder + "/" + assetFolder + assetName + "_normal.png";
	        if (!CopyTextureToPng(normal, normalName)) return false;

	        var specularName = textureFolder + "/" + assetFolder + assetName + "_specular.png";
	        if (!CopyTextureToPng(specular, specularName)) return false;

	        AssetDatabase.SaveAssets();
	        AssetDatabase.Refresh();
	        
	        EnforceReadAndARGB32(specularName);
	        EnforceReadAndARGB32(normalName);


	        AssetDatabase.SaveAssets();
	        AssetDatabase.Refresh();

	        Color32[] normals = LoadPixels(normalName);
	        Color32[] speculars = LoadPixels(specularName);

	        for (int i = 0; i < normals.Length; i++)
	        {
				normals[i].a = normals[i].r;
	            //normals[i].g = normals[i].g;
				normals[i].r = (byte)((speculars[i].r + speculars[i].g + speculars[i].b) / 3);
				normals[i].b = speculars[i].a;
	        }

	        RemoveNormalMapFlag(normalName);

	        var normalTexture = AssetDatabase.LoadAssetAtPath(normalName, typeof(Texture2D)) as Texture2D;
	        normalTexture.SetPixels32(normals);
	        normalTexture.Apply();
			System.IO.File.WriteAllBytes(normalName, normalTexture.EncodeToPNG());

	        AssetDatabase.DeleteAsset(specularName);

	        bool readable = !UnityEditorInternal.InternalEditorUtility.HasPro();
	        SetReadable(normalName, readable);
	        SetReadable(diffuseName, readable);
	        
	        AssetDatabase.SaveAssets();
	        AssetDatabase.Refresh();
	        return true;
	    }
    private UnityEngine.Shader CreateShader(string shaderString)
    {
        string resPath = Application.dataPath + "/resources";

        Directory.CreateDirectory(resPath);
        File.WriteAllText(resPath + "/workingshader.shader", shaderString);
        UnityEngine.Shader currentShader = Resources.Load("workingshader") as UnityEngine.Shader;
        string             path          = AssetDatabase.GetAssetPath(currentShader);

        AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
        return(currentShader);
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Shader o;
         o = new UnityEngine.Shader();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #46
0
 static public int get_renderQueue(IntPtr l)
 {
     try {
         UnityEngine.Shader self = (UnityEngine.Shader)checkSelf(l);
         pushValue(l, self.renderQueue);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #47
0
 static public int get_maximumLOD(IntPtr l)
 {
     try {
         UnityEngine.Shader self = (UnityEngine.Shader)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.maximumLOD);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.Shader o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.Shader();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Exemple #49
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Shader o;
         o = new UnityEngine.Shader();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Exemple #50
0
    static bool Camera_RenderWithShader__Shader__String(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 2)
        {
            UnityEngine.Shader arg0 = (UnityEngine.Shader)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.String      arg1 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            ((UnityEngine.Camera)vc.csObj).RenderWithShader(arg0, arg1);
        }

        return(true);
    }
 static public int set_maximumLOD(IntPtr l)
 {
     try {
         UnityEngine.Shader self = (UnityEngine.Shader)checkSelf(l);
         int v;
         checkType(l, 2, out v);
         self.maximumLOD = v;
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #52
0
    /* ----------------------------------------------- Functions */
    #region Functions
    /* ********************************************************* */
    //! Get Material

    /*!
     * @param	indexCellMap
     *      CellMap's index
     * @param	operationBlend
     *      Blend Operation for the target
     * @param	masking
     *      masking for the target
     * @param	nameShadcer
     *      Shader's name in animation-data
     *      null == Default(Standard) shader's name
     * @param	shader
     *      Shader applied<br>
     *      null == Default(Standard) shader
     * @param	flagCreateNew
     *      true == If not exist, create.
     *      false == If not exist, return null.
     * @retval	Return-Value
     *      Instance of Material
     *      null == Not exist or Error
     *
     * Search material with the specified content among materials currently held.<br>
     * Materials (held by Animation-Object) are affected by currently playback state
     *      since materials are dynamically generated.<br>
     * Materials will not be created until Play-Cursor reachs actually using material,
     *      and once it is created, those will be retained until Animation-Object is destroyed.<br>
     */
    public UnityEngine.Material MaterialGet(int indexCellMap,
                                            Library_SpriteStudio6.KindOperationBlendEffect operationBlend,
                                            Library_SpriteStudio6.KindMasking masking,
                                            string nameShader,
                                            UnityEngine.Shader shader,
                                            bool flagCreateNew
                                            )
    {
        if (null == DataEffect)
        {
            return(null);
        }
        if (0 > indexCellMap)
        {
            return(null);
        }

        if (true == TextureCheckOverride(indexCellMap))
        {               /* Texture Overrided */
            return(CacheMaterial.MaterialGetEffect(indexCellMap,
                                                   operationBlend,
                                                   masking,
                                                   nameShader,
                                                   shader,
                                                   TableTexture,
                                                   flagCreateNew
                                                   )
                   );
        }

        if (TableCellMap.Length <= indexCellMap)
        {
            return(null);
        }

        Script_SpriteStudio6_DataProject dataProject = DataEffect.DataProject;

        if (null == dataProject)
        {
            return(null);
        }
        return(dataProject.MaterialGetEffect(indexCellMap,
                                             operationBlend,
                                             masking,
                                             nameShader,
                                             shader,
                                             flagCreateNew
                                             )
               );
    }
 static public int Find_s(IntPtr l)
 {
     try{
         System.String a1;
         checkType(l, 1, out a1);
         UnityEngine.Shader ret = UnityEngine.Shader.Find(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static int Find(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string             arg0 = ToLua.CheckString(L, 1);
         UnityEngine.Shader o    = UnityEngine.Shader.Find(arg0);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static void Shader_maximumLOD(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.Shader _this = (UnityEngine.Shader)vc.csObj;
         var result = _this.maximumLOD;
         JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
     }
     else
     {
         System.Int32       arg0  = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
         UnityEngine.Shader _this = (UnityEngine.Shader)vc.csObj;
         _this.maximumLOD = arg0;
     }
 }
Exemple #56
0
 static int GetPropertyCount(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Shader obj = (UnityEngine.Shader)ToLua.CheckObject(L, 1, typeof(UnityEngine.Shader));
         int o = obj.GetPropertyCount();
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
// fields

// properties
    static void Material_shader(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.Material _this = (UnityEngine.Material)vc.csObj;
            var result = _this.shader;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Shader   arg0  = (UnityEngine.Shader)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Material _this = (UnityEngine.Material)vc.csObj;
            _this.shader = arg0;
        }
    }
Exemple #58
0
 static int GetPropertyType(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Shader obj = (UnityEngine.Shader)ToLua.CheckObject(L, 1, typeof(UnityEngine.Shader));
         int arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         UnityEngine.Rendering.ShaderPropertyType o = obj.GetPropertyType(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #59
0
 static int FindPropertyIndex(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Shader obj  = (UnityEngine.Shader)ToLua.CheckObject(L, 1, typeof(UnityEngine.Shader));
         string             arg0 = ToLua.CheckString(L, 2);
         int o = obj.FindPropertyIndex(arg0);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #60
0
 static int GetDependency(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Shader obj  = (UnityEngine.Shader)ToLua.CheckObject(L, 1, typeof(UnityEngine.Shader));
         string             arg0 = ToLua.CheckString(L, 2);
         UnityEngine.Shader o    = obj.GetDependency(arg0);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }