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

Technique 'ambient' node case added #8610

Closed
wants to merge 2 commits into from
Closed

Conversation

poof86
Copy link
Contributor

@poof86 poof86 commented Apr 12, 2016

The ambient node case is missing from technique/shader parsing

The ambient node case is missing from technique/shader parsing
@mrdoob
Copy link
Owner

mrdoob commented Apr 12, 2016

We don't support ambient in our built-in materials though.

@poof86
Copy link
Contributor Author

poof86 commented Apr 12, 2016

But there is support for ambient occlusion textures. I was trying to pick up ambient and emissive textures in my models and set them to the material.aoMap property.

Btw, I am missing a lightMap feature for the Basic/Constant material. I see it was removed with version r71.
To still get the result I want (a detailed diffuse texture blended with a lightMap) I changed the THREE.ShaderChunk[ 'aomap_fragment’ ] chunk with the following:

#ifdef USE_AOMAP
vec3 ambientOcclusion = texture2D( aoMap, vUv2 ).rgb * aoMapIntensity;
reflectedLight.indirectDiffuse = min( reflectedLight.indirectDiffuse.rgb * 2.0 * ambientOcclusion.rgb, vec3(1.0) );
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );
#endif
#endif

Inspired by WestLangley comment:
#5741 (comment)

Maybe ColladaLoader.js can use the ambient texture for material.aoMap and emissive texture for material.lightMap?
Lightmaps on BasicMaterial would use the following shader chunk:

#ifdef USE_LIGHTMAP
reflectedLight.indirectDiffuse = min( reflectedLight.indirectDiffuse.rgb * 2.0 * texture2D( lightMap, vUv2 ).rgb * lightMapIntensity, vec3(1.0) );
#endif

@WestLangley
Copy link
Collaborator

@poof86

Lightmaps in three.js are now treated as a source of indirect (ambient) light, and are purely additive to total indirect light.

Ambient occlusion maps in three.js occlude only indirect (ambient) light.

MeshBasicMaterial does not respond to lights.

three.js materials no longer have an ambient property. The ambient reflectance of the material is assumed to be the same as the diffuse reflectance of the material (a.k.a, the material's color).

Have the ColladaLoader.js use emissive and ambient textures to set the aoMap property on BasicMaterials.
In the future maybe add a lightMap property to BasicMaterial and have different blending modes for the shading.
@@ -3791,7 +3792,21 @@ THREE.ColladaLoader = function () {
switch ( this.type ) {

case 'constant':


if ( props.emissionMap !== undefined ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any example files that use these maps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a quick example just a sec

@poof86
Copy link
Contributor Author

poof86 commented Apr 12, 2016

I understand,

It would be nice if there is an easy way to use the BasicMaterial to blend detailed diffuse textures and prebaked lighting textures. Maybe add a different kind of textureMap property for this technique? The BasicMaterial is ideal for when you want to be as less resource intensive as possible right? So support for this would be great :)

Should I close the pull request?

@WestLangley
Copy link
Collaborator

By the way, MeshBasicMaterial does support ambient occlusion maps.

#6588
#6364 (comment)

@mrdoob
Copy link
Owner

mrdoob commented Nov 7, 2016

Now that MeshBasicMaterial supports lightMap. Is this PR needed?

@poof86
Copy link
Contributor Author

poof86 commented Nov 11, 2016

The lightmap shader uses a different formula, but I will test to see if it has similar results.
Sorry for not posting an example yet, was quite busy and forgot :/

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 17, 2017

Old ColladaLoader has been removed.

@Mugen87 Mugen87 closed this Sep 17, 2017
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