#embedding information into a texture for use with shader

1 messages · Page 1 of 1 (latest)

dawn sparrow
#

hi, so i have this shader that takes in a RGBA8 texture that contains ascii values, with the first 2 entries defining the width and height, however i seem to be having issues with getting the data out of the texture, i looked at AudioLink that achieves it like this

        uniform Texture2D<float4>   _AudioTexture;
        #define AudioLinkData(xycoord) _AudioTexture[uint2(xycoord)]

i modified it to use uint4 since i'm only getting integers from the texture
it looks like this at the end
(shader is in following message discord is pain)

(ignore the mentions of UDON, im using a shader function that came from a vrchat project )
but the issue is that i can't get any of it rendering, i think its due to actually getting the value but im not sure. im new to shaders so any help is appriciated!

GitHub

Contribute to cnlohr/cnsky development by creating an account on GitHub.

dire pilot
#

What is the issue you are having when trying to get the data ?
Wrong data ? Unexpected ? Wrong format ?

Looking at the code, it seems that the texutre is one dimentional (as you'r always using 0 for the Y coord), is that right ?

When the -2 offset when grabing the val ? If you want to skip the two first pixels that contain the dimentions, it should probably be +2 ?

Could you describe the global intent of the shader ? To my understanding it displays a SDF character from the texture table _TextTex , based on the UVs of the mesh, but how it that mesh constructed ?
Are the UVs outside of the regular [0;1] range ? Because your using floor(uv) as source for the texture fetch, which would result to 0 is most of the cases then.

dawn sparrow
# dire pilot What is the issue you are having when trying to get the data ? Wrong data ? Unex...

I think its either wrong data or just its not rendering correctly,

Yeah its supposed to be +2 lol

So the shader takes in a 1 dimentional array and the actual character is constructed with the shader function from the project linked above, most of the uv code from the shader came from this shader

GitHub

Contribute to cnlohr/cnsky development by creating an account on GitHub.

#

I have also just noticed in comparing that TextH and TextW are the wrong way round notlikethis

dawn sparrow
#

right i fixed those two and this is what it looks like right now, (the right is a test shader included with the MSDFShader project)

dire pilot
#

Is the texture maybe badly imported ?
Be sure that it is in "non PoT" mode and uncompressed.

#

And the proper format obviously

dawn sparrow
dire pilot
dawn sparrow
dawn sparrow
#

ok i was able to work around the uNorm issue

#
            float redval = arr[i] / 255.0f;
           tex.SetPixel(i, 0, new Color(redval, 0f, 0f, 255f));```
#
            uniform Texture2D<float4> _TextTex;
            #define texGrab(xycoord) (_TextTex[xycoord].r*255)```