public VMTLoader.VMTFile GetVMTMaterial(string materialName) { VMTLoader.VMTFile vmtFile = null; if (!VMTMaterials.ContainsKey(materialName)) { vmtFile = VMTLoader.ParseVMTFile(materialName); VMTMaterials.Add(materialName, vmtFile); } else { vmtFile = VMTMaterials [materialName]; } return(vmtFile); }
public Material GetMaterial(string materialName) { Material tempmat = null; if (Materials.ContainsKey(materialName)) { return(Materials[materialName]); } //VMT VMTLoader.VMTFile vmtFile = GetVMTMaterial(materialName); //Material if (vmtFile != null) { if (vmtFile.shader == "lightmappedgeneric") { if (vmtFile.selfillum) { tempmat = new Material(uSrcSettings.Inst.resources.sSelfillum); } else if (!vmtFile.translucent && !vmtFile.alphatest) { //tempmat = new Material(uSrcSettings.Inst.resources.sDiffuse); tempmat = new Material(uSrcSettings.Inst.resources.diffuseMaterial); } else { //tempmat = new Material(uSrcSettings.Inst.resources.sTransparent); Also fixes the transparency. tempmat = new Material(uSrcSettings.Inst.resources.transparentMaterial); } } else if (vmtFile.shader == "unlitgeneric") { if (vmtFile.additive) { tempmat = new Material(uSrcSettings.Inst.resources.sAdditive); tempmat.SetColor("_TintColor", Color.white); } else if (!vmtFile.translucent && !vmtFile.alphatest) { tempmat = new Material(uSrcSettings.Inst.resources.sUnlit); } else { tempmat = new Material(uSrcSettings.Inst.resources.sUnlitTransparent); } } else if (vmtFile.shader == "unlittwotexture") { tempmat = new Material(uSrcSettings.Inst.resources.sUnlit); } else if (vmtFile.shader == "vertexlitgeneric") { if (vmtFile.selfillum) { tempmat = new Material(uSrcSettings.Inst.resources.sSelfillum); } else if (vmtFile.alphatest) { //tempmat = new Material(uSrcSettings.Inst.resources.sAlphatest); Slow but sure move to materials instead of shaders. tempmat = new Material(uSrcSettings.Inst.resources.transparentCutout); } else if (vmtFile.translucent) { //tempmat = new Material(uSrcSettings.Inst.resources.sTransparent); This fixes the transparency. tempmat = new Material(uSrcSettings.Inst.resources.transparentMaterial); } else { //tempmat = new Material(uSrcSettings.Inst.resources.sVertexLit); This is to turn down the smoothness. tempmat = new Material(uSrcSettings.Inst.resources.vertexLitMaterial); } } else if (vmtFile.shader == "refract") { tempmat = new Material(uSrcSettings.Inst.resources.sRefract); } else if (vmtFile.shader == "worldvertextransition") { tempmat = new Material(uSrcSettings.Inst.resources.sWorldVertexTransition); string bt2 = vmtFile.basetexture2; Texture tex2 = GetTexture(bt2); tempmat.SetTexture("_MainTex2", tex2); if (tex2 == null) { Debug.LogWarning("Error loading second texture " + bt2 + " from material " + materialName); } } else if (vmtFile.shader == "water") { Debug.LogWarning("Shader " + vmtFile.shader + " from VMT " + materialName + " not suported"); tempmat = new Material(uSrcSettings.Inst.resources.transparentMaterial); tempmat.color = new Color(1, 1, 1, 0.3f); } else if (vmtFile.shader == "black") { tempmat = new Material(uSrcSettings.Inst.resources.sUnlit); tempmat.color = Color.black; } else if (vmtFile.shader == "infected") { tempmat = new Material(uSrcSettings.Inst.resources.diffuseMaterial); } /*else if(vmtFile.shader=="eyerefract") * { * Debug.Log ("EyeRefract shader not done. Used Diffuse"); * tempmat = new Material(uSrcSettings.Inst.resources.sDiffuse); * }*/ else { Debug.LogWarning("Shader " + vmtFile.shader + " from VMT " + materialName + " not suported"); tempmat = new Material(uSrcSettings.Inst.resources.diffuseMaterial); } tempmat.name = materialName; string textureName = vmtFile.basetexture; if (textureName != null) { textureName = textureName.ToLower(); Texture mainTex = GetTexture(textureName); tempmat.mainTexture = mainTex; // Replace name tempmat.name = tempmat.name.Replace("maps/" + Test.Inst.mapName + "/", ""); if (mainTex == null) { Debug.LogWarning("Error loading texture " + textureName + " from material " + materialName); } } else { //tempmat.shader = Shader.Find ("Transparent/Diffuse"); //tempmat.color = new Color (1, 1, 1, 0f); } if (vmtFile.dudvmap != null & vmtFile.shader == "refract") { string dudv = vmtFile.dudvmap.ToLower(); Texture dudvTex = GetTexture(dudv); tempmat.SetTexture("_BumpMap", dudvTex); if (dudvTex == null) { Debug.LogWarning("Error loading texture " + dudv + " from material " + materialName); } } Materials.Add(materialName, tempmat); return(tempmat); } else { //Debug.LogWarning("Error loading "+materialName); Materials.Add(materialName, Test.Inst.testMaterial); return(Test.Inst.testMaterial); } }
public Material GetMaterial(string materialName) { Material tempmat = null; if (Materials.ContainsKey(materialName)) { return(Materials[materialName]); } //VMT VMTLoader.VMTFile vmtFile = GetVMTMaterial(materialName); //Material if (vmtFile != null) { if (vmtFile.shader.ToLower() == "lightmappedgeneric") { if (vmtFile.selfillum) { tempmat = new Material(uSrcSettings.Inst.sSelfillum); } else if (!vmtFile.translucent && !vmtFile.alphatest) { tempmat = new Material(uSrcSettings.Inst.sDiffuse); } else { tempmat = new Material(uSrcSettings.Inst.sTransparent); } } else if (vmtFile.shader.ToLower() == "unlitgeneric") { if (vmtFile.additive) { tempmat = new Material(uSrcSettings.Inst.sAdditive); tempmat.SetColor("_TintColor", Color.white); } else if (!vmtFile.translucent && !vmtFile.alphatest) { tempmat = new Material(uSrcSettings.Inst.sUnlit); } else { tempmat = new Material(uSrcSettings.Inst.sUnlitTransparent); } } else if (vmtFile.shader.ToLower() == "unlittwotexture") { tempmat = new Material(uSrcSettings.Inst.sUnlit); } else if (vmtFile.shader.ToLower() == "vertexlitgeneric") { if (vmtFile.selfillum) { tempmat = new Material(uSrcSettings.Inst.sSelfillum); } else if (vmtFile.alphatest || vmtFile.translucent) { tempmat = new Material(uSrcSettings.Inst.sTransparent); } else { tempmat = new Material(uSrcSettings.Inst.sVertexLit); } } else if (vmtFile.shader.ToLower() == "water") { Debug.Log("Water shader not done. Used Diffuse"); tempmat = new Material(uSrcSettings.Inst.sDiffuse); } else if (vmtFile.shader.ToLower() == "worldvertextransition") { Debug.Log("WorldVertexTransition shader not done. Used Diffuse"); tempmat = new Material(uSrcSettings.Inst.sDiffuse); } else if (vmtFile.shader.ToLower() == "eyerefract") { Debug.Log("EyeRefract shader not done. Used Diffuse"); tempmat = new Material(uSrcSettings.Inst.sDiffuse); } else if (vmtFile.shader.ToLower() == "refract") { tempmat = new Material(uSrcSettings.Inst.sRefract); } else { Debug.LogWarning("Shader " + vmtFile.shader + " from VMT " + materialName + " not suported"); tempmat = new Material(uSrcSettings.Inst.sDiffuse); } tempmat.name = materialName; string textureName = vmtFile.basetexture; if (textureName != null) { textureName = textureName.ToLower(); Texture mainTex = GetTexture(textureName); tempmat.mainTexture = mainTex; if (mainTex == null) { Debug.LogWarning("Error loading texture " + textureName + " from material " + materialName); } } else { //tempmat.shader = Shader.Find ("Transparent/Diffuse"); //tempmat.color = new Color (1, 1, 1, 0f); } if (vmtFile.dudvmap != null) { string dudv = vmtFile.dudvmap.ToLower(); Texture dudvTex = GetTexture(dudv); tempmat.SetTexture("_BumpMap", dudvTex); if (dudvTex == null) { Debug.LogWarning("Error loading texture " + dudv + " from material " + materialName); } } Materials.Add(materialName, tempmat); return(tempmat); } else { //Debug.LogWarning("Error loading "+materialName); Materials.Add(materialName, Test.Inst.testMaterial); return(Test.Inst.testMaterial); } }