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

Support ptex mesh - Step 2: fix the shader #194

Merged
merged 2 commits into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/shaders/ptex-default-gl410.frag
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
uniform int tileSize;
uniform int widthInTiles;
uniform samplerBuffer meshAdjFaces;
uniform usamplerBuffer meshAdjFaces;

ivec2 FaceToAtlasPos(int faceID, int tileSize) {
ivec2 tilePos;
Expand Down Expand Up @@ -29,7 +29,7 @@ const uint FACE_MASK = 0x3FFFFFFF;

int GetAdjFace(int face, int edge, out int rot) {
// uint data = meshAdjFaces[face * 4 + edge];
uint data = uint(texelFetch(meshAdjFaces, face * 4 + edge));
uint data = texelFetch(meshAdjFaces, face * 4 + edge).r;
rot = int(data >> ROTATION_SHIFT);
return int(data & FACE_MASK);
}
Expand Down
12 changes: 8 additions & 4 deletions src/shaders/ptex-default-gl410.geom
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ out vec2 uv;
void main() {
gl_PrimitiveID = gl_PrimitiveIDIn;

uv = vec2(1.0, 0.0);
gl_Position = gl_in[1].gl_Position;
// the triangle trip generated is (3, 0, 2, 1),
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: trip -> strip

// which is is different from replicaSDK.
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo: is is -> is

// The winding of the two triangles (3, 0, 2) and (2, 0, 1)
// is CCW.
uv = vec2(0.0, 1.0);
gl_Position = gl_in[3].gl_Position;
EmitVertex();

uv = vec2(0.0, 0.0);
Expand All @@ -18,8 +22,8 @@ void main() {
gl_Position = gl_in[2].gl_Position;
EmitVertex();

uv = vec2(0.0, 1.0);
gl_Position = gl_in[3].gl_Position;
uv = vec2(1.0, 0.0);
gl_Position = gl_in[1].gl_Position;
EmitVertex();

EndPrimitive();
Expand Down