I’m trying to use this shader in P3D. I’ve made some minor modifications to use the proper panda3D inputs, but I end up just getting a single color the the whole frame. When I move the camera, the color changes. It almost feels like my shader is not properly taking the pixel position and instead outputing the same for all pixels.
I’m a total shader noob, so any help would be appreciated.
thanks for the advice @rdb. You’r correct. Note that on the shader I posted initially (the one I’m struggling with), I’m not incorrectly naming my variable as p3d_Texture0. In this case, I don’t think I even need the quad.setShaderInput("tex", tex) line?
Either way, the behaviour of the first shader seems the same, single color in the full frame
Interestingly, I was able to get close to the desired results by plaing with this line, specifically, replacing the gl_Position.z with different numbers (looks like 1.5 or 2 do the trick…).
You’re right, panda applies the texture by default to p3d_Texture0, so you don’t need the setShaderInput line then.
gl_Position.z is the depth, I believe. I am not sure what “dev space” is supposed to refer to. Note that the difference in your first and second shader is that in the second, you are actually using the coordinates from gl_MultiTexCoord0, whereas in the first shader, the Vertex_UV variable is written but never read.
I would first try to get a simple quad working that just displays the texture, without distortion. If that doesn’t work, I would try to set your shader to write out the texture coordinates that are being used to sample the texture to the red and blue channels of the output, then you can find out whether those might be the problem. It may indeed be that due to a difference in coordinate system (eg. expecting Y-up instead of Z-up), it is sampling the texture incorrectly.