question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shader screenshot

See original GitHub issue

Hello,

I render an image with a fragment shader:

    var app = new PIXI.Application({ width: window.innerWidth, height: window.innerHeight, antialiasing: false });
    app.resizeTo = window;

    let fragmentShader = document.getElementById('fragmentShader').textContent;
    let filter = new PIXI.Filter(null, fragmentShader);
    filter.uniforms.iResolution = {x: app.screen.width, y: app.screen.height};
    filter.uniforms.xmin = xmin;
    filter.uniforms.xmax = xmax;
    filter.uniforms.ymin = ymin;
    filter.uniforms.ymax = ymax;
    filter.uniforms.phase = 0;

    let container = new PIXI.Container();
    container.filterArea = app.screen;
    container.filters = [filter];
    app.stage.addChild(container);    
    document.getElementById('container').appendChild(app.view);

I tried this technique (the takeScreenshot function) to take a screenshot. But I only get a black 1x1 image. Should I use something else to take a screenshot?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ivanpopelyshevcommented, Mar 26, 2020

extract.canvas(app.stage) caculates bounds of stage and takes that part of screen. It doesnt see filterArea, that field does not affect bounds, it swaps bounds only for FilterSystem.

You have to create renderTexture of appropriate size, use renderer.render(app.stage, renderTexture); and then extract.canvas(renderTexture); - that will ensure that size of output is correct

Why do you need a Filter in first place when you dont use container contents (uSampler uniforms) ? Use mesh shader, its easier: https://pixijs.io/examples/#/mesh-and-shaders/triangle-textured.js

There are two ways of evading those kind of problems:

  1. Help PixiJS team produces articles and examples for all user cases like this one, maybe make one example yourself and ask to publish it in wiki

  2. Using pixijs cloned repo instead of just docs. Open it in separate IDE window and search for classes you use when you work with pixijs. If you read Extract class sources and try to debug it a bit - you will see the problem. Extract itself isnt magic it is just a wrapper around other pixi operations and WebGL readPixels.

Thank you for noticing that filter example + screenshot example = a problem. I will remember that and I’m going to make a link at https://github.com/pixijs/pixi.js/wiki/v5-Hacks .

0reactions
bigtimebuddycommented, Apr 1, 2020

Seems answered. Closing. @stla let me know if it’s not and we can reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Screenshots - Sildurs Shaders
Screenshots : Vibrant shaders album · Enhanced Default album · Fabulous shaders album. Sildur. GitHub E-Mail Twitter FB Page YouTube Discord Forum Donation ......
Read more >
Minecraft Shaders Screenshot (Edited) [1920x1080] - Pinterest
[1920x1200] I made a collection of Minecraft shaders screenshots to use as wallpapers.
Read more >
Screenshots. Shaders or no shaders? : r/Minecraft - Reddit
I dislike shaders for screenshots, since the shots do not represent what most people will see if they download a schematic / world...
Read more >
How to Take BETTER SCREENSHOTS in Minecraft! - YouTube
In this video, I'll show you how to take better screenshots in Minecraft! I cover angles, shaders, resolution, shadows, post processing and ...
Read more >
Minecraft screenshots aren't turning out? Do this instead.
This video will show you the techniques to make your screenshots look amazing, even if you can't run shaders !
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found