Transform Texture with PBR pipeline

Hi, here is a small shader I finally had working to transform texture (thanks to @tonfilm ).

shader TransformTexture_ShaderFX : ComputeFloat4, Texturing
{
    cbuffer PerMaterial
    {
        stage float4x4 tTex;
    }

    rgroup PerMaterial 
    {
        stage Texture2D Texture;
        stage SamplerState CustomSampler;
    }

    override float4 Compute()
    {
        float2 x = streams.TexCoord;

        float2 x0 = mul(float4((x.xy*2-1)*float2(1,-1) * 0.5, 0, 1), tTex).xy * float2(1, -1) + 0.5;

        return Texture.SampleLevel(CustomSampler, x0, 0);
    }
};

TransformTexturePBR.zip (9.0 KB)

2 Likes

That looks good, but I would change the SampleLevel to a normal Sample because materials usually work in 3d space and should make use of mipmaps to avoid flickering pixel effects. The SampleLevel with the level set to a constant 0 will always use the biggest mipmap of the texture.

1 Like

Alright fixed the Sample and added an other that works with instancing.

TransformTexturePBR.zip (14.5 KB)

I am not getting the trasnparency on any png from that example… not sure what I am doing wrong, it should look like what you posted on matrix ?

I don’t remember how I did this one but I think it was something like this :
TransformTexturePBR.zip (15.2 KB)
Just by randomizing the texture scale and translate.
You can also try with different kind of texture.

this is not specific to this example, to enable transparency on a material you need to connect a transparency feature to it, for this specific effect, Cutoff might be suited well: Transparency | vvvv gamma documentation

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.