exeldro / obs-shaderfilter

OBS Studio filter for applying an arbitrary shader to a source.
GNU General Public License v2.0
377 stars 39 forks source link

Texture Sampling behaviour issues #27

Open Omnituens opened 9 months ago

Omnituens commented 9 months ago

I was attempting to do some texture sampling from an png in a function, but I found some odd behaviour.

Make a colour source of colour ff00ff in an OBS scene and a 10x10 png of a different solid colour (I used ff8811). You can also create another colour source to sample from, it is not exclusive to loading from a graphics file.

Apply the following shader to the colour source, setting testTexture to the png.

uniform texture2d testTexture;

float4 getColour(float2 uv)
{
    return testTexture.Sample(textureSampler, uv);
}

float4 mainImage(VertData v_in) : TARGET
{
    float2 testuv = {0.5f, 0.5f};
    return getColour(testuv);
    float4 sourceColour = image.Sample(textureSampler, testuv);
}

You will observe that the colour being returned is the colour source, when it should be the colour from the texture. Commenting out the float4 definition after the return OR replacing the GetColour call with sampling the testTexture directly has the desired behaviour and returns the sampled texture rather than the source.

OBS is 30.0 and plugin version is 2.1.3