2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2012-12-11 01:15:13 +00:00
|
|
|
//
|
|
|
|
|
2013-07-01 18:58:28 +00:00
|
|
|
//----------------------------------------------------------
|
2015-05-26 23:35:06 +00:00
|
|
|
// Patches.VertexGregory
|
2012-12-11 01:15:13 +00:00
|
|
|
//----------------------------------------------------------
|
2013-06-24 19:03:57 +00:00
|
|
|
#ifdef OSD_PATCH_VERTEX_GREGORY_SHADER
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
layout (location=0) in vec4 position;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_ATTRIBUTE_DECLARE
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
out block {
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdPerVertexGregory v;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_DECLARE
|
2013-06-10 19:53:04 +00:00
|
|
|
} outpt;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdComputePerVertexGregory(gl_VertexID, position.xyz, outpt.v);
|
2013-07-01 18:47:21 +00:00
|
|
|
OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position);
|
|
|
|
OSD_USER_VARYING_PER_VERTEX();
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
2013-07-01 18:47:21 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// Patches.TessControlGregory
|
|
|
|
//----------------------------------------------------------
|
2013-06-24 19:03:57 +00:00
|
|
|
#ifdef OSD_PATCH_TESS_CONTROL_GREGORY_SHADER
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
in block {
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdPerVertexGregory v;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_DECLARE
|
2013-06-10 19:53:04 +00:00
|
|
|
} inpt[];
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
out block {
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdPerPatchVertexGregory v;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_DECLARE
|
2015-05-31 17:59:01 +00:00
|
|
|
} outpt[4];
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
layout(vertices = 4) out;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdPerVertexGregory cv[4];
|
|
|
|
for (int i=0; i<4; ++i) {
|
|
|
|
cv[i] = inpt[i].v;
|
2013-07-01 18:58:28 +00:00
|
|
|
}
|
|
|
|
|
Updated handling of patchParam and patchCoord
Each patch has a corresponding patchParam. This is a set of three values
specifying additional information about the patch:
faceId -- topological face identifier (e.g. Ptex FaceId)
bitfield -- refinement-level, non-quad, boundary, transition, uv-offset
sharpness -- crease sharpness for a single-crease patch
These are stored in OsdPatchParamBuffer indexed by the value returned
from OsdGetPatchIndex() which is a function of the current PrimitiveID
along with an optional client provided offset.
Accessors are provided to extract values from a patchParam. These are
all named OsdGetPatch*().
While drawing patches, the patchParam is condensed into a patchCoord which
has four values (u, v, faceLevel, faceId). These patchCoords are treated
as int values during per-prim processing but are converted to float values
during per-vertex processing where the values are interpolated.
Also, cleaned up more of the shader namespace by giving an Osd prefix
to public functions, and consolidated boundary and transition handling
code into the PatchCommon shader files. The functions determining
tessellation levels are now all named OsdGetTessLevel*().
2015-05-02 00:52:37 +00:00
|
|
|
ivec3 patchParam = OsdGetPatchParam(OsdGetPatchIndex(gl_PrimitiveID));
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdComputePerPatchVertexGregory(patchParam, gl_InvocationID, gl_PrimitiveID, cv, outpt[gl_InvocationID].v);
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
OSD_USER_VARYING_PER_CONTROL_POINT(gl_InvocationID, gl_InvocationID);
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
if (gl_InvocationID == 0) {
|
Updated handling of patchParam and patchCoord
Each patch has a corresponding patchParam. This is a set of three values
specifying additional information about the patch:
faceId -- topological face identifier (e.g. Ptex FaceId)
bitfield -- refinement-level, non-quad, boundary, transition, uv-offset
sharpness -- crease sharpness for a single-crease patch
These are stored in OsdPatchParamBuffer indexed by the value returned
from OsdGetPatchIndex() which is a function of the current PrimitiveID
along with an optional client provided offset.
Accessors are provided to extract values from a patchParam. These are
all named OsdGetPatch*().
While drawing patches, the patchParam is condensed into a patchCoord which
has four values (u, v, faceLevel, faceId). These patchCoords are treated
as int values during per-prim processing but are converted to float values
during per-vertex processing where the values are interpolated.
Also, cleaned up more of the shader namespace by giving an Osd prefix
to public functions, and consolidated boundary and transition handling
code into the PatchCommon shader files. The functions determining
tessellation levels are now all named OsdGetTessLevel*().
2015-05-02 00:52:37 +00:00
|
|
|
vec4 tessLevelOuter = vec4(0);
|
|
|
|
vec2 tessLevelInner = vec2(0);
|
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
OSD_PATCH_CULL(4);
|
|
|
|
|
|
|
|
OsdGetTessLevels(cv[0].P, cv[3].P, cv[2].P, cv[1].P,
|
2015-05-21 01:27:32 +00:00
|
|
|
patchParam, tessLevelOuter, tessLevelInner);
|
Updated handling of patchParam and patchCoord
Each patch has a corresponding patchParam. This is a set of three values
specifying additional information about the patch:
faceId -- topological face identifier (e.g. Ptex FaceId)
bitfield -- refinement-level, non-quad, boundary, transition, uv-offset
sharpness -- crease sharpness for a single-crease patch
These are stored in OsdPatchParamBuffer indexed by the value returned
from OsdGetPatchIndex() which is a function of the current PrimitiveID
along with an optional client provided offset.
Accessors are provided to extract values from a patchParam. These are
all named OsdGetPatch*().
While drawing patches, the patchParam is condensed into a patchCoord which
has four values (u, v, faceLevel, faceId). These patchCoords are treated
as int values during per-prim processing but are converted to float values
during per-vertex processing where the values are interpolated.
Also, cleaned up more of the shader namespace by giving an Osd prefix
to public functions, and consolidated boundary and transition handling
code into the PatchCommon shader files. The functions determining
tessellation levels are now all named OsdGetTessLevel*().
2015-05-02 00:52:37 +00:00
|
|
|
|
|
|
|
gl_TessLevelOuter[0] = tessLevelOuter[0];
|
|
|
|
gl_TessLevelOuter[1] = tessLevelOuter[1];
|
|
|
|
gl_TessLevelOuter[2] = tessLevelOuter[2];
|
|
|
|
gl_TessLevelOuter[3] = tessLevelOuter[3];
|
|
|
|
|
|
|
|
gl_TessLevelInner[0] = tessLevelInner[0];
|
|
|
|
gl_TessLevelInner[1] = tessLevelInner[1];
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
}
|
2013-07-01 18:47:21 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------
|
|
|
|
// Patches.TessEvalGregory
|
|
|
|
//----------------------------------------------------------
|
2013-06-24 19:03:57 +00:00
|
|
|
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_SHADER
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
layout(quads) in;
|
2015-05-26 23:35:06 +00:00
|
|
|
layout(OSD_SPACING) in;
|
2013-06-27 20:34:25 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
in block {
|
2015-05-26 23:35:06 +00:00
|
|
|
OsdPerPatchVertexGregory v;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_DECLARE
|
2013-06-10 19:53:04 +00:00
|
|
|
} inpt[];
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
out block {
|
|
|
|
OutputVertex v;
|
2013-06-28 21:05:47 +00:00
|
|
|
OSD_USER_VARYING_DECLARE
|
2013-06-10 19:53:04 +00:00
|
|
|
} outpt;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2015-05-26 23:35:06 +00:00
|
|
|
vec3 P = vec3(0), dPu = vec3(0), dPv = vec3(0);
|
|
|
|
vec3 N = vec3(0), dNu = vec3(0), dNv = vec3(0);
|
|
|
|
|
|
|
|
vec3 cv[20];
|
|
|
|
cv[0] = inpt[0].v.P;
|
|
|
|
cv[1] = inpt[0].v.Ep;
|
|
|
|
cv[2] = inpt[0].v.Em;
|
|
|
|
cv[3] = inpt[0].v.Fp;
|
|
|
|
cv[4] = inpt[0].v.Fm;
|
|
|
|
|
|
|
|
cv[5] = inpt[1].v.P;
|
|
|
|
cv[6] = inpt[1].v.Ep;
|
|
|
|
cv[7] = inpt[1].v.Em;
|
|
|
|
cv[8] = inpt[1].v.Fp;
|
|
|
|
cv[9] = inpt[1].v.Fm;
|
|
|
|
|
|
|
|
cv[10] = inpt[2].v.P;
|
|
|
|
cv[11] = inpt[2].v.Ep;
|
|
|
|
cv[12] = inpt[2].v.Em;
|
|
|
|
cv[13] = inpt[2].v.Fp;
|
|
|
|
cv[14] = inpt[2].v.Fm;
|
|
|
|
|
|
|
|
cv[15] = inpt[3].v.P;
|
|
|
|
cv[16] = inpt[3].v.Ep;
|
|
|
|
cv[17] = inpt[3].v.Em;
|
|
|
|
cv[18] = inpt[3].v.Fp;
|
|
|
|
cv[19] = inpt[3].v.Fm;
|
2013-09-21 01:23:28 +00:00
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
vec2 UV = gl_TessCoord.xy;
|
|
|
|
ivec3 patchParam = inpt[0].v.patchParam;
|
|
|
|
OsdEvalPatchGregory(patchParam, UV, cv, P, dPu, dPv, N, dNu, dNv);
|
|
|
|
|
|
|
|
// all code below here is client code
|
|
|
|
outpt.v.position = OsdModelViewMatrix() * vec4(P, 1.0f);
|
|
|
|
outpt.v.normal = (OsdModelViewMatrix() * vec4(N, 0.0f)).xyz;
|
|
|
|
outpt.v.tangent = (OsdModelViewMatrix() * vec4(dPu, 0.0f)).xyz;
|
|
|
|
outpt.v.bitangent = (OsdModelViewMatrix() * vec4(dPv, 0.0f)).xyz;
|
2013-09-21 01:23:28 +00:00
|
|
|
#ifdef OSD_COMPUTE_NORMAL_DERIVATIVES
|
2015-05-26 23:35:06 +00:00
|
|
|
outpt.v.Nu = dNu;
|
|
|
|
outpt.v.Nv = dNv;
|
2013-09-21 01:23:28 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-26 23:35:06 +00:00
|
|
|
outpt.v.tessCoord = UV;
|
|
|
|
outpt.v.patchCoord = OsdInterpolatePatchCoord(UV, patchParam);
|
2015-05-15 18:03:31 +00:00
|
|
|
|
|
|
|
OSD_USER_VARYING_PER_EVAL_POINT(UV, 0, 1, 3, 2);
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
OSD_DISPLACEMENT_CALLBACK;
|
|
|
|
|
2015-05-21 14:25:04 +00:00
|
|
|
gl_Position = OsdProjectionMatrix() * outpt.v.position;
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|