Skip to content

[WIP] normalmap space example#14303

Closed
pailhead wants to merge 4 commits intomrdoob:devfrom
pailhead:normal-map-space-example
Closed

[WIP] normalmap space example#14303
pailhead wants to merge 4 commits intomrdoob:devfrom
pailhead:normal-map-space-example

Conversation

@pailhead
Copy link
Contributor

@pailhead pailhead commented Jun 16, 2018

Hi,

I made a simple geosphere in 3d studio max, mapped it into two UV islands, and baked a tangent and object space normal maps. There are lots of options to flip channels in max's baker.

This demo uses onBeforeCompile to inject the code that will be merged soon, this is more about the asset (a small obj with a corresponding baked normal map). @WestLangley do you think this might be useful?

normalmap_space

The baked model looks a bit different in 3ds max (red is tangent, purple is object):
normalmap_3dsmax

@Mugen87 Mugen87 closed this Jun 16, 2018
@Mugen87 Mugen87 reopened this Jun 16, 2018
@pailhead pailhead changed the title normalmap space example [WIP] normalmap space example Jun 16, 2018
Repository owner deleted a comment from pailhead Jun 16, 2018
@pailhead
Copy link
Contributor Author

Per conversation with @mrdoob this can wait until #14239 lands. If someone finds it interesting though, the model and textures are there to experiment with. It was generated in world space as opposed to local XYZ with the default settings for both tangent and object.

@pailhead pailhead force-pushed the normal-map-space-example branch from 39199da to d7856d7 Compare June 16, 2018 20:14
@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2018

#14239 has now been merged 🙌

@WestLangley
Copy link
Collaborator

@WestLangley do you think this might be useful?

I did not provide an example because I did not think a separate example just to show an object-space normal map provided added benefit. But having and object-space normal map as part of an existing example seems like a good idea. Maybe one of the loader examples could use an object-space normal map?

Your tangent-space example has serious artifacts -- at the seams, apparently. I think it would be useful to figure out what is going on there.

Also, be aware that it does not make sense to include attribute vertex normals with an object-space normal map. The attribute vertex normals are not used.

@pailhead
Copy link
Contributor Author

pailhead commented Jun 17, 2018

Also, be aware that it does not make sense to include attribute vertex normals with an object-space normal map. The attribute vertex normals are not used.

It's not needed for the tangent ones either essentially since it can be computed on the client. Was slightly easier to export than to look up what computeVertexNormals was actually called :D I can remove the normals, it would make the file smaller.

Your tangent-space example has serious artifacts -- at the seams, apparently. I think it would be useful to figure out what is going on there.

It's more than just seams, there's only one seam running around the circumference. I think "normal map" is a broad topic, but as is, this is a content authoring tool, generating two types of baked normal maps, and the example shows how they render with three.js. If not useful as public facing, perhaps it can be assessed as just that result of rendering content generated in 3ds max?

What do you suggest be done if anything with this? I was more curious about the "export with these settings" conclusion, whtat's the object space convention?

@pailhead
Copy link
Contributor Author

pailhead commented Jun 17, 2018

Actually i stand corrected for the normals being needed. For OBJ in particular, i think exporting the normals, basically considers smoothing groups inside of 3ds max. Meaning, a hard edge that is generated by smoothing groups (shared vertices) in 3ds max, gets translated to a split (douple vertices) in three.js. Normals are needed to indicate this split (hard edge) i think. But, the source object could also be modified, to include an actual split at hard edges (double vertices).

@WestLangley
Copy link
Collaborator

Vertex normals are required for a tangent-space normal map. For proper rendering, they must be the same as the normals assumed when the normal map was created. computeVertexNormals() is a heuristic that computes 'reasonable' normals. I would not rely on the client using that method if a tangent-space map is being used.

What do you suggest be done if anything with this?

Nothing, really. It is well-known that modeling tools and rendering engines have differing approaches to dealing with normal maps.

@pailhead
Copy link
Contributor Author

pailhead commented Jun 18, 2018

Vertex normals are required for a tangent-space normal map. For proper rendering, they must be the same as the normals assumed when the normal map was created.

They do not depend on normals alone, but I believe OBJ can't even store these. I think one might use a heuristic since the results are going to be subjectively incorrect (without the tangent frame, it's impossible to tell what "correct" is). Proper rendering thus may become arbitrary.

@mrdoob
Copy link
Owner

mrdoob commented Jun 18, 2018

@mrdoob
Copy link
Owner

mrdoob commented Jun 18, 2018

How come the live link doesn't look like in the screenshot?

@pailhead
Copy link
Contributor Author

umm i think i didnt flip some flag right, it was the shader code that's now inside ill look into it

@pailhead
Copy link
Contributor Author

@mrdoob i'm confused, it seems to look fine once i rebased, but i need to double check some things. Is this raw git just running it off my branch? If so, maybe it didn't include the merge?

@pailhead pailhead force-pushed the normal-map-space-example branch from 1e3d1b0 to 87d46f7 Compare June 18, 2018 03:53
@pailhead
Copy link
Contributor Author

Does the rawgit thing update? The demo should look exactly the same as the one posted if you click on the first screenshot.

@mrdoob
Copy link
Owner

mrdoob commented Jun 18, 2018

Seems like it updated. Looks fine here 👌

I think we should simplify the example though. Do you mind removing DAT.GUI and showing 2 spheres next to each other, one using tangent space and another using object space?

@mrdoob mrdoob added this to the r94 milestone Jun 18, 2018
@mrdoob
Copy link
Owner

mrdoob commented Jun 21, 2018

Thanks for simplifying the example! Do you know why the tangent based normal map looks wrong?

screen shot 2018-06-20 at 5 18 23 pm

Seems like 3DS Max tangents don't match with the ones the dfdx code computes.

@pailhead
Copy link
Contributor Author

pailhead commented Jun 21, 2018

Yes, but it is a broad topic. You basically outlined the jist of it with your last sentence.

@mrdoob mrdoob modified the milestones: r94, r95 Jun 27, 2018
@mrdoob
Copy link
Owner

mrdoob commented Jul 31, 2018

Closing in favour of #14593

@mrdoob mrdoob closed this Jul 31, 2018
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