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

Default opengl shader misrepresents polymeshes with no N prim var #110

Closed
bentoogood opened this issue Apr 3, 2013 · 5 comments
Closed
Labels
bug Issues representing bugs scene Issues with GafferScene

Comments

@bentoogood
Copy link
Contributor

If an object of type:MeshPrimitive and interpolation:linear has no 'N' primvar (normals data) the default 3d Viewer shader doesn't function correctly.

Meshes set to interpolation:catmullClark don't suffer from this problem.

no_normals_no_likey

@bentoogood
Copy link
Contributor Author

Sample torus used to demonstrate problem (save as .obj file):

# This file uses centimeters as units for non-parametric coordinates.

v 1.500000 -0.000000 0.000001
v 1.213526 -0.000000 -0.881677
v 0.463526 -0.000000 -1.426585
v -0.463526 -0.000000 -1.426585
v -1.213525 -0.000000 -0.881678
v -1.500000 -0.000000 -0.000000
v -1.213526 -0.000000 0.881678
v -0.463526 -0.000000 1.426585
v 0.463525 -0.000000 1.426585
v 1.213526 -0.000000 0.881678
v 1.404508 -0.293893 0.000001
v 1.136272 -0.293893 -0.825549
v 0.434017 -0.293893 -1.335767
v -0.434017 -0.293893 -1.335767
v -1.136271 -0.293893 -0.825550
v -1.404508 -0.293893 -0.000000
v -1.136271 -0.293893 0.825549
v -0.434017 -0.293893 1.335767
v 0.434017 -0.293893 1.335767
v 1.136271 -0.293893 0.825549
v 1.154509 -0.475528 0.000001
v 0.934017 -0.475528 -0.678603
v 0.356763 -0.475528 -1.098003
v -0.356763 -0.475528 -1.098003
v -0.934017 -0.475528 -0.678603
v -1.154509 -0.475528 -0.000000
v -0.934017 -0.475528 0.678603
v -0.356763 -0.475528 1.098003
v 0.356763 -0.475528 1.098003
v 0.934017 -0.475528 0.678603
v 0.845491 -0.475528 0.000001
v 0.684017 -0.475528 -0.496967
v 0.261271 -0.475528 -0.804110
v -0.261271 -0.475528 -0.804110
v -0.684017 -0.475528 -0.496967
v -0.845491 -0.475528 -0.000000
v -0.684017 -0.475528 0.496967
v -0.261271 -0.475528 0.804110
v 0.261271 -0.475528 0.804110
v 0.684017 -0.475528 0.496967
v 0.595491 -0.293892 0.000000
v 0.481763 -0.293892 -0.350021
v 0.184017 -0.293892 -0.566346
v -0.184017 -0.293892 -0.566346
v -0.481763 -0.293892 -0.350021
v -0.595491 -0.293892 -0.000000
v -0.481763 -0.293892 0.350021
v -0.184017 -0.293892 0.566346
v 0.184017 -0.293892 0.566346
v 0.481763 -0.293892 0.350021
v 0.500000 0.000000 0.000000
v 0.404509 0.000000 -0.293892
v 0.154509 0.000000 -0.475528
v -0.154509 0.000000 -0.475528
v -0.404508 0.000000 -0.293893
v -0.500000 0.000000 -0.000000
v -0.404509 0.000000 0.293893
v -0.154509 0.000000 0.475528
v 0.154508 0.000000 0.475528
v 0.404509 0.000000 0.293893
v 0.595492 0.293893 0.000000
v 0.481763 0.293893 -0.350021
v 0.184017 0.293893 -0.566346
v -0.184017 0.293893 -0.566346
v -0.481763 0.293893 -0.350021
v -0.595492 0.293893 -0.000000
v -0.481763 0.293893 0.350021
v -0.184017 0.293893 0.566346
v 0.184017 0.293893 0.566346
v 0.481763 0.293893 0.350021
v 0.845492 0.475528 0.000001
v 0.684018 0.475528 -0.496967
v 0.261272 0.475528 -0.804111
v -0.261272 0.475528 -0.804111
v -0.684017 0.475528 -0.496968
v -0.845492 0.475528 -0.000000
v -0.684017 0.475528 0.496968
v -0.261271 0.475528 0.804111
v 0.261271 0.475528 0.804111
v 0.684017 0.475528 0.496968
v 1.154509 0.475528 0.000001
v 0.934018 0.475528 -0.678603
v 0.356763 0.475528 -1.098003
v -0.356763 0.475528 -1.098003
v -0.934017 0.475528 -0.678604
v -1.154509 0.475528 -0.000000
v -0.934018 0.475528 0.678603
v -0.356763 0.475528 1.098003
v 0.356763 0.475528 1.098004
v 0.934018 0.475528 0.678603
v 1.404509 0.293892 0.000001
v 1.136272 0.293892 -0.825549
v 0.434017 0.293892 -1.335767
v -0.434017 0.293892 -1.335767
v -1.136271 0.293892 -0.825550
v -1.404509 0.293892 -0.000000
v -1.136272 0.293892 0.825550
v -0.434017 0.293892 1.335767
v 0.434017 0.293892 1.335767
v 1.136272 0.293892 0.825550
f 1 11 12 2
f 2 12 13 3
f 3 13 14 4
f 4 14 15 5
f 5 15 16 6
f 6 16 17 7
f 7 17 18 8
f 8 18 19 9
f 9 19 20 10
f 10 20 11 1
f 11 21 22 12
f 12 22 23 13
f 13 23 24 14
f 14 24 25 15
f 15 25 26 16
f 16 26 27 17
f 17 27 28 18
f 18 28 29 19
f 19 29 30 20
f 20 30 21 11
f 21 31 32 22
f 22 32 33 23
f 23 33 34 24
f 24 34 35 25
f 25 35 36 26
f 26 36 37 27
f 27 37 38 28
f 28 38 39 29
f 29 39 40 30
f 30 40 31 21
f 31 41 42 32
f 32 42 43 33
f 33 43 44 34
f 34 44 45 35
f 35 45 46 36
f 36 46 47 37
f 37 47 48 38
f 38 48 49 39
f 39 49 50 40
f 40 50 41 31
f 41 51 52 42
f 42 52 53 43
f 43 53 54 44
f 44 54 55 45
f 45 55 56 46
f 46 56 57 47
f 47 57 58 48
f 48 58 59 49
f 49 59 60 50
f 50 60 51 41
f 51 61 62 52
f 52 62 63 53
f 53 63 64 54
f 54 64 65 55
f 55 65 66 56
f 56 66 67 57
f 57 67 68 58
f 58 68 69 59
f 59 69 70 60
f 60 70 61 51
f 61 71 72 62
f 62 72 73 63
f 63 73 74 64
f 64 74 75 65
f 65 75 76 66
f 66 76 77 67
f 67 77 78 68
f 68 78 79 69
f 69 79 80 70
f 70 80 71 61
f 71 81 82 72
f 72 82 83 73
f 73 83 84 74
f 74 84 85 75
f 75 85 86 76
f 76 86 87 77
f 77 87 88 78
f 78 88 89 79
f 79 89 90 80
f 80 90 81 71
f 81 91 92 82
f 82 92 93 83
f 83 93 94 84
f 84 94 95 85
f 85 95 96 86
f 86 96 97 87
f 87 97 98 88
f 88 98 99 89
f 89 99 100 90
f 90 100 91 81
f 91 1 2 92
f 92 2 3 93
f 93 3 4 94
f 94 4 5 95
f 95 5 6 96
f 96 6 7 97
f 97 7 8 98
f 98 8 9 99
f 99 9 10 100
f 100 10 1 91

@johnhaddon
Copy link
Member

So what we'd be wanting here is to add face-normals so it is shaded in a faceted manner?

@bentoogood
Copy link
Contributor Author

faceted per face normals sounds fine.

@johnhaddon
Copy link
Member

The problem here is actually in IECoreGL in Cortex, so we'll need to deal with it there.

johnhaddon added a commit to johnhaddon/cortex that referenced this issue Nov 25, 2013
This is achieved by computing a Uniform "N" in the ToGLMeshConverter. Because up till now the GL MeshPrimitive didn't support Uniform data, the "N" is immediately converted to FaceVarying also in the ToGLMeshConverter. This new conversion makes the conversions taking place inside the IECoreGL::MeshPrimitive totally redundant unless someone is using the MeshPrimitive class directly without a converter. Note that the MeshPrimitive actually doesn't have enough information to support Uniform data directly because it doesn't have the faces prior to triangulation. For this reason, I think there's a very good case for ditching the internal conversions in MeshPrimitive, and making the MeshPrimitive constructor need only the number of triangles, and not the vertex ids (which are used purely for conversion).

Fixes ImageEngine#118 and GafferHQ/gaffer#110.
@johnhaddon
Copy link
Member

Closing this, as the root cause has been fixed in ImageEngine/cortex#118.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues representing bugs scene Issues with GafferScene
Projects
None yet
Development

No branches or pull requests

2 participants