You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added shaders to my game recently and to ease in the new feature I decided to use your passthrough shader from the tutorial here. After adding it, I noticed anything being drawn by an IMDraw was black instead of the color it was supposed to be. Sprites and the Canvas clear color all show up as normal, but my IMDraw borders around buttons and simplistic progress bar appear as black.
Two causes come to mind.
There is no "texture" for IMDraw things for the shader to reference.
I'm drawing everything to a canvas, and then drawing the canvas to the window.
Number 1 makes a lot of sense if you look at the source, but I don't think I know enough about shaders yet to know what to do instead. Number 2 is something I read can enable a lot of advanced things but I'm still wrapping my head around the details so I admit this might be a side effect of that.
I don't think this is a bug in pixel, just in my understanding. How should I write my shaders to work with IMDraw?
Mac Big Sur x64
Pixel v0.10
Go 1.17.7
The text was updated successfully, but these errors were encountered:
I found the default fragment shader in the source code. Unsurprisingly it works with IMDraw. I'm trying to understand what the default does.
The opening if seems to make sure that gl_FragCoord is inside the vClipRect. vClipRect seems to be 1 point with 4 values (W, X, Y, and Z) except that X and Y seem to be the min coordinate of a rect and Z and W are the max coordinates. If the frag coordinate is outside of this rect, it's discarded (not calculated? black?). If the frag is in the clip rect, it continues. I'm not sure where its value comes from. The Frame of a sprite?
Intensity seems to act like a slider between Color and Texture. An intensity of 0 uses the color. Else, as the intensity gets closer to 1, the fragment gets more and more influenced by the color of the texture rather than the vColor. Regardless of the intensity, the colormask is applied too.
Turns out drawing to a canvas and then drawing to the window played no part in this.
I guess I figured out most of my misunderstandings. The only thing left unanswered is where vClipRect comes from exactly.
I added shaders to my game recently and to ease in the new feature I decided to use your passthrough shader from the tutorial here. After adding it, I noticed anything being drawn by an IMDraw was black instead of the color it was supposed to be. Sprites and the Canvas clear color all show up as normal, but my IMDraw borders around buttons and simplistic progress bar appear as black.
Two causes come to mind.
Number 1 makes a lot of sense if you look at the source, but I don't think I know enough about shaders yet to know what to do instead. Number 2 is something I read can enable a lot of advanced things but I'm still wrapping my head around the details so I admit this might be a side effect of that.
I don't think this is a bug in pixel, just in my understanding. How should I write my shaders to work with IMDraw?
Mac Big Sur x64
Pixel v0.10
Go 1.17.7
The text was updated successfully, but these errors were encountered: