Project specific bugs (tex2Dlod in vertex program, garbled mouse cursor)

I’m putting this in the shader category because the more important of the two problems fits it. Basically I’m encountering two strange behaviors:

  1. When I move my mouse over the game view, the cursor turns to a larger rectangle with garbled pixels (probably rendering some random data as a graphic).

  2. When I use tex2Dlod in the vertex function of a shader, the values I get aren’t the expected ones. If an RGBA value is exactly 1 or 0, it is the correct value. For anything in between I get a smaller value than it is supposed to.

I reproduced the issue in a simplified shader for demonstration purposes. But when I use this shader in a new project, it works as intended. Also, the garbled mouse cursor appears in three different Unity Editor versions, but only in this one project. Not in the new one I made to test the demo shader.

The code for the demo shader:

Shader "Debug/WrongSampleData"
{
    Properties
    {
        _MainTex("MainTex (RGBA)", 2D) = "black" {}
    }

    SubShader
    {
        CGPROGRAM

        #pragma surface surf Standard vertex:vert
        #include "UnityCG.cginc"

        sampler _MainTex;

        struct Input
        {
            float4 color;
        };

        void vert(inout appdata_full v, out Input o) {
            float4 data = tex2Dlod(_MainTex, float4(0, 0, 0, 0));
            if (data.x > 0.85)
                o.color = float4(1,0,0,1);
            else
                o.color = float4(0, 0, 1, 1);
        }

        void surf (Input IN, inout SurfaceOutputStandard o)
        {
            o.Albedo = IN.color.rgb;
        }

        ENDCG
    }
    FallBack "Diffuse"
}

I use a texture with one pixel that has the color rgba(0.9, 0,0.9,1). So it should render as red, because 0.9 is bigger than 0.85. But it gives me blue, which means the value coming back from tex2Dlod is equal or smaller than 0.85.

When I use another texture that has rgba(1, 0, 1, 1), it renders red as expected:


In my completely fresh and new project, when I copy over this shader and the textures, both render red as expected:

So my question is, what could cause these bugs in my project? What could change the mouse cursor? What could affect the tex2Dlod function (which I assume is a native function)?

The textures are attached to this post.

6070644--658143--Data.png
6070644--658146--Data0_9.png

Okay, I was able to reproduce both problems in my fresh project by copying over files from the “corrupted” project.

The unexpected shader behavior was due to a player setting. I had color space set to linear, setting it to gamma fixed the problem.

The garbled mouse cursor seems to be caused by some file in my project. Since it isn’t breaking anything in the build (I hope) I’m probably not going to spend time finding it (for now), but if anyone has a hunch what might be causing this please let me know.

I remembered that the reason I set it to linear is because Oculus says to do so:

Is there a way to make my data texture shader work with the linear setting? I guess I could do my own gamma correction on the values.

Removing the tick on sRGB (Color Texture) in the texture setting makes it linear. Values seem to be reliable now.