Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPU Shader Module for viewport drawing #1098

Open
luboslenco opened this issue Jan 13, 2019 · 6 comments
Open

GPU Shader Module for viewport drawing #1098

luboslenco opened this issue Jan 13, 2019 · 6 comments
Labels
feature request This issue requests a feature

Comments

@luboslenco
Copy link
Member

luboslenco commented Jan 13, 2019

Use GPU shader module to draw game preview in Blender viewport.

GPU Shader Module API:
https://docs.blender.org/api/blender2.8/gpu.html

@MoritzBrueckner
Copy link
Collaborator

Hi, out of curiosity: how did this work back then?

How was it possible to run Kha without opening another window? How did the (fast) communication between the processes work? I found some old code but it's not really clear how it worked. It also used the barmory module which I can't find anywhere (because of the custom blender version used for Armory?).

Thanks :)

@luboslenco
Copy link
Member Author

Yo, it was a special build of Blender with Krom embedded in it. barmory was a Python module which told Krom where to load krom.js file, Krom then executed OpenGL calls inside the Blender viewport. Unfortunately it was hell on earth to keep it up to date with new Blender versions, manage it for all 3 operating systems and contained many hacks.

@mistajuliax
Copy link

Hi, is this something that could be considering again now that blender have a lts version or does is not related to it ? What about synching viewport editing with krom ?? Cheers.

@MoritzBrueckner
Copy link
Collaborator

Thanks for the explanation! That sounds very complicated and explains why the viewport preview was removed.

Do you have any idea if there might be ways of implementing this without the need to maintain a custom Blender version? A while ago I thought about using a memory mapped file (if krom would support that) to send the drawn image to Blender but that would probably be still too slow and doesn't solve the other problems (input rerouting, no sound etc.).

@luboslenco
Copy link
Member Author

The only other way I found out involved pulling pixels out of gpu which is not fast. But in regards to syncing viewport editing, there is an options for that at Armory Project - Live Patch, so maybe improving on that might be worth looking into.

@N8n5h
Copy link
Contributor

N8n5h commented May 13, 2021

Use GPU shader module to draw game preview in Blender viewport.

GPU Shader Module API:
https://docs.blender.org/api/blender2.8/gpu.html

Ok, I'm poking around with the original idea to see if it's actually doable with the api's current state. So far I've managed to tick off the "checklist" rendering to a texture to use it as input for another shader.:
image
The triangle is rendered first, and then the image is rendered to the square.

But I can't seem to find a way to bind multiple targets to the GPUOffScreen object to render multiple different images in one pass with the same shader instead of just one, like it's done in armory in several places with the fragColor[0], fragColor[1], etc. So unless someone has some idea about this, the only other possibility I can think of would be to maybe render the shader in multiple passes to get all the different images, which may not be very efficient...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request This issue requests a feature
Projects
None yet
Development

No branches or pull requests

4 participants