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

Enable raw shader code for ShaderMaterial #3121

Closed
BKcore opened this issue Feb 22, 2013 · 10 comments
Closed

Enable raw shader code for ShaderMaterial #3121

BKcore opened this issue Feb 22, 2013 · 10 comments

Comments

@BKcore
Copy link

BKcore commented Feb 22, 2013

I'm suggesting a quick addition to THREE.WebGLRenderer.buildProgram() and THREE.ShaderMaterial in 2 steps:

This really tiny change would allow true custom fragment and vertex shaders to be used, without the fear of some automatic and hidden attributes/uniforms/defines addition by the Renderer.

As for backward compatibility, it's not a problem since we could just set disableShaderPrefix to false by default, making that change a choice to the user by setting that attribute to true after creating the material.

Sometimes, I need true flexibility when writing custom materials, and with all the code added by the Renderer to my shaders, it's sometimes a pain to debug.

What do you think?

@mrdoob
Copy link
Owner

mrdoob commented Feb 22, 2013

Maybe THREE.RawShaderMaterial?

@BKcore
Copy link
Author

BKcore commented Feb 23, 2013

Sounds good too. Although the difference between ShaderMaterial and RawShaderMaterial could be obscure to the neophyte.
Maybe useRawShader instead of disableShaderPrefix as attribute since negative api attributes are ugly.
Creating a new material for such a small change might be overkill. Although I haven't been following your recent api choices, so I can't say which way seems better fitted.

@zz85
Copy link
Contributor

zz85 commented Feb 28, 2013

+1 to this functionality. this is an issue I've also faced.

I think mrdoob is coming from where a new material is easier API-wise compared to a flag.

Or perhaps let RawShaderMaterial extend ShaderMaterial with raw shader flag enabled? (or the other way)?

Although I always wonder if there's a better way three.js can generate configurable shader code..

@mastershadow
Copy link

+1 for me too

@zz85
Copy link
Contributor

zz85 commented Nov 22, 2013

upping this thread, since i'm playing around with shaders a little.. any recent thoughts to this?

@mrdoob
Copy link
Owner

mrdoob commented Nov 22, 2013

Haven't spend any brain cycles into this myself. Open to more API ideas though.

@zz85
Copy link
Contributor

zz85 commented Nov 24, 2013

The simplest solution for now would be as @BKcore says - check for a flag. Then if we wish to try the THREE.RawShaderMaterial, would could just extend ShaderMaterial after.

I should probably try to do this soon and see whats happens.

@mrdoob
Copy link
Owner

mrdoob commented Mar 2, 2014

Well... that took a while...
Thanks guys! :)

@mrdoob mrdoob closed this as completed Mar 2, 2014
@zz85
Copy link
Contributor

zz85 commented Mar 3, 2014

nice @mrdoob. i was thinking of this the other day I was looking at WebGLProgram. Glad you did it yourself :)

@mrdoob
Copy link
Owner

mrdoob commented Mar 3, 2014

Step by step...

Next thing is, maybe, to do a Geometry to BufferGeometry step and remove all the Geometry specific code from WebGLRenderer.

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

No branches or pull requests

4 participants