SenPie Posted June 25, 2021 Share Posted June 25, 2021 2021-06-25 14-18-28.mkv Hi, I've made a fragment shader that bends and stretches a given texture to give it a fluid flow. Here is the code: #ifdef GL_ES #define LOWP lowp precision mediump float; #else #define LOWP #endif uniform sampler2D u_texture; varying LOWP vec4 v_color; varying vec2 vTextureCoord; uniform float u_time; uniform sampler2D uSampler; vec4 normalizedSin(float speed, vec4 var, vec4 outputValue) { return ((sin(var * 3.14159 * speed) + 1.0) / 2.0); } float sphereMaskNode(float hardness, float radius, vec2 center, vec2 uv, float outputValue) { return 1.0 - clamp((distance(uv, center) - radius) / (1.0 - hardness), 0.0, 1.0); } vec4 normalizedCos(float speed, vec4 var, vec4 outputValue) { return ((cos(var * 3.14159 * speed) + 1.0) / 2.0); } void main() { vec4 normalizedSinVar1 = normalizedSin(0.22434203, vec4(u_time, u_time, u_time, 1.0), vec4(0.0)); vec2 vec2Val0 = vec2(u_time, normalizedSinVar1.x); vec2 mathVar0 = sin(vec2Val0) * (vec2(0.4)); vec2 vec2Val1 = vec2(0.5, 0.3); vec2 mathVar2 = (mathVar0) + (vec2Val1); float sphereMaskNodeVar0 = sphereMaskNode(0.5948184, 0.0, mathVar2, vTextureCoord, float(0.0)); float mathVar1 = (sphereMaskNodeVar0) * (0.05); vec4 mathVar3 = pow(texture2D(uSampler, (vTextureCoord - 0.5)/(vec2(1.0, 1.0)) + 0.5 + vec2(mathVar1)), vec4(17.388779, 17.388779, 17.388779, 1.0)); vec4 mathVar4 = (mathVar3) * (vec4(6.050579, 6.050579, 6.050579, 1.0)); vec4 normalizedCosVar2 = normalizedCos(0.5, vec4(u_time, u_time, u_time, 1.0), vec4(0.0)); vec4 mathVar6 = (mathVar4) * (normalizedCosVar2); vec4 mathVar5 = (mathVar6) + (texture2D(uSampler, (vTextureCoord - 0.5)/(vec2(1.0, 1.0)) + 0.5 + vec2(mathVar1))); gl_FragColor = mathVar5; } I applied that shader on a lava sprite with a PIXI.Filter, however it gets cut off on the sides. I intentional made the width and height of lava bigger than the screen width and height, so when it gets stretched it will still look fine. It seems like anything that is outside of the visible zone is not rendered at all, so when sprite is stretched I see nothing in place. Any ideas how can I fix this issue? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 25, 2021 Share Posted June 25, 2021 "filter.autoFit = false" should help SenPie 1 Quote Link to comment Share on other sites More sharing options...
SenPie Posted June 25, 2021 Author Share Posted June 25, 2021 2 hours ago, ivan.popelyshev said: "filter.autoFit = false" should help Yes, it worked! and you saved me a lot of debugging time. Thank you! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.