-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
[3.x] Add BLEND_MODE_DISABLED for spatial shaders. #56279
Conversation
Commits need to be squashed and renamed to match a topic name. Besides that, you need to create a master version of this PR. Changes should always be made for the master/main branch first unless it's something very specific to the previous version. |
8f3331f
to
5bdc220
Compare
Sorry for wasting your time, I'm new to contributing on Github, and I find this feature to be very useful for a project i'm working on, so I patched it onto the 3.x branch, altough I do intend to look into implementing this in the master branch as well. I would then have to open a separate PR, correct? |
I tested the PR you linked on a custom build that also integrates the changes from this PR and #51708, and it doesn't completely fit my use case, which i will include in more detail the PR's description. example project adapted from #51708: 32bpcViewportTest.zip |
5bdc220
to
c010bad
Compare
There is a violation of the static check - use clang-format tool on the files you've changed to fix it (https://docs.godotengine.org/en/latest/community/contributing/code_style_guidelines.html?highlight=clang-format#using-clang-format-locally) |
c010bad
to
b5aa26a
Compare
Ok, i think it should pass all checks now, thank you for the instructions. |
b5aa26a
to
56c4ff9
Compare
71cb8d3
to
c58391c
Compare
Over the last days i've been looking into implementing this PR for the master branch as well. Not reading the contributing guidelines carefully led me to skip submitting an issue to the godot-proposals repository. Should I submit an proposal going more in depth about the use case before submitting a new PR that implements these changes in master? |
I think for Godot 4.x we might need a better solution for these types of use cases. For 3.x not up to me to decide waht can be done. |
The thing is this functionality is already present for |
This should likely also be implemented in the GLES2 renderer. |
Yes, this will need to be added to both GLES2 and GLES3 before being merged. My outstanding concern is that this same mode will be very difficult in 4.0 and will naturally behave differently (as 3D and 2D use different texture color formats). Further, even in 3.x, depending on how this is being used for calculations it will behave different on mobile and desktop (mobile can't render to RGBA16 buffers, it uses RGB10_A2 for non-transparent and RGBA8 for transparent. In GLES2 we always use RGB8 or RGBA8). Some more details about your use-case would be helpful because, ultimately, we want to ensure that we find a solution to your particular use-case and create a feature that is intuitive and robust for other users as well. |
This feature essentially lets me easily use all four color channels when writing compute shaders in Godot 3.x. For this to happen in spatial shaders, there are two main requirements (at least in my workflow) that must be satisfied:
Due to my inexperience with Vulkan i've been struggling to find a solution for this in 4.0 as well, even though this feature, as far as i know, only benefits compute shaders, which limits its importance for 4.0 which will have a more robust compute shader support. |
My main concern is over the changing behaviour between platforms. In Godot 3.x, the scene shader was never designed to be used as a GPGPU (general-purpose computing on graphics processing units) shader. Further the framework around it assumes that it is doing traditional forward rendering of meshes. Accordingly, the engine will break your shader if you use it from other platforms (notably, GLES2, or any mobile device). If you are doing general-purpose compute, is there any reason not to use CanvasItem shaders? CanvasItem shaders don't have any post-processing or tonemapping applied. Importantly, the texture you render to is the one you read from, so they suffer less from precision loss than Spatial shaders and would generally be more suitable for this kind of thing. |
In most cases, CanvasItem shaders are fine. This is for those instances where it's not enough: for example because implementing a multi-pass compute shader that operates on a significant viewport size requires you instance an additional viewport for each pass and consume several times more VRAM. |
How would this PR solve that issue? You would still need multiple viewports wouldn't you? Also, with CanvasItems, you can use BackBufferCopies to stack shaders without having to reallocate an entire Viewport. To be clear, I hope I am not coming off as if I am needlessly criticizing your PR. I just think there may be a better solution for your problem and if there is, I would like to find that before introducing something new to the API that we won't be able to keep in the next upcoming version. |
No worries, i recognize this is an edge case, I just revived the PR because it solved this problem on my particular situation.
CanvasItem shader materials do not support multi-pass shading, and Spatial shaders do not support
You don't need to stack viewports if passes in the middle don't need to communicate with the next pass: |
Ahh, I think I am beginning to understand what you are doing. Are you using a full screen quad with multiple chained I suggested BackBufferCopy as I assumed subsequent passes were reading data from earlier passes. |
Thanks for the explanation, i will also try doing it this way. |
Please let me know how it goes! If this PR really does make the process way easier for you, then I am in favour of merging (we will have to sort out what to do about 4.0 though). |
This seems abandoned and there isn't much demand for users to add this feature in 3.x, so closing. |
I made this pull request by manually reviewing the changes in 35278 for use in the
3.x
branch, and added relevant documentation for the newBlendMode
enum value.As is stated in the original PR, this is a really useful feature for multi-pass compute involving tightly packed data in color channels. For my use case, I need a solution (implemented via render mode in this case) that i can pair with the
unshaded
render mode to be able to modify the alpha channel to a value other than 1 without the graphics driver subsequently modifying the values in the albedo channels, so that i can use the alpha channel for data transfer as well as the albedo ones.