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

Highlight shaders when hovering over list item #3

Closed
spite opened this issue Apr 7, 2015 · 7 comments
Closed

Highlight shaders when hovering over list item #3

spite opened this issue Apr 7, 2015 · 7 comments

Comments

@spite
Copy link
Owner

spite commented Apr 7, 2015

It probably has to do with replacing gl_FragColor.rgb *= vec3( 1., 0., 1. ); in the last step of the fragment shader, but I can't figure out a way that:

a) works with any structure of shader - probably requires some interesting regExp
b) won't interfere with the shader source update mechanism (how to distinguish user-type changs from that change) - may be creating a parallel shader for that?

@toji
Copy link

toji commented Apr 7, 2015

Maybe something like this psuedo-code?

shaderSource.replace('main()', 'internalMain()');
shaderSource.append('void main() { internalMain(); gl_FragColor.r = 1.0; }');

Obviously the replace would need to be more robust than that, but this way you preserve all of the original fragment shader logic. Other candidates for the frag color change would be inverting or swizzling color channels.

@spite
Copy link
Owner Author

spite commented Apr 7, 2015

That's a good one!

Exactly, checking for a more precise "main()" to prevent changing functions that might be named "{whatever}main()", and that should work!

Let's give it a try and then figure out if there needs to be some caching to prevent continuous re-attaching and re-linking of programs.

spite added a commit that referenced this issue Apr 7, 2015
@spite
Copy link
Owner Author

spite commented Apr 7, 2015

Ok, it worked :)

This is definitely going to be a problem with heavy shaders that take longer to compile, but we'll cross that bridge when we come to it.

For now, when version 1.0.2 gets updated in the Chrome Store, there's already color hinting of the program is hovered.

I've tried it with several programs, including your Q3 BSP viewer, and it works as expected :)

Here's a video showing the result https://www.youtube.com/watch?v=vUgUWq5Twdw

@spite spite closed this as completed Apr 7, 2015
@toji
Copy link

toji commented Apr 7, 2015

Very nice! Glad it works!

@spite
Copy link
Owner Author

spite commented Apr 7, 2015

Thanks for the suggestion, it really did the trick. I would probably have ended looking for the closing brace of the main() and adding the color modifier. Kudos!

@spite
Copy link
Owner Author

spite commented Apr 9, 2015

Still not working. There's some issues and it destroys shaders.

@spite
Copy link
Owner Author

spite commented Jul 13, 2015

The highlighting system -and the toggling visibility system, which is based on the same idea-, is working. If the shader breaks it's because the live-replacing mechanism of the extension is still not good enough. Closing this ticket.

@spite spite closed this as completed Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants