[Solved] Shader question: Getting current pixel x/y color from passed reference image
Posted: Sat Apr 23, 2022 4:26 pm
I know the title is really wonky. I don't know the lingo enough to know how to word it better.
I have a really stupid problem I've been trying to figure out for hours now relating to shaders.
So I have a DepthMap canvas and my main canvas. I use a shader to draw to the DepthMap canvas stuff in certain colors. Like one color for certain things and another for everything else or whatever. That part isn't important. I then draw the same stuff normally to the main canvas using my normal shader. I am passing the DepthMap to the main shader and I am trying to grab the color of the pixel in that DepthMap from within the main shader but I am having trouble grabbing the proper pixel coordinate. For some reason I am only grabbing the bottom right corner pixel of the DepthMap. I've tried everything I can to figure out how to pass the proper coordinates to the Texel function but it just isn't working. It's always just the bottom right pixel. Which in screen space coordinates is vec2(1.0,1.0) I assume. I've tried everything. I've Googled. I've looked at other projects using the g3d library. Nothing seems to work. pixcoord is always 1.0, 1.0 (Where 1.0 basically means furthest right/down on the canvas. 0.0 would mean furthest left and up and 0.5 would be the middle) no matter what even though I'd think it should be whatever the current pixel coordinate is for the shader at that moment. Right? Is there some other variable it's supposed to be? I'm literally about to rip my hair out. lol
Hours I've been trying. I think someone else was having this issue a few pages back too. (Notice in their screenshot that they have a smaller version of the scene rendered in black and white, that's what I'm doing as well. I want to be able to compare the pixel from the DepthMap with the same pixel in the main canvas.) No one ever answered it and I don't know if they ever solved it. I'm so desperate! I feel like I'm missing the most obvious thing here.
Note that "DepthMap" has no meaning. It's just what I'm calling it right now. It could be called anything really. It's just a 3D canvas that I'm drawing the world to using a special shader.
I have a really stupid problem I've been trying to figure out for hours now relating to shaders.
So I have a DepthMap canvas and my main canvas. I use a shader to draw to the DepthMap canvas stuff in certain colors. Like one color for certain things and another for everything else or whatever. That part isn't important. I then draw the same stuff normally to the main canvas using my normal shader. I am passing the DepthMap to the main shader and I am trying to grab the color of the pixel in that DepthMap from within the main shader but I am having trouble grabbing the proper pixel coordinate. For some reason I am only grabbing the bottom right corner pixel of the DepthMap. I've tried everything I can to figure out how to pass the proper coordinates to the Texel function but it just isn't working. It's always just the bottom right pixel. Which in screen space coordinates is vec2(1.0,1.0) I assume. I've tried everything. I've Googled. I've looked at other projects using the g3d library. Nothing seems to work. pixcoord is always 1.0, 1.0 (Where 1.0 basically means furthest right/down on the canvas. 0.0 would mean furthest left and up and 0.5 would be the middle) no matter what even though I'd think it should be whatever the current pixel coordinate is for the shader at that moment. Right? Is there some other variable it's supposed to be? I'm literally about to rip my hair out. lol
Hours I've been trying. I think someone else was having this issue a few pages back too. (Notice in their screenshot that they have a smaller version of the scene rendered in black and white, that's what I'm doing as well. I want to be able to compare the pixel from the DepthMap with the same pixel in the main canvas.) No one ever answered it and I don't know if they ever solved it. I'm so desperate! I feel like I'm missing the most obvious thing here.
Note that "DepthMap" has no meaning. It's just what I'm calling it right now. It could be called anything really. It's just a 3D canvas that I'm drawing the world to using a special shader.