Search the Community
Showing results for tags 'Fragment to world coordinates'.
-
I'm trying to use a fragment shader to represent moving lava, I've found a shadertoy lava but if I try to use that in leadwerks i can get a moving image but it doesn't move with the first person camera. I know that the screen coordinates that I am using need to be changed to a world based system, but I have been unable to get lava plane to have a 3D appearance, ie further away patterns look smaller and near patterns look bigger, and if I move the camera the view doesn't move. The function I am using, at its most basic starts with vec2 p = gl_FragCoord.xy; I think I have to manipulate this into a world position, but I don't have the knowledge on how this can be converted. I think I have to use various transformations that invert those made by leadwerks. Is what I am trying to do possible. Ive tried to use the shader on a material, applied to the plane, but if I do it that way I don't get the lava swirling on the screen, but it still fails to follow the camera. Ie the image of the lava remains fixed to the viewport. At the moment, I have a Lava.mdl, just like a water plane, a lava.lua script which loads a lava.shader. The script sets iGlobalTime as a float, which just counts in 0.005 increments. The other variable is a vec2 iResolution set to context:GetWidth()*2 and context:GetHeight()*2 Though if I try to divide gl_FragCood.xy by iResolution the lava fails to display except as a solid colour. Does anyone have a Fragment shader code snippet that converts coordinates back to world coordinates for Leadwerks? Thanks in anticipation.