Jump to content

Search the Community

Showing results for tags 'shader fragment'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 2 results

  1. Tried the official "hello shader" example with pixi6 but it no longer seems to animate: https://pixijs.io/examples/#/filters-advanced/custom.js I inject PixiJs into a React app. (I don't think this is the issue, since it works fine for everything else I've been doing the past few months.) In this code snippet, useEffect just ensures that the code runs outside the render loop. And the useLayoutEffect block ensures the "uniforms" object and animate callback don't trigger re-renders. The shader will load fine. The app.ticker will run the animation function. But the shader does not animate. ?‍♂️ export function usePixiShader(props: { comp?: Container; uniforms?: Record<string, unknown>; animate?: (filter: Filter, delta: number) => void; }) { const { comp: parent, uniforms, animate } = props; // just gives you the instance of the app const app = useContext(PixiAppContext); const comp = parent ?? app?.stage; const uniformsRef = useRef(uniforms); const animateRef = useRef(animate); useLayoutEffect(() => { uniformsRef.current = uniforms; animateRef.current = animate; }); useEffect(() => { if (!resources || !comp || !app) return; const _shader = ` precision mediump float; varying vec2 vTextureCoord; varying vec4 vColor; uniform sampler2D uSampler; uniform float customUniform; void main(void) { vec2 uvs = vTextureCoord.xy; vec4 fg = texture2D(uSampler, vTextureCoord); fg.r = uvs.y + sin(customUniform); //fg.r = clamp(fg.r,0.0,0.9); gl_FragColor = fg; } `; const filter = new Filter(undefined, _shader, { ...uniformsRef.current, }); comp.filters = [filter]; let animate: undefined | ((delta: number) => void); if (animateRef.current) { animate = (delta: number) => { animateRef.current?.(filter, delta); }; app.ticker.add(animate); } return () => { if (animate) app.ticker.remove(animate); }; }, [app, comp, resources]); return null } // usage usePixiShader({ comp: sprite?.sprite, uniforms: { customUniform: 0, }, animate: (filter, delta) => { filter.uniforms.customUniform += 0.04 * delta; }, });
  2. Flow this topic if you don't Use Shader a lot. i try made that because most of member prefer to don't Use shader we talk about this stuffs step by step : What is Shader How It work in GPU : understanding How can i use it How can start programming in shader what information we access in shader [ more question added in next ] we try talk about one stuff per days
×
×
  • Create New...