public static ShaderChannel ToShaderChannel(this ShaderChannel4 _this) { switch (_this) { case ShaderChannel4.Vertex: return(ShaderChannel.Vertex); case ShaderChannel4.Normal: return(ShaderChannel.Normal); case ShaderChannel4.Color: return(ShaderChannel.Color); case ShaderChannel4.UV0: return(ShaderChannel.UV0); case ShaderChannel4.UV1: return(ShaderChannel.UV1); case ShaderChannel4.Tangent: return(ShaderChannel.Tangent); default: throw new Exception($"Unsupported channel type {_this}"); } }
public static ChannelInfo GenerateChannelInfo(Version instanceVersion, StreamInfo[] origin, ShaderChannel channelType) { ChannelInfo instance = new ChannelInfo(); ShaderChannel4 channelv4 = channelType.ToShaderChannel4(); int streamIndex = origin.IndexOf(t => t.IsMatch(channelv4)); if (streamIndex >= 0) { byte offset = 0; ref StreamInfo stream = ref origin[streamIndex]; for (ShaderChannel4 i = 0; i < channelv4; i++) { if (stream.IsMatch(i)) { offset += i.ToShaderChannel().GetStride(instanceVersion); } } instance.Stream = (byte)streamIndex; instance.Offset = offset; instance.Format = channelType.GetVertexFormat(instanceVersion).ToFormat(instanceVersion); instance.RawDimension = channelType.GetDimention(instanceVersion); }
public bool IsMatch(ShaderChannel4 channel) { return((ChannelMask & (1 << (int)channel)) != 0); }