public void SetMaterialUniforms(Shader shader, RMaterial?previousMaterial, List <string> attributeNames) { // TODO: This code could be moved to the constructor. if (genericMaterial == null || shouldUpdateTexturesAndSamplers) { // Don't update this every frame since accessing the database is slow. // TODO: This may need to be updated more frequently if materials are eventually reassignable to new mesh objects. // TODO: The actual in game check is more complicated, and involves checking names, subindex, and usage. var hasRequiredAttributes = ShaderValidation.IsValidAttributeList(ShaderLabel, attributeNames); genericMaterial = CreateGenericMaterial(hasRequiredAttributes); shouldUpdateTexturesAndSamplers = false; } if (uniformBlock == null) { uniformBlock = new UniformBlock(shader, "MaterialParams") { BlockBinding = 1 }; SetMaterialParams(uniformBlock); } if (shouldUpdateUniformBlock) { SetMaterialParams(uniformBlock); shouldUpdateUniformBlock = false; } // Update the uniform values. genericMaterial.SetShaderUniforms(shader, previousMaterial?.genericMaterial); uniformBlock.BindBlock(shader); }
public void ValidLabelAndAttributeListDifferentOrder() { Assert.IsTrue(ShaderValidation.IsValidAttributeList("SFX_PBS_0100000008008269_opaque", new string[] { "Normal0", "Position0", "map1", "Tangent0", }) ); }
public void MissingAttribute() { Assert.IsFalse(ShaderValidation.IsValidAttributeList("SFX_PBS_1b01000008008a68_opaque", new string[] { "Position0", "Normal0", "Tangent0", "colorSet1", "colorSet2" }) ); }
public void InvalidShaderLabel() { Assert.IsFalse(ShaderValidation.IsValidAttributeList("SFX_PBS_1b01000008008a68", new string[] { "Position0", "Normal0", "Tangent0", "map1", "colorSet1", "colorSet2" }) ); }