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-09-26 19:04:57 +00:00
|
|
|
|
2013-12-03 23:59:38 +00:00
|
|
|
//
|
|
|
|
// typical shader composition ordering (see glDrawRegistry:_CompileShader)
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// - glsl version string (#version 430)
|
|
|
|
//
|
|
|
|
// - common defines (#define OSD_ENABLE_PATCH_CULL, ...)
|
|
|
|
// - source defines (#define VERTEX_SHADER, ...)
|
|
|
|
//
|
|
|
|
// - osd headers (glslPatchCommon: varying structs,
|
|
|
|
// glslPtexCommon: ptex functions)
|
|
|
|
// - client header (Osd*Matrix(), displacement callback, ...)
|
|
|
|
//
|
|
|
|
// - osd shader source (glslPatchBSpline, glslPatchGregory, ...)
|
|
|
|
// or
|
|
|
|
// client shader source (vertex/geometry/fragment shader)
|
|
|
|
//
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
//----------------------------------------------------------
|
|
|
|
// Patches.Common
|
|
|
|
//----------------------------------------------------------
|
|
|
|
|
2013-06-28 21:05:47 +00:00
|
|
|
#ifndef OSD_USER_VARYING_DECLARE
|
|
|
|
#define OSD_USER_VARYING_DECLARE
|
|
|
|
// type var;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OSD_USER_VARYING_ATTRIBUTE_DECLARE
|
|
|
|
#define OSD_USER_VARYING_ATTRIBUTE_DECLARE
|
|
|
|
// layout(location = loc) in type var;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OSD_USER_VARYING_PER_VERTEX
|
|
|
|
#define OSD_USER_VARYING_PER_VERTEX()
|
|
|
|
// output.var = var;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OSD_USER_VARYING_PER_CONTROL_POINT
|
|
|
|
#define OSD_USER_VARYING_PER_CONTROL_POINT(ID_OUT, ID_IN)
|
|
|
|
// output[ID_OUT].var = input[ID_IN].var
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef OSD_USER_VARYING_PER_EVAL_POINT
|
|
|
|
#define OSD_USER_VARYING_PER_EVAL_POINT(UV, a, b, c, d)
|
|
|
|
// output.var =
|
|
|
|
// mix(mix(input[a].var, input[b].var, UV.x),
|
|
|
|
// mix(input[c].var, input[d].var, UV.x), UV.y)
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif
|
|
|
|
|
2013-06-24 19:03:57 +00:00
|
|
|
#ifndef OSD_TRANSITION_ROTATE
|
|
|
|
#define OSD_TRANSITION_ROTATE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined OSD_PATCH_BOUNDARY
|
|
|
|
#define OSD_PATCH_INPUT_SIZE 12
|
|
|
|
#elif defined OSD_PATCH_CORNER
|
|
|
|
#define OSD_PATCH_INPUT_SIZE 9
|
|
|
|
#else
|
|
|
|
#define OSD_PATCH_INPUT_SIZE 16
|
2013-06-10 19:20:08 +00:00
|
|
|
#endif
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#define M_PI 3.14159265359f
|
|
|
|
|
2013-07-19 02:44:54 +00:00
|
|
|
#if __VERSION__ < 420
|
|
|
|
#define centroid
|
|
|
|
#endif
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
struct ControlVertex {
|
|
|
|
vec4 position;
|
2012-12-17 18:26:14 +00:00
|
|
|
centroid vec4 patchCoord; // u, v, level, faceID
|
2012-12-11 01:15:13 +00:00
|
|
|
ivec4 ptexInfo; // U offset, V offset, 2^ptexlevel', rotation
|
2015-04-08 01:34:05 +00:00
|
|
|
#ifdef OSD_ENABLE_PATCH_CULL
|
2012-12-11 01:15:13 +00:00
|
|
|
ivec3 clipFlag;
|
2015-04-08 01:34:05 +00:00
|
|
|
#endif
|
2012-12-11 01:15:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OutputVertex {
|
|
|
|
vec4 position;
|
|
|
|
vec3 normal;
|
2012-12-17 18:26:14 +00:00
|
|
|
centroid vec4 patchCoord; // u, v, level, faceID
|
2013-06-04 18:02:27 +00:00
|
|
|
centroid vec2 tessCoord; // tesscoord.st
|
2013-09-21 01:23:28 +00:00
|
|
|
vec3 tangent;
|
|
|
|
vec3 bitangent;
|
|
|
|
#if defined OSD_COMPUTE_NORMAL_DERIVATIVES
|
|
|
|
vec3 Nu;
|
|
|
|
vec3 Nv;
|
|
|
|
#endif
|
2012-12-11 01:15:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct GregControlVertex {
|
|
|
|
vec3 position;
|
|
|
|
vec3 hullPosition;
|
|
|
|
ivec3 clipFlag;
|
|
|
|
int valence;
|
|
|
|
vec3 e0;
|
|
|
|
vec3 e1;
|
|
|
|
uint zerothNeighbor;
|
|
|
|
vec3 org;
|
|
|
|
#if OSD_MAX_VALENCE > 0
|
|
|
|
vec3 r[OSD_MAX_VALENCE];
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GregEvalVertex {
|
|
|
|
vec3 position;
|
|
|
|
vec3 Ep;
|
|
|
|
vec3 Em;
|
|
|
|
vec3 Fp;
|
|
|
|
vec3 Fm;
|
2012-12-17 18:26:14 +00:00
|
|
|
centroid vec4 patchCoord;
|
2012-12-11 01:15:13 +00:00
|
|
|
ivec4 ptexInfo;
|
|
|
|
};
|
|
|
|
|
2013-12-03 23:59:38 +00:00
|
|
|
// osd shaders need following functions defined
|
|
|
|
mat4 OsdModelViewMatrix();
|
|
|
|
mat4 OsdProjectionMatrix();
|
|
|
|
mat4 OsdModelViewProjectionMatrix();
|
|
|
|
float OsdTessLevel();
|
|
|
|
int OsdGregoryQuadOffsetBase();
|
|
|
|
int OsdPrimitiveIdBase();
|
2014-05-09 00:20:54 +00:00
|
|
|
int OsdBaseVertex();
|
2013-03-08 01:50:15 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
float GetTessLevel(int patchLevel)
|
|
|
|
{
|
2013-06-10 19:01:43 +00:00
|
|
|
#ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION
|
2013-12-03 23:59:38 +00:00
|
|
|
return OsdTessLevel();
|
2012-12-11 01:15:13 +00:00
|
|
|
#else
|
2013-12-03 23:59:38 +00:00
|
|
|
return OsdTessLevel() / pow(2, patchLevel-1);
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-12-03 23:59:38 +00:00
|
|
|
#ifndef GetPrimitiveID
|
|
|
|
#define GetPrimitiveID() (gl_PrimitiveID + OsdPrimitiveIdBase())
|
|
|
|
#endif
|
|
|
|
|
2013-01-05 03:15:24 +00:00
|
|
|
float GetPostProjectionSphereExtent(vec3 center, float diameter)
|
|
|
|
{
|
2013-12-03 23:59:38 +00:00
|
|
|
vec4 p = OsdProjectionMatrix() * vec4(center, 1.0);
|
|
|
|
return abs(diameter * OsdProjectionMatrix()[1][1] / p.w);
|
2013-01-05 03:15:24 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 19:03:57 +00:00
|
|
|
float TessAdaptive(vec3 p0, vec3 p1)
|
2012-12-11 01:15:13 +00:00
|
|
|
{
|
|
|
|
// Adaptive factor can be any computation that depends only on arg values.
|
2013-01-05 03:15:24 +00:00
|
|
|
// Project the diameter of the edge's bounding sphere instead of using the
|
|
|
|
// length of the projected edge itself to avoid problems near silhouettes.
|
|
|
|
vec3 center = (p0 + p1) / 2.0;
|
|
|
|
float diameter = distance(p0, p1);
|
2013-12-03 23:59:38 +00:00
|
|
|
return max(1.0, OsdTessLevel() * GetPostProjectionSphereExtent(center, diameter));
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef OSD_DISPLACEMENT_CALLBACK
|
|
|
|
#define OSD_DISPLACEMENT_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2013-07-03 19:08:10 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ptex coordinates
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2013-07-18 19:57:26 +00:00
|
|
|
uniform isamplerBuffer OsdPatchParamBuffer;
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-04-17 14:42:53 +00:00
|
|
|
#define GetPatchParam() \
|
|
|
|
(texelFetch(OsdPatchParamBuffer, GetPrimitiveID()).y)
|
|
|
|
|
2013-06-10 19:20:08 +00:00
|
|
|
#define GetPatchLevel() \
|
2013-12-03 23:59:38 +00:00
|
|
|
(texelFetch(OsdPatchParamBuffer, GetPrimitiveID()).y & 0xf)
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-04-17 14:42:53 +00:00
|
|
|
#define GetSharpness() \
|
2014-10-13 15:52:09 +00:00
|
|
|
(intBitsToFloat(texelFetch(OsdPatchParamBuffer, GetPrimitiveID()).z))
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#define OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER \
|
|
|
|
{ \
|
2013-07-18 19:57:26 +00:00
|
|
|
ivec2 ptexIndex = texelFetch(OsdPatchParamBuffer, \
|
2013-12-03 23:59:38 +00:00
|
|
|
GetPrimitiveID()).xy; \
|
2013-03-23 01:20:50 +00:00
|
|
|
int faceID = ptexIndex.x; \
|
2015-04-17 14:42:53 +00:00
|
|
|
int lv = 1 << ((ptexIndex.y & 0x7) - ((ptexIndex.y >> 3) & 1)); \
|
|
|
|
int u = (ptexIndex.y >> 22) & 0x3ff; \
|
|
|
|
int v = (ptexIndex.y >> 12) & 0x3ff; \
|
2013-06-10 19:53:04 +00:00
|
|
|
outpt[ID].v.patchCoord.w = faceID+0.5; \
|
2015-04-17 14:42:53 +00:00
|
|
|
outpt[ID].v.ptexInfo = ivec4(u, v, lv, 0); \
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER \
|
|
|
|
{ \
|
2013-06-10 19:53:04 +00:00
|
|
|
vec2 uv = outpt.v.patchCoord.xy; \
|
|
|
|
ivec2 p = inpt[0].v.ptexInfo.xy; \
|
|
|
|
int lv = inpt[0].v.ptexInfo.z; \
|
|
|
|
outpt.v.tessCoord.xy = uv; \
|
2015-04-17 14:42:53 +00:00
|
|
|
outpt.v.patchCoord.xy = (uv * vec2(1.0)/lv) + vec2(p.x, p.y)/lv;\
|
2012-12-11 01:15:13 +00:00
|
|
|
}
|
|
|
|
|
2013-07-03 19:08:10 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// face varyings
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2013-07-18 19:57:26 +00:00
|
|
|
uniform samplerBuffer OsdFVarDataBuffer;
|
2013-07-03 19:08:10 +00:00
|
|
|
|
|
|
|
#ifndef OSD_FVAR_WIDTH
|
|
|
|
#define OSD_FVAR_WIDTH 0
|
|
|
|
#endif
|
|
|
|
|
2013-09-23 19:52:27 +00:00
|
|
|
// ------ extract from quads (catmark, bilinear) ---------
|
|
|
|
// XXX: only linear interpolation is supported
|
|
|
|
|
2013-07-08 23:16:28 +00:00
|
|
|
#define OSD_COMPUTE_FACE_VARYING_1(result, fvarOffset, tessCoord) \
|
|
|
|
{ \
|
|
|
|
float v[4]; \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 4; \
|
2013-07-08 23:16:28 +00:00
|
|
|
for (int i = 0; i < 4; ++i) { \
|
|
|
|
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
2013-07-18 19:57:26 +00:00
|
|
|
v[i] = texelFetch(OsdFVarDataBuffer, index).s \
|
2013-07-08 23:16:28 +00:00
|
|
|
} \
|
|
|
|
result = mix(mix(v[0], v[1], tessCoord.s), \
|
|
|
|
mix(v[3], v[2], tessCoord.s), \
|
|
|
|
tessCoord.t); \
|
2013-07-03 19:08:10 +00:00
|
|
|
}
|
2013-07-08 23:16:28 +00:00
|
|
|
|
|
|
|
#define OSD_COMPUTE_FACE_VARYING_2(result, fvarOffset, tessCoord) \
|
|
|
|
{ \
|
|
|
|
vec2 v[4]; \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 4; \
|
2013-07-08 23:16:28 +00:00
|
|
|
for (int i = 0; i < 4; ++i) { \
|
|
|
|
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
2013-07-18 19:57:26 +00:00
|
|
|
v[i] = vec2(texelFetch(OsdFVarDataBuffer, index).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s); \
|
2013-07-08 23:16:28 +00:00
|
|
|
} \
|
|
|
|
result = mix(mix(v[0], v[1], tessCoord.s), \
|
|
|
|
mix(v[3], v[2], tessCoord.s), \
|
|
|
|
tessCoord.t); \
|
2013-07-03 19:08:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 23:16:28 +00:00
|
|
|
#define OSD_COMPUTE_FACE_VARYING_3(result, fvarOffset, tessCoord) \
|
|
|
|
{ \
|
|
|
|
vec3 v[4]; \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 4; \
|
2013-07-08 23:16:28 +00:00
|
|
|
for (int i = 0; i < 4; ++i) { \
|
|
|
|
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
2013-07-18 19:57:26 +00:00
|
|
|
v[i] = vec3(texelFetch(OsdFVarDataBuffer, index).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 2).s); \
|
2013-07-08 23:16:28 +00:00
|
|
|
} \
|
|
|
|
result = mix(mix(v[0], v[1], tessCoord.s), \
|
|
|
|
mix(v[3], v[2], tessCoord.s), \
|
|
|
|
tessCoord.t); \
|
2013-07-03 19:08:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-08 23:16:28 +00:00
|
|
|
#define OSD_COMPUTE_FACE_VARYING_4(result, fvarOffset, tessCoord) \
|
|
|
|
{ \
|
|
|
|
vec4 v[4]; \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 4; \
|
2013-07-08 23:16:28 +00:00
|
|
|
for (int i = 0; i < 4; ++i) { \
|
|
|
|
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
2013-09-23 19:52:27 +00:00
|
|
|
v[i] = vec4(texelFetch(OsdFVarDataBuffer, index).s, \
|
2013-07-18 19:57:26 +00:00
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 2).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 3).s); \
|
2013-07-08 23:16:28 +00:00
|
|
|
} \
|
|
|
|
result = mix(mix(v[0], v[1], tessCoord.s), \
|
|
|
|
mix(v[3], v[2], tessCoord.s), \
|
|
|
|
tessCoord.t); \
|
2013-07-03 19:08:10 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 19:52:27 +00:00
|
|
|
// ------ extract from triangles (loop) ---------
|
|
|
|
// XXX: no interpolation supproted
|
|
|
|
|
|
|
|
#define OSD_COMPUTE_FACE_VARYING_TRI_1(result, fvarOffset, triVert) \
|
|
|
|
{ \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 3; \
|
2013-09-23 19:52:27 +00:00
|
|
|
int index = (primOffset+triVert)*OSD_FVAR_WIDTH + fvarOffset; \
|
|
|
|
result = texelFetch(OsdFVarDataBuffer, index).s; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OSD_COMPUTE_FACE_VARYING_TRI_2(result, fvarOffset, triVert) \
|
|
|
|
{ \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 3; \
|
2013-09-23 19:52:27 +00:00
|
|
|
int index = (primOffset+triVert)*OSD_FVAR_WIDTH + fvarOffset; \
|
|
|
|
result = vec2(texelFetch(OsdFVarDataBuffer, index).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OSD_COMPUTE_FACE_VARYING_TRI_3(result, fvarOffset, triVert) \
|
|
|
|
{ \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 3; \
|
2013-09-23 19:52:27 +00:00
|
|
|
int index = (primOffset+triVert)*OSD_FVAR_WIDTH + fvarOffset; \
|
|
|
|
result = vec3(texelFetch(OsdFVarDataBuffer, index).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 2).s); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OSD_COMPUTE_FACE_VARYING_TRI_4(result, fvarOffset, triVert) \
|
|
|
|
{ \
|
2013-12-03 23:59:38 +00:00
|
|
|
int primOffset = GetPrimitiveID() * 3; \
|
2013-09-23 19:52:27 +00:00
|
|
|
int index = (primOffset+triVert)*OSD_FVAR_WIDTH + fvarOffset; \
|
|
|
|
result = vec4(texelFetch(OsdFVarDataBuffer, index).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 1).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 2).s, \
|
|
|
|
texelFetch(OsdFVarDataBuffer, index + 3).s); \
|
|
|
|
}
|
|
|
|
|
2013-07-03 19:08:10 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// patch culling
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifdef OSD_ENABLE_PATCH_CULL
|
|
|
|
|
|
|
|
#define OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(P) \
|
2013-12-03 23:59:38 +00:00
|
|
|
vec4 clipPos = OsdModelViewProjectionMatrix() * P; \
|
2012-12-11 01:15:13 +00:00
|
|
|
bvec3 clip0 = lessThan(clipPos.xyz, vec3(clipPos.w)); \
|
|
|
|
bvec3 clip1 = greaterThan(clipPos.xyz, -vec3(clipPos.w)); \
|
2013-06-10 19:53:04 +00:00
|
|
|
outpt.v.clipFlag = ivec3(clip0) + 2*ivec3(clip1); \
|
2012-12-11 01:15:13 +00:00
|
|
|
|
|
|
|
#define OSD_PATCH_CULL(N) \
|
|
|
|
ivec3 clipFlag = ivec3(0); \
|
|
|
|
for(int i = 0; i < N; ++i) { \
|
2013-06-10 19:53:04 +00:00
|
|
|
clipFlag |= inpt[i].v.clipFlag; \
|
2012-12-11 01:15:13 +00:00
|
|
|
} \
|
|
|
|
if (clipFlag != ivec3(3) ) { \
|
|
|
|
gl_TessLevelInner[0] = 0; \
|
|
|
|
gl_TessLevelInner[1] = 0; \
|
|
|
|
gl_TessLevelOuter[0] = 0; \
|
|
|
|
gl_TessLevelOuter[1] = 0; \
|
|
|
|
gl_TessLevelOuter[2] = 0; \
|
|
|
|
gl_TessLevelOuter[3] = 0; \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(P)
|
|
|
|
#define OSD_PATCH_CULL(N)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void
|
|
|
|
Univar4x4(in float u, out float B[4], out float D[4])
|
|
|
|
{
|
|
|
|
float t = u;
|
|
|
|
float s = 1.0f - u;
|
|
|
|
|
|
|
|
float A0 = s * s;
|
|
|
|
float A1 = 2 * s * t;
|
|
|
|
float A2 = t * t;
|
|
|
|
|
|
|
|
B[0] = s * A0;
|
|
|
|
B[1] = t * A0 + s * A1;
|
|
|
|
B[2] = t * A1 + s * A2;
|
|
|
|
B[3] = t * A2;
|
|
|
|
|
|
|
|
D[0] = - A0;
|
|
|
|
D[1] = A0 - A1;
|
|
|
|
D[2] = A1 - A2;
|
|
|
|
D[3] = A2;
|
|
|
|
}
|
2013-09-21 01:23:28 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Univar4x4(in float u, out float B[4], out float D[4], out float C[4])
|
|
|
|
{
|
|
|
|
float t = u;
|
|
|
|
float s = 1.0f - u;
|
|
|
|
|
|
|
|
float A0 = s * s;
|
|
|
|
float A1 = 2 * s * t;
|
|
|
|
float A2 = t * t;
|
|
|
|
|
|
|
|
B[0] = s * A0;
|
|
|
|
B[1] = t * A0 + s * A1;
|
|
|
|
B[2] = t * A1 + s * A2;
|
|
|
|
B[3] = t * A2;
|
|
|
|
|
|
|
|
D[0] = - A0;
|
|
|
|
D[1] = A0 - A1;
|
|
|
|
D[2] = A1 - A2;
|
|
|
|
D[3] = A2;
|
|
|
|
|
|
|
|
A0 = - s;
|
|
|
|
A1 = s - t;
|
|
|
|
A2 = t;
|
|
|
|
|
|
|
|
C[0] = - A0;
|
|
|
|
C[1] = A0 - A1;
|
|
|
|
C[2] = A1 - A2;
|
|
|
|
C[3] = A2;
|
|
|
|
}
|