private float GetAlpha(Vector3Int coord) { float[] channels = ReadAllChannels(coord); int i = 0; foreach (var layout in m_Settings.TextureLayout) { int channelSize = CommonVoxelImportSettings.GetChannelCount(layout); if (layout == CommonVoxelImportSettings.TextureLayoutFormat.Alpha) { return(channels[i]); } i += channelSize; } return(0); }
public VoxelVertexOutput ResolveVoxelVertex(VoxelVertexInput input, VoxelModelGenerationSettings settings) { float[] channels = ReadAllChannels(input.Coord); VoxelMaterialBasic material = new VoxelMaterialBasic(); List <Vector4> customUVs = new List <Vector4>(); int c = 0; foreach (var layout in m_Settings.TextureLayout) { switch (layout) { case CommonVoxelImportSettings.TextureLayoutFormat.Tint: material.Tint = new Vector4( channels[c + 0], channels[c + 1], channels[c + 2], channels[c + 3] ); break; case CommonVoxelImportSettings.TextureLayoutFormat.Albedo: material.Colour.r = channels[c + 0]; material.Colour.g = channels[c + 1]; material.Colour.b = channels[c + 2]; break; case CommonVoxelImportSettings.TextureLayoutFormat.Alpha: material.Colour.a = channels[c]; break; case CommonVoxelImportSettings.TextureLayoutFormat.CustomUV2: customUVs.Add(new Vector4(channels[c + 0], channels[c + 1], 0, 0)); break; case CommonVoxelImportSettings.TextureLayoutFormat.CustomUV4: customUVs.Add(new Vector4(channels[c + 0], channels[c + 1], channels[c + 2], channels[c + 3])); break; case CommonVoxelImportSettings.TextureLayoutFormat.Specular: material.Specular = channels[c]; break; case CommonVoxelImportSettings.TextureLayoutFormat.Roughness: material.Roughness = channels[c]; break; } int channelSize = CommonVoxelImportSettings.GetChannelCount(layout); c += channelSize; } material.CustomUVs = customUVs.ToArray(); VoxelVertexOutput output = new VoxelVertexOutput(); output.SetDefaults(input, settings); material.ApplyToVertex(input, ref output); return(output); }