Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Canvas transparency #74

Open
VinAr22 opened this issue Feb 27, 2020 · 12 comments
Open

Canvas transparency #74

VinAr22 opened this issue Feb 27, 2020 · 12 comments
Labels
feature request good first issue Good for newcomers question Further information is requested

Comments

@VinAr22
Copy link

VinAr22 commented Feb 27, 2020

Hello again! Im trying to save canvas as image like this

var data = renderer.domElement.toDataURL("image/png");
var img = new Image();
img.src = data;
$("body").append(img);

this way works only with three WebGLRenderer. In ray traycing renderer i get black background. Whats im doing wrong?

@jaxry
Copy link
Contributor

jaxry commented Feb 27, 2020

That's a good question and I'm not sure. I can try to offer some possible solutions.

https://stackoverflow.com/a/26790802
If you follow the instructions here and get the code structured in the right order, does it work? If not, it may be because the renderer doesn't always draw to the screen each frame, and only draws to the screen when the next sample is completely rendered. In this case, does running your code inside the renderer.onSampleRendered callback work?

@RenderTool
Copy link

Hello! @VinAr22 I can save it normally on my Google browser, and it's also black on Firefox.

@VinAr22
Copy link
Author

VinAr22 commented Feb 27, 2020

Hi! Thanks for the quick response. The method using requestAnimationFrame does not work. renderer.onSampleRendered did the trick

@VinAr22
Copy link
Author

VinAr22 commented Feb 27, 2020

So i have another question about this topic. Maybe it is possible to save only model view on transparent background? :)

@jaxry
Copy link
Contributor

jaxry commented Mar 4, 2020

Good question. It's not possible at the moment, but I'm in the middle of separating the different of stages of rendering (useful for spatial denoising) that will also make transparency possible as well. So we'll probably have that in a few weeks!

@VinAr22
Copy link
Author

VinAr22 commented Mar 4, 2020

Hello! It'll be cool! Please let me know when it will be possible

@jaxry jaxry changed the title How to save canvas as image Canvas transparency Apr 20, 2020
@VinAr22
Copy link
Author

VinAr22 commented Apr 29, 2020

Hello @jaxry! After the update, saving the canvas data does not work with renderer.onSampleRendered. :(

@jaxry
Copy link
Contributor

jaxry commented Apr 29, 2020

Thanks for letting me know. onSampleRendered now measures performance as well, and to get an accurate number, the callback is called one frame after the sample is rendered to the screen. Doing so makes the callback fall out of sync with the browser's draw frame.

Unfortunately I don't think we can move the callback back to where it was. Instead, would a separate callback, like renderer.getScreenshot(callback) get the job done?

@VinAr22
Copy link
Author

VinAr22 commented Apr 30, 2020

Hi @jaxry ! Thanks for the response. I understand correctly, this function already exists? Or is it just planned? it would be cool to be able to save a screenshot.

@elfrank elfrank added feature request question Further information is requested good first issue Good for newcomers labels May 17, 2020
@nicolab28
Copy link

nicolab28 commented May 26, 2020

I have hard-coded this code:

if (typeof window.screenShot == "function") {
        if (window.doScreenShot){
          window.screenShot();
          window.doScreenShot=false;
        }
      }

At the end of the function drawTile()

if (isLastTile) {
...

HERE
}

@VinAr22
Copy link
Author

VinAr22 commented May 26, 2020

Hi @nicolab28 ! Is it works with the last version of the ray tracing renderer?

@nicolab28
Copy link

I don't think I'm using the very last one, but I don't see why it won't work?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants