You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function float bar() is declared to return a single float value. The expression after return is the result of a call to tex2D, which is a float3, but since the function's signature is of type float, the first channel should be implicitly selected and used as the output, i.e. line 2 should effectively have a .x inserted before the semicolon by the compiler.
However, when we try to construct a float2 using baz and another float (line 6), the compiler/translator sees that baz "returned a float3" (line 2) and decides that a float3 and another float is "too much data". It is, in essence ignoring the fact that foo returns a float AND the fact that the dummy variable baz is declared to be of type float (line 5), and instead is looking solely at the code body (line 2) to determine a datatype.
There is no way, however that "baz" will end up being any more than a float at runtime. So there is no way (line 6) can be providing too much information to the float2 constructor at runtime. Yet, the compiler dies with the message "too much data in type constructor" at line 6.
The text was updated successfully, but these errors were encountered:
Since you're talking about surface shaders, that sounds like it's something Unity specific. You're sure the error is caused by hlsl2glsl, and not by any of the other ten-or-so shader compilers that Unity uses? (might be Cg, HLSL, HLSL360, CgPS3 etc.)
Consider the following code from a surface shader:
The function
float bar()
is declared to return a single float value. The expression after return is the result of a call to tex2D, which is a float3, but since the function's signature is of type float, the first channel should be implicitly selected and used as the output, i.e. line 2 should effectively have a.x
inserted before the semicolon by the compiler.However, when we try to construct a float2 using baz and another float (line 6), the compiler/translator sees that baz "returned a float3" (line 2) and decides that a float3 and another float is "too much data". It is, in essence ignoring the fact that foo returns a float AND the fact that the dummy variable
baz
is declared to be of type float (line 5), and instead is looking solely at the code body (line 2) to determine a datatype.There is no way, however that "baz" will end up being any more than a float at runtime. So there is no way (line 6) can be providing too much information to the float2 constructor at runtime. Yet, the compiler dies with the message "too much data in type constructor" at line 6.
The text was updated successfully, but these errors were encountered: