public Material CreateMaterial( RenderContext rc, string vertexShaderName, string fragmentShaderName, MaterialVertexInput vertexInputs, MaterialInputs <MaterialGlobalInputElement> globalInputs, MaterialInputs <MaterialPerObjectInputElement> perObjectInputs, MaterialTextureInputs textureInputs) { return(CreateMaterial(rc, vertexShaderName, fragmentShaderName, new[] { vertexInputs }, globalInputs, perObjectInputs, textureInputs)); }
public Material CreateMaterial( RenderContext rc, string vertexShaderName, string fragmentShaderName, MaterialVertexInput[] vertexInputs, MaterialInputs <MaterialGlobalInputElement> globalInputs, MaterialInputs <MaterialPerObjectInputElement> perObjectInputs, MaterialTextureInputs textureInputs) { Shader vs = CreateShader(ShaderType.Vertex, vertexShaderName); Shader fs = CreateShader(ShaderType.Fragment, fragmentShaderName); VertexInputLayout inputLayout = CreateInputLayout(vs, vertexInputs); ShaderSet shaderSet = CreateShaderSet(inputLayout, vs, fs); ShaderConstantBindings constantBindings = CreateShaderConstantBindings(rc, shaderSet, globalInputs, perObjectInputs); ShaderTextureBindingSlots textureSlots = CreateShaderTextureBindingSlots(shaderSet, textureInputs); DefaultTextureBindingInfo[] defaultTextureInfos = CreateDefaultTextureBindingInfos(rc, textureInputs); return(new Material(rc, shaderSet, constantBindings, textureSlots, defaultTextureInfos)); }
public DefaultTextureBindingInfo[] CreateDefaultTextureBindingInfos(RenderContext rc, MaterialTextureInputs textureInputs) { List <DefaultTextureBindingInfo> textures = new List <DefaultTextureBindingInfo>(); for (int i = 0; i < textureInputs.Elements.Length; i++) { var element = textureInputs.Elements[i]; var texture = element.GetDeviceTexture(rc); if (texture != null) { textures.Add(new DefaultTextureBindingInfo(i, CreateShaderTextureBinding(texture))); } } return(textures.ToArray()); }
/// <summary> /// Creates a new <see cref="ShaderTextureBindingSlots"/> for the given shader set and a device-agnostic description. /// </summary> /// <param name="shaderSet">The <see cref="ShaderSet"/> which the slots will be valid for.</param> /// <param name="textureInputs">The texture slot descriptions.</param> /// <returns>A new <see cref="ShaderTextureBindingSlots"/>.</returns> public abstract ShaderTextureBindingSlots CreateShaderTextureBindingSlots(ShaderSet shaderSet, MaterialTextureInputs textureInputs);