public GameObject GetNextObjectTestAlpha(PointerEventData eventData) { List <RaycastResult> raycastResults = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, raycastResults); RaycastResult rr = raycastResults.Find((RaycastResult x) => { if (x.gameObject == gameObject) { return(false); } AlphaTest alphaTest = x.gameObject.GetComponent <AlphaTest>(); if (alphaTest == null) { return(true); } else { return(alphaTest.IsAlphaPoint(eventData)); } }); print(rr.gameObject.name); return(rr.gameObject); }
/// <summary> /// /// </summary> /// <param name="other"></param> /// <returns></returns> public virtual bool Equals(Material other) { if (other == null) { return(false); } return(AlphaTest.Equals(other.AlphaTest) && Blending.Equals(other.Blending) && ClipIntersections.Equals(other.ClipIntersections) && ClipShadows.Equals(other.ClipShadows) && ColorWrite.Equals(other.ColorWrite) && DepthTest.Equals(other.DepthTest) && DepthWrite.Equals(other.DepthWrite) && Dithering.Equals(other.Dithering) && FlatShading.Equals(other.FlatShading) && Fog.Equals(other.Fog) && Lights.Equals(other.Lights) && Opacity.Equals(other.Opacity) && Overdraw.Equals(other.Overdraw) && PremultipliedAlpha.Equals(other.PremultipliedAlpha) && Side.Equals(other.Side) && Transparent.Equals(other.Transparent) && VertexColors.Equals(other.VertexColors) && Visible.Equals(other.Visible) && UserData == other.UserData && ClippingPlanes == other.ClippingPlanes && string.Equals(Precision, other.Precision)); }
public static bool CallFragmentStage(ref Vertex vertex, int x, int y, out Color finallyColor) { ResetDiscard(); finallyColor = currentMaterial.CallFragmentStage(ref vertex); // color blend if (currentMaterial.blendEnbale) { finallyColor = BlendColor.Calculate(finallyColor, GetBufferColor(x, y), currentMaterial.blendOp, currentMaterial.srcFactor, currentMaterial.destFactor, currentMaterial.srcFactorA, currentMaterial.destFactorA); } // alpha test if (IsAlphaTestOn() && !AlphaTest.IsPass(currentMaterial.alphaTest, finallyColor.a, currentMaterial.alphaTestValue)) { Discard(); } if (IsDiscard()) { return(false); } SetBufferColor(x, y, finallyColor); // simple clamp color values to [0, 1] finallyColor = Color.Saturate(finallyColor); return(true); }
public void OnEndDrag(PointerEventData eventData) { if (eventData.pointerEnter != null) { AlphaTest alphaTest = eventData.pointerEnter.GetComponent <AlphaTest>(); if (alphaTest != null && !alphaTest.IsAlphaPoint(eventData)) { eventData.pointerEnter = alphaTest.GetNextObjectTestAlpha(eventData); } } SendMessage("OnDragFinish", eventData, SendMessageOptions.DontRequireReceiver); }
private static void WriteAlphaTest(StringBuilder stream, Material mat, MAT3 data) { string[] alphaRef = new[] { "alphaRef.r", "alphaRef.g" }; AlphaTest aTest = mat.AlphaTest; stream.AppendFormat("\t// Alpha Test: Compare A: {0} Reference A: {1} Op: {2} Compare B: {3} Reference B: {4}\n", aTest.Comp0, aTest.Reference0, aTest.Operation, aTest.Comp1, aTest.Reference1); stream.Append("\tif(!( "); stream.AppendFormat(m_tevAlphaFuncTable[(int)aTest.Comp0], (aTest.Reference0 / 255f)); // LHS stream.AppendFormat("{0}", m_tevAlphaFuncLogicTable[(int)aTest.Operation]); // Logic Operation stream.AppendFormat(m_tevAlphaFuncTable[(int)aTest.Comp1], (aTest.Reference1 / 255f)); stream.Append("))\n\t{\n"); stream.Append("\t\tdiscard;\n"); stream.Append("\t\treturn;\n"); stream.Append("\t}\n"); }
public void Read(BinaryReader reader, int length, bool Demo = false) { ShaderType = reader.ReadUInt32(); switch (ShaderType) { case 23: IntParam = reader.ReadUInt32(); FloatParam[0] = reader.ReadSingle(); FloatParam[1] = reader.ReadSingle(); break; case 26: IntParam = reader.ReadUInt32(); FloatParam[0] = reader.ReadSingle(); FloatParam[1] = reader.ReadSingle(); FloatParam[2] = reader.ReadSingle(); FloatParam[3] = reader.ReadSingle(); break; case 16: case 17: FloatParam[0] = reader.ReadSingle(); break; default: break; } ABlending = (AlphaBlending)reader.ReadByte(); AlphaRegSettingsIndex = reader.ReadByte(); ATest = (AlphaTest)reader.ReadByte(); ATestMethod = (AlphaTestMethod)reader.ReadByte(); AlphaValueToBeComparedTo = reader.ReadByte(); ProcessMethodWhenAlphaTestFailed = (ProcessAfterAlphaTestFailed)reader.ReadByte(); DAlphaTest = (DestinationAlphaTest)reader.ReadByte(); DAlphaTestMode = (DestinationAlphaTestMode)reader.ReadByte(); DepthTest = (DepthTestMethod)reader.ReadByte(); UnkVal1 = reader.ReadByte(); ShdMethod = (ShadingMethod)reader.ReadByte(); TxtMapping = (TextureMapping)reader.ReadByte(); MethodOfSpecifyingTextureCoordinates = (TextureCoordinatesSpecification)reader.ReadByte(); Fog = (Fogging)reader.ReadByte(); ContextNum = (Context)reader.ReadByte(); UnkVal2 = reader.ReadByte(); UnkVal3 = reader.ReadByte(); UsePresetAlphaRegSettings = reader.ReadBoolean(); SpecOfColA = (ColorSpecMethod)reader.ReadByte(); SpecOfColB = (ColorSpecMethod)reader.ReadByte(); SpecOfAlphaC = (AlphaSpecMethod)reader.ReadByte(); SpecOfColD = (ColorSpecMethod)reader.ReadByte(); FixedAlphaValue = reader.ReadByte(); TextureFilterWhenTextureIsExpanded = (TextureFilter)reader.ReadByte(); AlphaCorrectionValue = reader.ReadBoolean(); UnkFlag1 = reader.ReadBoolean(); UnkFlag2 = reader.ReadBoolean(); ZValueDrawingMask = (ZValueDrawMask)reader.ReadByte(); if (!Demo) { UnkFlag3 = reader.ReadBoolean(); BlobFlag = reader.ReadBoolean(); isDemo = false; } else { UnkFlag3 = false; BlobFlag = false; isDemo = true; } LodParamK = reader.ReadUInt16(); LodParamL = reader.ReadUInt16(); UnkVector1.Load(reader, 16); UnkVector2.Load(reader, 16); UnkVector3.Load(reader, 16); TextureId = reader.ReadUInt32(); reader.ReadUInt32(); // Shader type }