public override string ToHlsl()
        {
            switch (funcName)
            {
            case "rgb":
                // transform values into rgb vector
                return($"float4(({value1.ToHlsl()}).x, " +
                       $"({value2.ToHlsl()}).x, " +
                       $"({value3.ToHlsl()}).x, 1.0)");

            case "lerp":
                return($"lerp({value1.ToHlsl()}, {value2.ToHlsl()}, ({value3.ToHlsl()}).x)");

            case "clamp":
                return($"clamp({value1.ToHlsl()}, {value2.ToHlsl()}, {value3.ToHlsl()})");
            }
            throw new Exception("invalid string as function name: " + funcName);
        }
Esempio n. 2
0
 public override string ToHlsl()
 {
     // aqcuire opengl function name
     if (!GetHlslFunction(funcName, out var start, out var end))
     {
         throw new Exception("invalid string as function name: " + funcName);
     }
     return(start + value.ToHlsl() + end);
 }
Esempio n. 3
0
        public override string ToHlsl()
        {
            if (!IsHlslFunction())
            {
                throw new Exception("invalid string as function name: " + funcName);
            }

            var val1 = value1.ToHlsl();
            var val2 = value2.ToHlsl();

            if (funcName == "pow")
            {
                val1 = $"max({val1}, 0.0)"; // do this to suppress warning and undefined behaviour
            }
            if (convertToRgb)
            {
                return("float4(f3(" + funcName + "((" + val1 + ").xyz,(" + val2 + ").xyz)), 1.0)");
            }

            return(funcName + "(" + val1 + "," + val2 + ")");
        }