Пример #1
0
        public void Compile(ShaderGraphMaterial material)
        {
            var t = GatherShaderGraphInstructions();

            material.Compile();
            // TODO: saving, caching? etc
        }
Пример #2
0
 public void Compile(ShaderGraphMaterial shader)
 {
     if ((int)m_ChannelMask < (int)m_OutParam.Type || (int)m_ChannelMask >= (int)m_OutParam.Type + 1)
     {
         throw new TypeMismatch(shader.CurrentInstructionIndex,
                                m_OutParam.Type.ToString(), ((VariableType)((int)m_ChannelMask)).ToString());
     }
     shader.AddTextureSlot(m_TextureType, m_TextureSlot);
     shader.AddSamplerSlot(m_SamplerSlot);
     shader.AddSetValue(m_OutParam, $"{m_TextureSlot}.Sample({m_SamplerSlot}, {m_UVSlot}).{m_ChannelMask.ToString().ToLower()}");
 }
Пример #3
0
        public void TestItAll()
        {
            var TextureSample = new ShaderGraphMaterial.VariableDefinition()
            {
                Name = "TextureSample",
                Type = ShaderGraphMaterial.VariableType.FLOAT4,
            };

            var instructions = new List <ShaderGraphMaterial.IBaseShaderInstruction>()
            {
                new ShaderGraphMaterial.AddVariableInstruction(TextureSample),

                /*new ShaderGraphMaterial.SampleTextureInstruction("LinearSampler",
                 *  ShaderGraphMaterial.TextureType.Texture2D,
                 *  "Texture0", "input.uv0",
                 *  ShaderGraphMaterial.Channel.RGBA,
                 *  TextureSample),
                 * new ShaderGraphMaterial.SetVariableValueMask(ShaderGraphMaterial.VariableDefinition.EmissiveColor,
                 *  TextureSample, ShaderGraphMaterial.Channel.RGB),*/
                new ShaderGraphMaterial.SetVariableValue(ShaderGraphMaterial.VariableDefinition.EmissiveColor,
                                                         "float3(0.0f, 0.533f, 1.0f)"),
                new ShaderGraphMaterial.SetVariableValueMask(ShaderGraphMaterial.VariableDefinition.Opacity,
                                                             TextureSample, ShaderGraphMaterial.Channel.A),
            };

            MetaMaterial mm = new MetaMaterial()
            {
                materialDomain = MetaMaterial.MaterialDomain.Surface,
                blendMode      = MetaMaterial.BlendMode.Translucent,
                shadingMode    = MetaMaterial.ShadingMode.Unlit,
                cullMode       = MetaMaterial.CullMode.None,
                Wireframe      = true,
            };

            ShaderGraphMaterial material = new ShaderGraphMaterial("TestShader", mm, instructions);

            material.AddInstruction(new ShaderGraphMaterial.SetVariableValue(
                                        ShaderGraphMaterial.VariableDefinition.Opacity, "0.7f"));

            ShaderGraphCompiler compiler = new ShaderGraphCompiler();

            compiler.Compile(material);
        }
Пример #4
0
 public void Compile(ShaderGraphMaterial shader)
 {
     shader.AddSetValue(m_Variable, m_Value.Name.ToString() + "." + m_Mask.ToString().ToLower());
 }
Пример #5
0
 public void Compile(ShaderGraphMaterial shader)
 {
     shader.AddSetValue(m_Variable, m_Value.ToString());
 }
Пример #6
0
 public void Compile(ShaderGraphMaterial shader)
 {
     shader.AddVariable(m_Definition);
 }