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

add renderer prop in onBeforeCompile #13362

Merged
merged 5 commits into from
Mar 3, 2018
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Feb 19, 2018

My need:

To the next NodeMaterial release is need renderer argument to build material. Not to complicate too much the idea is use an auto build since the onBeforeCompile is called.

THREE.NodeMaterial.prototype.onBeforeCompile = function( shader ) {

_this.build( shader.renderer );

};

Renderer argument is the first moment to texture encoding. Now is individual by texture and not by slot as previously, for example:

Old

	if ( builder.isSlot( 'color' ) ) {

		code = 'mapTexelToLinear(' + code + ')';

	} else if ( builder.isSlot( 'emissive' ) ) {

		code = 'emissiveMapTexelToLinear(' + code + ')';

	} else if ( builder.isSlot( 'environment' ) ) {

		code = 'envMapTexelToLinear(' + code + ')';

	}

New

code = builder.material.getTexelDecodingFunction( code, this.value.encoding, builder.renderer );

And fix the fact that the old mode only work with linear texture encoding in NodeMaterial.

@sunag
Copy link
Collaborator Author

sunag commented Feb 20, 2018

Or could be this:

material.onBeforeCompile( materialProperties.shader, _this );

https://github.com/sunag/three.js/blob/a4b8c30be485b4ff661c60151f84ecb57e441227/src/renderers/WebGLRenderer.js#L1541

@mrdoob
Copy link
Owner

mrdoob commented Feb 27, 2018

Or could be this:

material.onBeforeCompile( materialProperties.shader, _this );

I think I vote for that instead.

@mrdoob mrdoob added this to the r91 milestone Feb 27, 2018
@sunag
Copy link
Collaborator Author

sunag commented Feb 28, 2018

Done!

@WestLangley
Copy link
Collaborator

I think there should be an update to the documentation when a method's signature is changed.

@Mugen87
Copy link
Collaborator

Mugen87 commented Feb 28, 2018

@sunag
Copy link
Collaborator Author

sunag commented Feb 28, 2018

Is to change it

[method:null onBeforeCompile]()

to?

[method:null onBeforeCompile]( [param:Object shader], [param:WebGLRenderer renderer] )

@mrdoob
Copy link
Owner

mrdoob commented Mar 1, 2018

@sunag yep!

@sunag
Copy link
Collaborator Author

sunag commented Mar 1, 2018

Done

@mrdoob mrdoob merged commit 6c2d00a into mrdoob:dev Mar 3, 2018
@mrdoob
Copy link
Owner

mrdoob commented Mar 3, 2018

Thanks!

@sunag sunag deleted the 91dev-shadercompile branch June 3, 2019 22:58
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

Successfully merging this pull request may close these issues.

4 participants