public static uint GetTexEnvConfigHash(GFShader Shader) { FNV1a FNV = new FNV1a(); foreach (PICATexEnvStage Stage in Shader.TexEnvStages) { FNV.Hash(Stage.Color.ToUInt32()); FNV.Hash(Stage.Combiner.ToUInt32()); FNV.Hash(Stage.Operand.ToUInt32()); FNV.Hash(Stage.Scale.ToUInt32()); FNV.Hash(Stage.Source.ToUInt32()); FNV.Hash(Stage.UpdateAlphaBuffer ? 1 : 0); FNV.Hash(Stage.UpdateColorBuffer ? 1 : 0); } FNV.Hash(Shader.TexEnvBufferColor.ToUInt32()); return(FNV.HashCode); }
private static int GetMaterialShaderHash(H3DMaterialParams Params) { FNV1a HashGen = new FNV1a(); HashGen.Hash(Params.ShaderReference?.GetHashCode() ?? 0); HashGen.Hash(Params.TranslucencyKind.GetHashCode()); HashGen.Hash(Params.TexCoordConfig.GetHashCode()); HashGen.Hash(Params.FresnelSelector.GetHashCode()); HashGen.Hash(Params.BumpMode.GetHashCode()); HashGen.Hash(Params.BumpTexture.GetHashCode()); HashGen.Hash(Params.Constant0Assignment.GetHashCode()); HashGen.Hash(Params.Constant1Assignment.GetHashCode()); HashGen.Hash(Params.Constant2Assignment.GetHashCode()); HashGen.Hash(Params.Constant3Assignment.GetHashCode()); HashGen.Hash(Params.Constant4Assignment.GetHashCode()); HashGen.Hash(Params.Constant5Assignment.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.Dist0.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.Dist1.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.Fresnel.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.ReflecR.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.ReflecG.GetHashCode()); HashGen.Hash(Params.LUTInputAbsolute.ReflecB.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.Dist0.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.Dist1.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.Fresnel.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.ReflecR.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.ReflecG.GetHashCode()); HashGen.Hash(Params.LUTInputSelection.ReflecB.GetHashCode()); HashGen.Hash(Params.LUTInputScale.Dist0.GetHashCode()); HashGen.Hash(Params.LUTInputScale.Dist1.GetHashCode()); HashGen.Hash(Params.LUTInputScale.Fresnel.GetHashCode()); HashGen.Hash(Params.LUTInputScale.ReflecR.GetHashCode()); HashGen.Hash(Params.LUTInputScale.ReflecG.GetHashCode()); HashGen.Hash(Params.LUTInputScale.ReflecB.GetHashCode()); HashGen.Hash(Params.LUTDist0TableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTDist1TableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTFresnelTableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecRTableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecGTableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecBTableName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTDist0SamplerName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTDist1SamplerName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTFresnelSamplerName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecRSamplerName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecGSamplerName?.GetHashCode() ?? 0); HashGen.Hash(Params.LUTReflecBSamplerName?.GetHashCode() ?? 0); foreach (PICATexEnvStage Stage in Params.TexEnvStages) { HashGen.Hash(Stage.Source.Color[0].GetHashCode()); HashGen.Hash(Stage.Source.Color[1].GetHashCode()); HashGen.Hash(Stage.Source.Color[2].GetHashCode()); HashGen.Hash(Stage.Source.Alpha[0].GetHashCode()); HashGen.Hash(Stage.Source.Alpha[1].GetHashCode()); HashGen.Hash(Stage.Source.Alpha[2].GetHashCode()); HashGen.Hash(Stage.Operand.Color[0].GetHashCode()); HashGen.Hash(Stage.Operand.Color[1].GetHashCode()); HashGen.Hash(Stage.Operand.Color[2].GetHashCode()); HashGen.Hash(Stage.Operand.Alpha[0].GetHashCode()); HashGen.Hash(Stage.Operand.Alpha[1].GetHashCode()); HashGen.Hash(Stage.Operand.Alpha[2].GetHashCode()); HashGen.Hash(Stage.Combiner.Color.GetHashCode()); HashGen.Hash(Stage.Combiner.Alpha.GetHashCode()); HashGen.Hash(Stage.Scale.Color.GetHashCode()); HashGen.Hash(Stage.Scale.Alpha.GetHashCode()); HashGen.Hash(Stage.UpdateColorBuffer.GetHashCode()); HashGen.Hash(Stage.UpdateAlphaBuffer.GetHashCode()); } HashGen.Hash(Params.TexEnvBufferColor.R.GetHashCode()); HashGen.Hash(Params.TexEnvBufferColor.G.GetHashCode()); HashGen.Hash(Params.TexEnvBufferColor.B.GetHashCode()); HashGen.Hash(Params.TexEnvBufferColor.A.GetHashCode()); return((int)HashGen.HashCode); }