private void SwapToVanillaPlusBody(MaterialEditorCharaController controller) { foreach (var renderer in GetRendererList(controller.ChaControl.gameObject)) { foreach (var material in GetMaterials(controller.ChaControl.gameObject, renderer)) { SwapToVanillaPlus(controller, 0, ObjectType.Character, material, controller.ChaControl.gameObject); } } }
private void SwapToVanillaPlusHair(MaterialEditorCharaController controller, int slot) { var go = controller.ChaControl.objHair[slot]; foreach (var renderer in GetRendererList(go)) { foreach (var material in GetMaterials(go, renderer)) { SwapToVanillaPlus(controller, slot, ObjectType.Hair, material, go); } } }
private void SwapToVanillaPlusAccessory(MaterialEditorCharaController controller, int slot) { var go = controller.ChaControl.GetAccessoryObject(slot); if (go != null) { foreach (var renderer in GetRendererList(go)) { foreach (var material in GetMaterials(go, renderer)) { SwapToVanillaPlus(controller, slot, ObjectType.Accessory, material, go); } } } }
private void SwapToVanillaPlus(MaterialEditorCharaController controller, int slot, ObjectType objectType, Material mat, GameObject go) { if (controller.GetMaterialShader(slot, ObjectType.Clothing, mat, go) == null) { if (VanillaPlusShaders.TryGetValue(mat.shader.name, out var vanillaPlusShaderName)) { int renderQueue = mat.renderQueue; controller.SetMaterialShader(slot, objectType, mat, vanillaPlusShaderName, go); controller.SetMaterialShaderRenderQueue(slot, objectType, mat, renderQueue, go); if (mat.shader.name == "xukmi/MainAlphaPlus") { controller.SetMaterialFloatProperty(slot, objectType, mat, "Cutoff", 0.1f, go); } } } }
internal static void ApplyEffect(ChaControl chaCtrl, int type, int slot, GameObject go) { if (go == null) { return; } ComponentLookupTable _lookup = go.GetComponent <ComponentLookupTable>(); if (_lookup == null) { return; } List <Renderer> renderers = _lookup.Components <Renderer>(); if (type == 1 && slot == 0 && go.transform.Find("ct_top_parts_A") != null) { foreach (Transform _child in go.transform) { renderers.AddRange(_child.GetComponent <ComponentLookupTable>().Components <Renderer>()); } } if (renderers?.Count == 0) { return; } MaterialEditorCharaController pluginCtrl = GetController(chaCtrl); Traverse traverse = Traverse.Create(pluginCtrl); for (int i = 0; i < renderers.Count; i++) { Renderer renderer = renderers[i]; if (renderer.materials?.Length == 0) { continue; } foreach (Material mat in renderer.materials) { if (!mat.HasProperty(ChaShader._Texture2)) { continue; } if (mat.GetTexture("_liquidmask") == null) { if (useR.IndexOf(go.name) >= 0) { mat.SetTexture("_liquidmask", liquidmaskR); } else if (useG.IndexOf(go.name) >= 0) { mat.SetTexture("_liquidmask", liquidmaskG); } } if (mat.GetTexture(ChaShader._Texture2) == null || CfgLiquidOverride.Value) { if (!HasMaterialTexture(traverse, slot, (ObjectType)type, mat, "Texture2", go)) { mat.SetTexture(ChaShader._Texture2, LiquidT); } } if (mat.HasProperty(ChaShader._Texture3) && (mat.GetTexture(ChaShader._Texture3) == null || CfgLiquidOverride.Value)) { if (!HasMaterialTexture(traverse, slot, (ObjectType)type, mat, "Texture3", go)) { mat.SetTexture(ChaShader._Texture3, LiquidN); } } float s0 = pluginCtrl.GetMaterialFloatPropertyValue(slot, (ObjectType)type, mat, "liquidface", go) ?? chaCtrl.fileStatus.siruLv[0]; mat.SetFloat(ChaShader._liquidface, s0); float s1 = pluginCtrl.GetMaterialFloatPropertyValue(slot, (ObjectType)type, mat, "liquidftop", go) ?? chaCtrl.fileStatus.siruLv[1]; mat.SetFloat(ChaShader._liquidftop, s1); float s2 = pluginCtrl.GetMaterialFloatPropertyValue(slot, (ObjectType)type, mat, "liquidfbot", go) ?? chaCtrl.fileStatus.siruLv[2]; mat.SetFloat(ChaShader._liquidfbot, s2); float s3 = pluginCtrl.GetMaterialFloatPropertyValue(slot, (ObjectType)type, mat, "liquidbtop", go) ?? chaCtrl.fileStatus.siruLv[3]; mat.SetFloat(ChaShader._liquidbtop, s3); float s4 = pluginCtrl.GetMaterialFloatPropertyValue(slot, (ObjectType)type, mat, "liquidbbot", go) ?? chaCtrl.fileStatus.siruLv[4]; mat.SetFloat(ChaShader._liquidbbot, s4); } } }