public void SetMaterial(P3dBlendMode blendMode, Texture texture, Color color, float opacity) { Material = cachedMaterials[blendMode]; Texture = texture; Color = color; Opacity = opacity; }
public static bool Blit(ref RenderTexture renderTexture, P3dBlendMode blendMode, Texture texture, Color color, float opacity) { Command.Instance.SetMaterial(blendMode, texture, color, opacity); Command.Instance.Apply(); if (Command.Instance.Swap == true) { var swap = P3dHelper.GetRenderTexture(renderTexture.width, renderTexture.height, renderTexture.depth, renderTexture.format); Command.Instance.Material.SetTexture(P3dShader._Buffer, renderTexture); P3dHelper.Blit(swap, Command.Instance.Material); P3dHelper.ReleaseRenderTexture(renderTexture); renderTexture = swap; return(true); } P3dHelper.Blit(renderTexture, Command.Instance.Material); return(false); }
public void SetMaterial(Texture texture, Color color, Vector4 channels) { Blend = P3dBlendMode.Replace(channels); Material = cachedMaterial; Texture = texture; Color = color; }
public void SetMaterial(P3dBlendMode blendMode, Texture texture, Texture shape, P3dChannel shapeChannel, float hardness, float wrapping, float normalBack, float normalFront, float normalFade, Color color, float opacity, Texture tileTexture, Matrix4x4 tileMatrix, float tileBlend) { switch (Extrusions) { case 0: Material = cachedSpotMaterials[blendMode]; break; case 1: Material = cachedLineMaterials[blendMode]; break; case 2: Material = cachedQuadMaterials[blendMode]; break; } Blend = blendMode; Color = color; Opacity = opacity; Hardness = hardness; Wrapping = wrapping; Texture = texture; Shape = shape; ShapeChannel = P3dHelper.IndexToVector((int)shapeChannel); TileTexture = tileTexture; TileMatrix = tileMatrix; TileBlend = tileBlend; var pointA = normalFront - 1.0f - normalFade; var pointB = normalFront - 1.0f; var pointC = 1.0f - normalBack + normalFade; var pointD = 1.0f - normalBack; NormalFront = new Vector2(pointA, P3dHelper.Reciprocal(pointB - pointA)); NormalBack = new Vector2(pointC, P3dHelper.Reciprocal(pointD - pointC)); }
public void SetMaterial(Texture texture, Color color) { Blend = P3dBlendMode.ReplaceCustom(color, texture); Material = cachedMaterial; Texture = texture; Color = color; Radius = float.PositiveInfinity; }
public static void SetMaterial(P3dBlendMode blendMode, Texture texture, Color color, float opacity) { cachedMaterial = cachedMaterials[(int)blendMode]; cachedSwap = cachedSwaps[(int)blendMode]; cachedTexture = texture; cachedColor = color; cachedOpacity = opacity; }
public static void SetMaterial(P3dBlendMode blendMode, Texture texture) { cachedMaterial = cachedMaterials[(int)blendMode]; cachedSwap = cachedSwaps[(int)blendMode]; cachedTexture = texture; cachedColor = Color.white; cachedOpacity = 1.0f; }
public void SetMaterial(P3dBlendMode blendMode, float hardness, Color color, float opacity) { Material = cachedMaterials[(int)blendMode]; Swap = cachedSwaps[(int)blendMode]; Hardness = hardness; Color = color; Opacity = opacity; }
public void SetMaterial(P3dBlendMode blendMode, float hardness, Color color, float opacity) { Blend = blendMode; Material = cachedMaterials[blendMode]; Hardness = hardness; Color = color; Opacity = opacity; }
public void SetMaterial(P3dBlendMode blendMode, Texture texture, Color color, float opacity, float minimum) { Blend = blendMode; Material = cachedMaterials[blendMode]; Texture = texture; Color = color; Opacity = opacity; Minimum = minimum; }
public void SetMaterial(P3dBlendMode blendMode, Texture decal, Color color, float opacity, Texture shape) { Blend = blendMode; Material = cachedMaterials[blendMode]; Color = color; Opacity = opacity; Texture = decal; Shape = shape; }
public static RenderTexture Blit(RenderTexture main, P3dBlendMode blendMode, Texture texture, Color color, float opacity, float minimum) { var swap = P3dHelper.GetRenderTexture(main.descriptor, main); Blit(ref main, ref swap, blendMode, texture, color, opacity, minimum); P3dHelper.ReleaseRenderTexture(swap); return(main); }
public static bool Blit(P3dBlendMode blendMode, ref RenderTexture renderTexture, Texture texture) { cachedMaterial = cachedMaterials[(int)blendMode]; cachedSwap = cachedSwaps[(int)blendMode]; cachedMaterial.SetTexture(P3dShader._Texture, texture); cachedMaterial.SetColor(P3dShader._Color, Color.white); cachedMaterial.SetFloat(P3dShader._Opacity, 1.0f); return(Blit(cachedMaterial, ref renderTexture)); }
public static void Blit(ref RenderTexture main, ref RenderTexture swap, P3dBlendMode blendMode, Texture texture, Color color, float opacity, float minimum) { Instance.SetMaterial(blendMode, texture, color, opacity, minimum); Instance.Apply(main); P3dHelper.Blit(swap, Instance.Material); P3dHelper.Swap(ref main, ref swap); }
public static void SetMaterial(P3dBlendMode blendMode, float hardness, Texture texture, float strength, float tiling, Color color, float opacity) { cachedMaterial = cachedMaterials[(int)blendMode]; cachedSwap = cachedSwaps[(int)blendMode]; cachedHardness = hardness; cachedTexture = texture; cachedStrength = strength; cachedTiling = tiling; cachedColor = color; cachedOpacity = opacity; }
public static void SetMaterial(P3dBlendMode blendMode, Texture decal, float hardness, float oneSided, Color color, float opacity, Texture shape) { cachedMaterial = cachedMaterials[(int)blendMode]; cachedSwap = cachedSwaps[(int)blendMode]; cachedColor = color; cachedOpacity = opacity; cachedHardness = hardness; cachedTexture = decal; cachedShape = shape; cachedNormalScale = oneSided; }
public void SetMaterial(P3dBlendMode blendMode, float hardness, Color color, float opacity, Texture texture, float strength, float tiling) { Material = cachedMaterials[(int)blendMode]; Swap = cachedSwaps[(int)blendMode]; Hardness = hardness; Color = color; Opacity = opacity; Texture = texture; Strength = strength; Tiling = tiling; }
public Material SetMaterial(P3dBlendMode blendMode, Texture texture, Color color, float opacity, float minimum) { Blend = blendMode; Material = new P3dHashedMaterial(cachedMaterial, cachedMaterialHash); Pass = blendMode; Texture = texture; Color = color; Opacity = opacity; Minimum = minimum; return(cachedMaterial); }
public void SetMaterial(Texture textureR, Texture textureG, Texture textureB, Texture textureA, Vector4 channelR, Vector4 channelG, Vector4 channelB, Vector4 channelA, Vector4 channels) { Blend = P3dBlendMode.Replace(channels); Material = cachedMaterial; TextureR = textureR; TextureG = textureG; TextureB = textureB; TextureA = textureA; ChannelR = channelR; ChannelG = channelG; ChannelB = channelB; ChannelA = channelA; }
public static void Blit(ref RenderTexture main, ref RenderTexture swap, P3dBlendMode blendMode, Texture texture, Color color, float opacity, float minimum) { Instance.SetMaterial(blendMode, texture, color, opacity, minimum); Instance.Apply(); if (Instance.Double == true) { P3dCommandReplace.Blit(swap, main, Color.white); Instance.Material.SetTexture(P3dShader._Buffer, swap); Instance.Material.SetVector(P3dShader._BufferSize, new Vector2(swap.width, swap.height)); } P3dHelper.Blit(main, Instance.Material); }
public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) { var sObj = property.serializedObject; var sIdx = property.FindPropertyRelative("Index"); var sCol = property.FindPropertyRelative("Color"); var sTex = property.FindPropertyRelative("Texture"); var sKer = property.FindPropertyRelative("Kernel"); var sCha = property.FindPropertyRelative("Channels"); var height = base.GetPropertyHeight(property, label); rect.height = height; var right = rect; right.xMin += EditorGUIUtility.labelWidth; EditorGUI.LabelField(rect, label); if (GUI.Button(right, P3dBlendMode.GetName(sIdx.intValue), EditorStyles.popup) == true) { var menu = new GenericMenu(); for (var i = 0; i < P3dBlendMode.COUNT; i++) { var index = i; var content = new GUIContent(P3dBlendMode.GetName(index)); var on = index == sIdx.intValue; menu.AddItem(content, on, () => { sIdx.intValue = index; sObj.ApplyModifiedProperties(); }); } menu.DropDown(right); } EditorGUI.indentLevel++; rect.y += rect.height + 2; sCha.vector4Value = EditorGUI.Vector4Field(rect, new GUIContent(sCha.displayName, sCha.tooltip), sCha.vector4Value); if (sIdx.intValue == P3dBlendMode.REPLACE_CUSTOM) { rect.y += rect.height + 2; EditorGUI.PropertyField(rect, sCol); rect.y += rect.height + 2; EditorGUI.PropertyField(rect, sTex); } if (sIdx.intValue == P3dBlendMode.BLUR || sIdx.intValue == P3dBlendMode.FLOW) { rect.y += rect.height + 2; EditorGUI.PropertyField(rect, sKer); } EditorGUI.indentLevel--; }
public void SetMaterial(P3dBlendMode blendMode, Texture decal, float hardness, float normalBack, float normalFront, float normalFade, Color color, float opacity, Texture shape) { Material = cachedMaterials[(int)blendMode]; Swap = cachedSwaps[(int)blendMode]; Color = color; Opacity = opacity; Hardness = hardness; Texture = decal; Shape = shape; var pointA = normalFront - 1.0f - normalFade; var pointB = normalFront - 1.0f; var pointC = 1.0f - normalBack; var pointD = 1.0f - normalBack + normalFade; NormalFront = new Vector2(pointA, P3dHelper.Reciprocal(pointB - pointA)); NormalBack = new Vector2(pointC, P3dHelper.Reciprocal(pointD - pointC)); }
public static RenderTexture Blit(ref RenderTexture renderTexture, P3dBlendMode blendMode, Texture texture, Color color, float opacity) { Command.Instance.SetMaterial(blendMode, texture, color, opacity); Command.Instance.Apply(); var swap = P3dHelper.GetRenderTexture(renderTexture.descriptor); Command.Instance.Material.SetTexture(P3dShader._Buffer, renderTexture); P3dHelper.Blit(swap, Command.Instance.Material); P3dHelper.ReleaseRenderTexture(renderTexture); renderTexture = swap; return(swap); }
public void SetMaterial(P3dBlendMode blendMode, float hardness, Color color, float opacity, Texture tileTexture, Matrix4x4 tileMatrix, float tileBlend) { switch (Extrusions) { case 0: Material = cachedSpotMaterials[blendMode]; break; case 1: Material = cachedLineMaterials[blendMode]; break; case 2: Material = cachedQuadMaterials[blendMode]; break; } Blend = blendMode; Hardness = hardness; Color = color; Opacity = opacity; TileTexture = tileTexture; TileMatrix = tileMatrix; TileBlend = tileBlend; }
public void SetMaterial(P3dBlendMode blendMode, float hardness, Color color, float opacity, Texture tileTexture, Matrix4x4 tileMatrix, float tileOpacity, float tileTransition) { switch (Extrusions) { case 0: Material = new P3dHashedMaterial(cachedSpotMaterial, cachedSpotMaterialHash); break; case 1: Material = new P3dHashedMaterial(cachedLineMaterial, cachedLineMaterialHash); break; case 2: Material = new P3dHashedMaterial(cachedQuadMaterial, cachedQuadMaterialHash); break; } Blend = blendMode; Pass = blendMode; Hardness = hardness; Color = color; Opacity = opacity; TileTexture = tileTexture; TileMatrix = tileMatrix; TileOpacity = tileOpacity; TileTransition = tileTransition; }
public void OnGUI() { Technique = (P3dWindowBrushTechnique)EditorGUILayout.EnumPopup("Technique", Technique); EditorGUI.indentLevel++; switch (Technique) { case P3dWindowBrushTechnique.Replace: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); Texture = EditorGUI.ObjectField(P3dHelper.Reserve(), "Texture", Texture, typeof(Texture), false) as Texture; Color = EditorGUILayout.ColorField("Color", Color); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); } break; case P3dWindowBrushTechnique.Fill: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); BlendMode = (P3dBlendMode)EditorGUILayout.EnumPopup("Blend Mode", BlendMode); Texture = EditorGUI.ObjectField(P3dHelper.Reserve(), "Texture", Texture, typeof(Texture), false) as Texture; Color = EditorGUILayout.ColorField("Color", Color); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); } break; case P3dWindowBrushTechnique.Sphere: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); BlendMode = (P3dBlendMode)EditorGUILayout.EnumPopup("Blend Mode", BlendMode); Color = EditorGUILayout.ColorField("Color", Color); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); Radius = EditorGUILayout.FloatField("Radius", Radius); Hardness = EditorGUILayout.FloatField("Hardness", Hardness); } break; case P3dWindowBrushTechnique.Decal: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); BlendMode = (P3dBlendMode)EditorGUILayout.EnumPopup("Blend Mode", BlendMode); P3dHelper.BeginColor(Texture == null); Texture = EditorGUI.ObjectField(P3dHelper.Reserve(), "Texture", Texture, typeof(Texture), false) as Texture; P3dHelper.EndColor(); if (BlendMode == P3dBlendMode.Replace) { P3dHelper.BeginColor(Shape == null); Shape = EditorGUI.ObjectField(P3dHelper.Reserve(), "Shape", Shape, typeof(Texture), false) as Texture; P3dHelper.EndColor(); } Color = EditorGUILayout.ColorField("Color", Color); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); Radius = EditorGUILayout.FloatField("Radius", Radius); Angle = EditorGUILayout.FloatField("Angle", Angle); Depth = EditorGUILayout.FloatField("Depth", Depth); Hardness = EditorGUILayout.FloatField("Hardness", Hardness); NormalFront = EditorGUILayout.Slider("Normal Front", NormalFront, 0.0f, 1.0f); NormalBack = EditorGUILayout.Slider("Normal Back", NormalBack, 0.0f, 1.0f); NormalRange = EditorGUILayout.Slider("Normal Range", NormalRange, 0.001f, 0.25f); } break; case P3dWindowBrushTechnique.SphereTriplanar: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); BlendMode = (P3dBlendMode)EditorGUILayout.EnumPopup("Blend Mode", BlendMode); P3dHelper.BeginColor(Texture == null); Texture = EditorGUI.ObjectField(P3dHelper.Reserve(), "Texture", Texture, typeof(Texture), false) as Texture; P3dHelper.EndColor(); Strength = EditorGUILayout.FloatField("Strength", Strength); Tiling = EditorGUILayout.FloatField("Tiling", Tiling); Color = EditorGUILayout.ColorField("Color", Color); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); Radius = EditorGUILayout.FloatField("Radius", Radius); Hardness = EditorGUILayout.FloatField("Hardness", Hardness); } break; case P3dWindowBrushTechnique.SphereBlur: { P3dGroup_Drawer.OnGUI(P3dHelper.Reserve(), this, new GUIContent("Group")); Opacity = EditorGUILayout.Slider("Opacity", Opacity, 0.0f, 1.0f); KernelSize = EditorGUILayout.Slider("Kernel Size", KernelSize, 0.0001f, 0.1f); Radius = EditorGUILayout.FloatField("Radius", Radius); Hardness = EditorGUILayout.FloatField("Hardness", Hardness); } break; } EditorGUI.indentLevel--; }
public static Material Build(Shader shader, int uv, P3dBlendMode blendMode) { var material = Build(shader); switch (blendMode) { case P3dBlendMode.AlphaBlend: { material.SetInt(_SrcRGB, (int)BlendMode.SrcAlpha); material.SetInt(_DstRGB, (int)BlendMode.OneMinusSrcAlpha); material.SetInt(_SrcA, (int)BlendMode.OneMinusDstAlpha); material.SetInt(_DstA, (int)BlendMode.One); material.SetInt(_Op, (int)BlendOp.Add); } break; case P3dBlendMode.AlphaBlendRGB: { material.SetInt(_SrcRGB, (int)BlendMode.SrcAlpha); material.SetInt(_DstRGB, (int)BlendMode.OneMinusSrcAlpha); material.SetInt(_SrcA, (int)BlendMode.Zero); material.SetInt(_DstA, (int)BlendMode.One); material.SetInt(_Op, (int)BlendOp.Add); } break; case P3dBlendMode.Additive: { material.SetInt(_SrcRGB, (int)BlendMode.One); material.SetInt(_DstRGB, (int)BlendMode.One); material.SetInt(_SrcA, (int)BlendMode.One); material.SetInt(_DstA, (int)BlendMode.One); material.SetInt(_Op, (int)BlendOp.Add); material.EnableKeyword("P3D_A"); // Additive } break; case P3dBlendMode.Subtractive: { material.SetInt(_SrcRGB, (int)BlendMode.One); material.SetInt(_DstRGB, (int)BlendMode.One); material.SetInt(_SrcA, (int)BlendMode.One); material.SetInt(_DstA, (int)BlendMode.One); material.SetInt(_Op, (int)BlendOp.ReverseSubtract); material.EnableKeyword("P3D_A"); // Additive } break; case P3dBlendMode.SoftAdditive: { material.SetInt(_SrcRGB, (int)BlendMode.OneMinusDstColor); material.SetInt(_DstRGB, (int)BlendMode.One); material.SetInt(_SrcA, (int)BlendMode.OneMinusDstAlpha); material.SetInt(_DstA, (int)BlendMode.One); material.SetInt(_Op, (int)BlendOp.Add); material.EnableKeyword("P3D_A"); // Additive } break; case P3dBlendMode.AlphaBlendAdvanced: { material.SetInt(_SrcRGB, (int)BlendMode.One); material.SetInt(_DstRGB, (int)BlendMode.Zero); material.SetInt(_SrcA, (int)BlendMode.One); material.SetInt(_DstA, (int)BlendMode.Zero); material.SetInt(_Op, (int)BlendOp.Add); material.EnableKeyword("P3D_B"); // Swapped alpha } break; case P3dBlendMode.Replace: { material.SetInt(_SrcRGB, (int)BlendMode.One); material.SetInt(_DstRGB, (int)BlendMode.Zero); material.SetInt(_SrcA, (int)BlendMode.One); material.SetInt(_DstA, (int)BlendMode.Zero); material.SetInt(_Op, (int)BlendOp.Add); material.EnableKeyword("P3D_C"); // Shape } break; case P3dBlendMode.Multiply: { material.SetInt(_SrcRGB, (int)BlendMode.DstColor); material.SetInt(_DstRGB, (int)BlendMode.Zero); material.SetInt(_SrcA, (int)BlendMode.One); material.SetInt(_DstA, (int)BlendMode.Zero); material.SetInt(_Op, (int)BlendOp.Add); material.EnableKeyword("P3D_D"); // Multiply } break; } return(material); }