public override void OnGUI(MaterialEditor me, MaterialProperty[] props) { if (!me.isVisible) { return; } ClearDictionaries(); foreach (var property in GetType().GetFields(bindingFlags)) { if (property.FieldType == typeof(MaterialProperty)) { property.SetValue(this, FindProperty(property.Name, props)); } } Material mat = (Material)me.target; if (m_FirstTimeApply) { m_FirstTimeApply = false; } header = "WaterHeader_Pro"; if (!EditorGUIUtility.isProSkin) { header = "WaterHeader"; } Texture2D headerTex = (Texture2D)Resources.Load(header, typeof(Texture2D)); Texture2D collapseIcon = (Texture2D)Resources.Load("CollapseIcon", typeof(Texture2D)); GUILayout.Label(headerTex); MGUI.Space4(); if (!foldouts.ContainsKey(mat)) { foldouts.Add(mat, toggles); } EditorGUI.BeginChangeCheck(); { // Surface baseTabButtons.Add(() => { Toggles.CollapseFoldouts(mat, foldouts, 1); }, MGUI.collapseLabel); baseTabButtons.Add(() => { ResetSurface(); }, MGUI.resetLabel); Action surfaceTabAction = () => { MGUI.PropertyGroup(() => { me.RenderQueueField(); me.ShaderProperty(_CullMode, "Culling Mode"); me.ShaderProperty(_ZWrite, "ZWrite"); me.ShaderProperty(_Opacity, "Opacity"); me.ShaderProperty(_DistortionStrength, "Distortion Strength"); MGUI.Space2(); }); MGUI.PropertyGroup(() => { me.TexturePropertySingleLine(texLabel, _MainTex, _Color, _BaseColorStochasticToggle); MGUI.TexPropLabel(Tips.stochasticLabel, 172); MGUI.TextureSOScroll(me, _MainTex, _MainTexScroll); me.ShaderProperty(_BaseColorOffset, Tips.parallaxOffsetLabel); me.ShaderProperty(_BaseColorDistortionStrength, "Distortion Strength"); }); MGUI.DisplayInfo(" This shader requires a \"Depth Light\" prefab be present in the scene.\n (Found in: Assets/Mochie/Unity/Prefabs)"); }; Foldouts.Foldout("BASE", foldouts, baseTabButtons, mat, me, surfaceTabAction); // Primary Normal norm0TabButtons.Add(() => { ResetPrimaryNormal(); }, MGUI.resetLabel); Action norm0TabAction = () => { MGUI.Space4(); MGUI.PropertyGroup(() => { me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap0, _Normal0StochasticToggle); MGUI.TexPropLabel(Tips.stochasticLabel, 172); me.ShaderProperty(_NormalStr0, "Strength"); MGUI.Vector2Field(_NormalMapScale0, "Scale"); MGUI.Vector2Field(_NormalMapScroll0, "Scrolling"); me.ShaderProperty(_Rotation0, "Rotation"); me.ShaderProperty(_NormalMapOffset0, Tips.parallaxOffsetLabel); }); }; Foldouts.Foldout("PRIMARY NORMAL", foldouts, norm0TabButtons, mat, me, norm0TabAction); // Secondary Normal norm1TabButtons.Add(() => { ResetSecondaryNormal(); }, MGUI.resetLabel); Action norm1TabAction = () => { me.ShaderProperty(_Normal1Toggle, "Enable"); MGUI.Space4(); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_Normal1Toggle.floatValue == 0); me.TexturePropertySingleLine(Tips.waterNormalMap, _NormalMap1, _Normal1StochasticToggle); MGUI.TexPropLabel(Tips.stochasticLabel, 172); me.ShaderProperty(_NormalStr1, "Strength"); MGUI.Vector2Field(_NormalMapScale1, "Scale"); MGUI.Vector2Field(_NormalMapScroll1, "Scrolling"); me.ShaderProperty(_Rotation1, "Rotation"); me.ShaderProperty(_NormalMapOffset1, Tips.parallaxOffsetLabel); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("SECONDARY NORMAL", foldouts, norm1TabButtons, mat, me, norm1TabAction); // Reflections & Specular reflSpecTabButtons.Add(() => { ResetReflSpec(); }, MGUI.resetLabel); Action reflSpecTabAction = () => { MGUI.Space4(); me.ShaderProperty(_Roughness, Tips.waterRoughness); me.ShaderProperty(_Metallic, Tips.waterMetallic); MGUI.Space8(); me.ShaderProperty(_Reflections, "Reflections"); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_Reflections.floatValue == 0); if (_Reflections.floatValue == 2) { me.TexturePropertySingleLine(cubeLabel, _ReflCube); MGUI.Vector3Field(_ReflCubeRotation, "Rotation", false); } me.ShaderProperty(_ReflStrength, "Strength"); MGUI.ToggleFloat(me, "Screenspace Reflections", _SSR, _SSRStrength); if (_SSR.floatValue > 0) { me.ShaderProperty(_EdgeFadeSSR, "Edge Fade"); } me.ShaderProperty(_ReflTint, "Tint"); MGUI.ToggleGroupEnd(); }); MGUI.Space8(); me.ShaderProperty(_Specular, "Specular"); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_Specular.floatValue == 0); if (_Specular.floatValue == 2) { MGUI.Vector3Field(_LightDir, "Light Direction", false); } me.ShaderProperty(_SpecStrength, "Strength"); me.ShaderProperty(_SpecTint, "Tint"); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("REFLECTIONS & SPECULAR", foldouts, reflSpecTabButtons, mat, me, reflSpecTabAction); // Flow Mapping flowTabButtons.Add(() => { ResetFlowMapping(); }, MGUI.resetLabel); Action flowTabAction = () => { me.ShaderProperty(_FlowToggle, "Enable"); MGUI.Space4(); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_FlowToggle.floatValue == 0); me.TexturePropertySingleLine(flowLabel, _FlowMap); MGUI.Vector2Field(_FlowMapScale, "Scale"); me.ShaderProperty(_FlowSpeed, "Speed"); me.ShaderProperty(_FlowStrength, "Strength"); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("FLOW MAPPING", foldouts, flowTabButtons, mat, me, flowTabAction); // Vertex Offset vertTabButtons.Add(() => { ResetVertOffset(); }, MGUI.resetLabel); Action vertTabAction = () => { me.ShaderProperty(_VertOffsetMode, "Mode"); MGUI.Space4(); MGUI.ToggleGroup(_VertOffsetMode.floatValue == 0); if (_VertOffsetMode.floatValue == 1) { MGUI.PropertyGroup(() => { me.TexturePropertySingleLine(noiseLabel, _NoiseTex); me.ShaderProperty(_NoiseTexBlur, "Blur"); MGUI.Vector2Field(_NoiseTexScale, "Scale"); MGUI.Vector2Field(_NoiseTexScroll, "Scrolling"); }); MGUI.PropertyGroup(() => { MGUI.Vector3Field(_Offset, "Strength", false); me.ShaderProperty(_WaveHeight, "Strength Multiplier"); MGUI.SliderMinMax(_VertRemapMin, _VertRemapMax, -1f, 1f, "Remap", 1); }); } else if (_VertOffsetMode.floatValue == 2) { MGUI.BoldLabel("Global"); MGUI.PropertyGroup(() => { me.ShaderProperty(_WaveStrengthGlobal, "Strength"); me.ShaderProperty(_WaveScaleGlobal, "Scale"); me.ShaderProperty(_WaveSpeedGlobal, "Speed"); }); MGUI.BoldLabel("Wave 1"); MGUI.PropertyGroup(() => { me.ShaderProperty(_WaveStrength0, "Strength"); me.ShaderProperty(_WaveScale0, "Scale"); me.ShaderProperty(_WaveSpeed0, "Speed"); me.ShaderProperty(_WaveDirection0, "Direction"); }); MGUI.BoldLabel("Wave 2"); MGUI.PropertyGroup(() => { me.ShaderProperty(_WaveStrength1, "Strength"); me.ShaderProperty(_WaveScale1, "Scale"); me.ShaderProperty(_WaveSpeed1, "Speed"); me.ShaderProperty(_WaveDirection1, "Direction"); }); MGUI.BoldLabel("Wave 3"); MGUI.PropertyGroup(() => { me.ShaderProperty(_WaveStrength2, "Strength"); me.ShaderProperty(_WaveScale2, "Scale"); me.ShaderProperty(_WaveSpeed2, "Speed"); me.ShaderProperty(_WaveDirection2, "Direction"); }); MGUI.BoldLabel("Turbulence"); MGUI.PropertyGroup(() => { me.ShaderProperty(_Turbulence, Tips.turbulence); me.ShaderProperty(_TurbulenceSpeed, "Speed"); me.ShaderProperty(_TurbulenceScale, "Scale"); }); } MGUI.ToggleGroupEnd(); }; Foldouts.Foldout("VERTEX OFFSET", foldouts, vertTabButtons, mat, me, vertTabAction); // Caustics causticsTabButtons.Add(() => { ResetCaustics(); }, MGUI.resetLabel); Action causticsTabAction = () => { me.ShaderProperty(_CausticsToggle, "Enable"); MGUI.ToggleGroup(_CausticsToggle.floatValue == 0); MGUI.Space4(); MGUI.PropertyGroup(() => { me.ShaderProperty(_CausticsOpacity, "Strength"); me.ShaderProperty(_CausticsDisp, "Phase"); me.ShaderProperty(_CausticsSpeed, "Speed"); me.ShaderProperty(_CausticsScale, "Scale"); me.ShaderProperty(_CausticsFade, Tips.causticsFade); MGUI.Vector3Field(_CausticsRotation, "Rotation", false); }); MGUI.PropertyGroup(() => { me.ShaderProperty(_CausticsDistortion, "Distortion Strength"); me.ShaderProperty(_CausticsDistortionScale, "Distortion Scale"); MGUI.Vector2Field(_CausticsDistortionSpeed, "Distortion Speed"); }); MGUI.ToggleGroupEnd(); }; Foldouts.Foldout("CAUSTICS", foldouts, causticsTabButtons, mat, me, causticsTabAction); // Foam foamTabButtons.Add(() => { ResetFoam(); }, MGUI.resetLabel); Action foamTabAction = () => { me.ShaderProperty(_FoamToggle, "Enable"); MGUI.Space4(); MGUI.ToggleGroup(_FoamToggle.floatValue == 0); MGUI.PropertyGroup(() => { me.TexturePropertySingleLine(foamLabel, _FoamTex, _FoamColor, _FoamStochasticToggle); MGUI.TexPropLabel(Tips.stochasticLabel, 172); MGUI.Space2(); MGUI.Vector2Field(_FoamTexScale, "Scale"); MGUI.Vector2Field(_FoamTexScroll, "Scrolling"); me.ShaderProperty(_FoamOffset, Tips.parallaxOffsetLabel); me.ShaderProperty(_FoamDistortionStrength, "Distortion Strength"); MGUI.ToggleFloat(me, Tips.foamNormal, _FoamNormalToggle, _FoamNormalStrength); }); MGUI.PropertyGroup(() => { me.TexturePropertySingleLine(noiseLabel, _FoamNoiseTex); MGUI.Vector2Field(_FoamNoiseTexScale, "Scale"); MGUI.Vector2Field(_FoamNoiseTexScroll, "Scrolling"); me.ShaderProperty(_FoamNoiseTexStrength, Tips.foamNoiseTexStrength); me.ShaderProperty(_FoamNoiseTexCrestStrength, Tips.foamNoiseTexCrestStrength); }); MGUI.PropertyGroup(() => { me.ShaderProperty(_FoamRoughness, Tips.foamRoughness); me.ShaderProperty(_FoamPower, Tips.foamPower); me.ShaderProperty(_FoamOpacity, Tips.foamOpacity); me.ShaderProperty(_FoamCrestStrength, Tips.foamCrestStrength); me.ShaderProperty(_FoamCrestThreshold, Tips.foamCrestThreshold); }); MGUI.ToggleGroupEnd(); }; Foldouts.Foldout("FOAM", foldouts, foamTabButtons, mat, me, foamTabAction); // Depth Fog fogTabButtons.Add(() => { ResetFog(); }, MGUI.resetLabel); Action fogTabAction = () => { me.ShaderProperty(_FogToggle, "Enable"); MGUI.Space4(); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_FogToggle.floatValue == 0); me.ShaderProperty(_FogTint, "Color"); me.ShaderProperty(_FogPower, "Power"); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("DEPTH FOG", foldouts, fogTabButtons, mat, me, fogTabAction); // Edge Fade edgeFadeTabButtons.Add(() => { ResetEdgeFade(); }, MGUI.resetLabel); Action edgeFadeTabAction = () => { me.ShaderProperty(_EdgeFadeToggle, "Enable"); MGUI.Space4(); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_EdgeFadeToggle.floatValue == 0); me.ShaderProperty(_EdgeFadePower, "Power"); me.ShaderProperty(_EdgeFadeOffset, "Offset"); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("EDGE FADE", foldouts, edgeFadeTabButtons, mat, me, edgeFadeTabAction); // Rain rainTabButtons.Add(() => { ResetRain(); }, MGUI.resetLabel); Action rainTabAction = () => { me.ShaderProperty(_RainToggle, "Enable"); MGUI.Space4(); MGUI.PropertyGroup(() => { MGUI.ToggleGroup(_RainToggle.floatValue == 0); me.ShaderProperty(_RippleStr, "Strength"); me.ShaderProperty(_RippleSpeed, "Speed"); me.ShaderProperty(_RippleScale, "Scale"); MGUI.ToggleGroupEnd(); }); }; Foldouts.Foldout("RAIN", foldouts, rainTabButtons, mat, me, rainTabAction); } ApplyMaterialSettings(mat); GUILayout.Space(20); float buttonSize = 35f; Rect footerRect = EditorGUILayout.GetControlRect(); footerRect.x += (MGUI.GetInspectorWidth() / 2f) - buttonSize - 5f; footerRect.width = buttonSize; footerRect.height = buttonSize; if (GUI.Button(footerRect, MGUI.patIconTex)) { Application.OpenURL("https://www.patreon.com/mochieshaders"); } footerRect.x += buttonSize + 5f; footerRect.y += 17f; GUIStyle formatting = new GUIStyle(); formatting.fontSize = 15; formatting.fontStyle = FontStyle.Bold; if (EditorGUIUtility.isProSkin) { formatting.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 1); formatting.hover.textColor = new Color(0.8f, 0.8f, 0.8f, 1); GUI.Label(footerRect, versionLabel, formatting); footerRect.y += 20f; footerRect.x -= 35f; footerRect.width = 70f; footerRect.height = 70f; GUI.Label(footerRect, MGUI.mochieLogoPro); GUILayout.Space(90); } else { GUI.Label(footerRect, versionLabel, formatting); footerRect.y += 20f; footerRect.x -= 35f; footerRect.width = 70f; footerRect.height = 70f; GUI.Label(footerRect, MGUI.mochieLogo); GUILayout.Space(90); } }
void DoRenderingArea(Material mat) { MGUI.PropertyGroup(() => { MGUI.PropertyGroupLayer(() => { MGUI.SpaceN2(); if (samplingMode.floatValue != 4) { me.ShaderProperty(culling, Tips.culling); } queueOffset.floatValue = (int)queueOffset.floatValue; me.ShaderProperty(queueOffset, Tips.queueOffset); MGUI.SpaceN1(); MGUI.DummyProperty("Render Queue:", mat.renderQueue.ToString()); MGUI.SpaceN4(); }); MGUI.Space1(); MGUI.PropertyGroupLayer(() => { MGUI.SpaceN2(); MGUI.ToggleFloat(me, Tips.useFresnel, useFresnel, fresnelStrength); MGUI.ToggleFloat(me, Tips.highlightsText, highlights, specularStrength); MGUI.ToggleFloat(me, Tips.reflectionsText, reflections, reflectionStrength); MGUI.ToggleFloat(me, Tips.ssrText, ssr, ssrStrength); if (ssr.floatValue == 1) { me.ShaderProperty(edgeFade, Tips.edgeFadeText); } MGUI.ToggleFloat(me, Tips.reflVertexColor, reflVertexColor, reflVertexColorStrength); MGUI.ToggleFloat(me, Tips.reflShadows, reflShadows, reflShadowStrength); if (reflShadows.floatValue == 1) { me.ShaderProperty(brightnessReflShad, "Brightness", 1); me.ShaderProperty(contrastReflShad, "Contrast", 1); me.ShaderProperty(hdrReflShad, "HDR", 1); } MGUI.ToggleFloat(me, Tips.gsaa, gsaa, gsaaStrength); }); MGUI.Space1(); MGUI.PropertyGroupLayer(() => { MGUI.SpaceN3(); me.ShaderProperty(_BakeryMode, Tips.bakeryMode); me.ShaderProperty(_BAKERY_SHNONLINEAR, "Bakery Non-Linear SH"); me.ShaderProperty(_BAKERY_LMSPEC, "Bakery Lightmap Specular"); me.ShaderProperty(bicubicLightmap, Tips.bicubicLightmap); #if LTCGI_INCLUDED me.ShaderProperty(ltcgi, "LTCGI"); if (ltcgi.floatValue == 1) { me.ShaderProperty(ltcgi_spec_off, "LTCGI Disable Specular"); me.ShaderProperty(ltcgi_diffuse_off, "LTCGI Disable Diffuse"); } #else ltcgi.floatValue = 0; mat.DisableKeyword("LTCGI"); #endif me.EnableInstancingField(); MGUI.SpaceN2(); me.DoubleSidedGIField(); MGUI.SpaceN3(); }); if (ssr.floatValue == 1) { MGUI.DisplayInfo("\nScreenspace reflections in VRChat requires the \"Depth Light\" prefab found in: Assets/Mochie/Unity/Prefabs\n\nIt is also is VERY expensive, please use it sparingly!\n"); } MGUI.Space1(); // me.TexturePropertySingleLine(new GUIContent("RNM0"), _RNM0); // me.TexturePropertySingleLine(new GUIContent("RNM1"), _RNM1); // me.TexturePropertySingleLine(new GUIContent("RNM2"), _RNM2); }); }