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

Updating Shader to version 4.0 #1683

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

perminder-17
Copy link
Contributor

Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or

(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or

(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.

(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.

Signed-off-by: Perminder <permindersingh089@gmail.com>
@perminder-17 perminder-17 marked this pull request as draft July 2, 2024 16:21
@perminder-17
Copy link
Contributor Author

This is still a work in progress PR

Copy link
Contributor

github-actions bot commented Jul 2, 2024

Here are the build results
Avogadro2.AppImage
Win64.exe
Artifacts will only be retained for 90 days.

Signed-off-by: Perminder <permindersingh089@gmail.com>
@perminder-17 perminder-17 changed the title Updating Shader to GL ES 3.0 Updating Shader to version 4.0 Jul 2, 2024
Copy link
Contributor

github-actions bot commented Jul 2, 2024

Here are the build results
Avogadro2.AppImage
Win64.exe
Artifacts will only be retained for 90 days.

Signed-off-by: Perminder <permindersingh089@gmail.com>
Copy link
Contributor

github-actions bot commented Jul 3, 2024

Here are the build results
Avogadro2.AppImage
Win64.exe
Artifacts will only be retained for 90 days.

@perminder-17 perminder-17 marked this pull request as ready for review July 3, 2024 22:15
@ghutchis
Copy link
Member

ghutchis commented Jul 4, 2024

Please check the following patch. I get a bunch of errors from the shaders on my Mac, because texture2D is renamed to texture:
texture.patch

Nothing renders yet, but it also doesn't crash, which is a good start. 😄

@perminder-17
Copy link
Contributor Author

perminder-17 commented Jul 4, 2024

Please check the following patch. I get a bunch of errors from the shaders on my Mac, because texture2D is renamed to texture: texture.patch

Nothing renders yet, but it also doesn't crash, which is a good start. 😄

Hmmm....good catch. I will fix it now.

I thought texture2D() is fully removed in WEBGL and texture2D() is only depricated in OPENGL new versions. Anyways, fixing it now. Thanks

Signed-off-by: Perminder <permindersingh089@gmail.com>
Copy link
Contributor

github-actions bot commented Jul 5, 2024

Here are the build results
Avogadro2.AppImage
Win64.exe
Artifacts will only be retained for 90 days.

@ghutchis
Copy link
Member

ghutchis commented Jul 5, 2024

Any "deprecated" OpenGL code is not allowed in OpenGL Core Profile.

So the trick is looking around for deprecated code.

@perminder-17
Copy link
Contributor Author

Any "deprecated" OpenGL code is not allowed in OpenGL Core Profile.

So the trick is looking around for deprecated code.

Everything else in the code looks fine to me. Is there anything else that appears deprecated maybe?

@ghutchis
Copy link
Member

ghutchis commented Jul 6, 2024

@cryos - any ideas? In combination with OpenChemistry/avogadroapp#497 the shaders compile and link completely.

But we don't see anything rendered in the widget.

@cryos
Copy link
Member

cryos commented Jul 8, 2024

@cryos - any ideas? In combination with OpenChemistry/avogadroapp#497 the shaders compile and link completely.

But we don't see anything rendered in the widget.

Shaders are finicky, it would be looking at runtime issues, quirks or errors in updating. I had something pretty close to this but yeah I wasn't getting things to render correctly over a year back. I think the outColor versus gl_FragColor needs to be handled properly, I don't really see where outColor gets hooked up to anything, but it has been a while since I looked at this.

I don't see any discussion of the handling of the fragment color in this PR or the commits.

@ghutchis
Copy link
Member

ghutchis commented Jul 8, 2024

Thanks - @perminder-17 also got some feedback in the OpenGL community forum .. core profile requires VAO - vertex array objects: https://www.khronos.org/opengl/wiki/Tutorial2:_VAOs,_VBOs,_Vertex_and_Fragment_Shaders_(C_/_SDL)

There seems to be some other bits that need modernization (e.g., arrow*) but I think the VAO is the main missing piece.

@perminder-17
Copy link
Contributor Author

perminder-17 commented Jul 9, 2024

Thankyou so much @cryos for your thoughts.

I think the outColor versus gl_FragColor needs to be handled properly, I don't really see where outColor gets hooked up to anything,

I'm really sorry if I'm not referring to the same thing, but what I feel is:

We can associate fragment shader outputs with colour attachments using a layout directive,
For e.g.

layout(location=0) out vec4 outColor;

Also, the same thing can happen in the CPU too by glBindFragDataLocation which should be called prior to linking.

If a shader statically assigns a location to a varying out variable in the shader text, that location is used and any location assigned with glBindFragDataLocation is ignored.
Reference: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBindFragDataLocationIndexed.xhtml

But since we're using a single colour attachment (i.e. replacing gl_FragColor rather than gl_FragData), is it necessary to explicitly specify the attachment? as any output variable defaults to attachment zero?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants