Bug in Shaders.cs

Oct 10, 2009 at 9:15 AM

Hi folks,

I tried hard to let it work, but it always crashed. Finally found a bug in Shaders.cs where the ShaderCode is built.

The lerp function wants just 3 parameters, but gets 4.Should be the "Comma" I guess. After giving just 3 parameters

I saw the nice work!

 

 

 

Coordinator
Oct 10, 2009 at 11:50 PM

I'm confused on your bug report, can you be more specific? Lerp is defined as a three parameter function (T,T,double) => T, and works just fine for WPF and DirectX on my machine. Could this be a text encoding/internationalization issue? Is your system set to another language other than english?

Oct 11, 2009 at 12:57 PM

This is the shadercode on my Vista 64 original german now english system:

sampler2D input : register(s0);\r\nsampler2D i1
        : register(s1);\r\nsampler2D i2
        : register(s2);\r\nfloat r0
        : register(c0);\r\nfloat r1
        : register(c1);\r\nfloat4
        main(float2 uv : TEXCOORD)
        : COLOR {\r\n  
            float4 retV;\r\n  {\r\n
            float t1_0 = (uv.x + r0);\r\n
            float t1_1 = (uv.y + r1);\r\n
            float2 t1_2 = float2(t1_0, t1_1);\r\n    
            float2 t1_3 = (t1_2 % float2(1, 1));\r\n
            float4 t1_4 = tex2D(i1, t1_3);\r\n    
            float4 t1_5 = tex2D(i2, t1_3);\r\n
            float4 t1_6 = lerp(t1_4, t1_5, 0,5);\r\n
            float3 t1_7 = t1_6.xyz;\r\n
            float4 t1_8 = tex2D(input, uv);\r\n
            float4 t1_9 = float4(t1_7, t1_8.w);\r\n
            retV = t1_9;\r\n  
            }\r\n  
            return retV;\r\n
            }\r\n"

Set settings formats under "Regional and language" to English(United States) solved the problem.

Thanks

 

Coordinator
Oct 11, 2009 at 11:30 PM

Doesn't Germany use commas as decimal points? If so, there is a problem in the way I'm printing out scalar constants. Is there a way in .NET to get the system to use . instead of , when printing out a number?

Coordinator
Oct 11, 2009 at 11:42 PM

Ok, I think I've fixed it, but I'll have to find a European setup to test, here is the change I made in Core/Shaders.cs:

          if (arity.TypeOfK == typeof(bool)) return ((bool)e) ? "1" : "0";
          else if (arity.TypeOfK == typeof(double)) return ((double)e).ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
          else return e.ToString();

Hopefully that should work, sorry for the mistake!

Oct 12, 2009 at 1:05 PM

Hi, I just tested your code change. I set back the format to "German" and it worked well.

Thanks.