Announcement

Collapse
No announcement yet.

Problem when I pass UTexture2D to pixel shader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem when I pass UTexture2D to pixel shader

    Hello, I recently followed Temaran's tutorial (https://github.com/Temaran/UE4ShaderPluginDemo) for Shader in UE4. Actually I try to pass a UTexture2D (I don't create this texture during Runtime) to Shader then I convert in FRHITexture via UTexture2D->Resource->TextureRHI.

    Here is my Pixel shader :

    Code:
    Texture2D texturesample;
    SamplerState mySampler;
    float4 myColor;
    
    float4 mainPS(in float2 UV: TEXCOORD0) : SV_TARGET0
    {
    
        float4 packedValue = texturesample.Sample(mySampler, UV);
        if(packedValue.x > 0.0)
            return float4(1,0,0,0);
        return myColor;
    }
    Shader's parameters are similar with tamaran I just added FRHISamplerState.

    My Project crash if I click on Play. This error seems to be caused by if(packedValue.x > 0.0) .
    Is it caused by conversion between UTexture2D to FRHITexture ?

    #2
    * bump * * bump *

    Comment

    Working...
    X