Compute shader errors on Android

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm trying to blend a Texture2D in RWTexture2D In a Compute Shader. I need to do it channel by channel

Since I saw that RWTexture2D textures are not supported in Android I'm using my own struct RGBA32 which is composed of 4 floats. When I try to sum or interpolate the channels of both textures inside Unity Editor everything works fine. On Android, an error happens (Kernel at Index(0) is invalid).

   ARBG32 finalColor;
    float finalColor.r = colorA.r + colorB.r

If I change the code to finalColor.r = colorB.r it works fine on Android. Is it possible to work adding up or interpolating channels like that? Or do I need to do a bitwise operation or unpack them to combine two channels? I thought that I hadn’t to do it since that code in the Editor works perfectly.

Update-------

Additional info: What I'm trying to do is create a mask using a Render Texture in runtime, that mask after its creation it's going to be used to blend some textures on a terrain. Each channel (RGBA) of that mask is going to be painted with some shapes (brushes) and used to blend a different texture on a material. This will result in a terrain composed of ground, grass and snow areas.

I'm doing all that in a Compute Shader since I don't need this attached to a material, also I need to get information form some buffers.

My main goal right now is have this working, optimizations will come later. Brushes are grey scale. So everything is working in this project except the AddIntensity() Function. The code works great on Unity editor but not on Android. If I do:

        mainTexColor.r = brushColor.r;

It works on Android, but what I need is add more intensity each time that a brush paint in that pixel. In fact, every operation that I try to do in a color channel works fine on Editor but not on Android. I very new in graphics programming so, but I know that Unity editor works on Vulkan and Android on OpenGL.

e.g: I discovered that float4 doesn't work on Android.

I hope that this helps you better to understand my problem.

// Textures
RWTexture2D ResultMask;
Texture2D Brush;
//Color class
class ARBG32
{
    float r;
    float g;
    float b;
    float a;
};

//Function to add a brush value to a channel
       ARBG32 AddIntensity(ARBG32 mainTexColor, ARBG32 brushColor, int channel)
        {
            if(channel == 0)
                mainTexColor.r += brushColor.r;
            else if (channel == 1)
                mainTexColor.g += brushColor.r;
            else if (channel == 2)
                mainTexColor.b += brushColor.r;
            else 
                mainTexColor.a += brushColor.r;

            return mainTexColor;
        }

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.