mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-27 05:50:05 +00:00
Potential fix for the shader compilation problem.
Replace face varying computation functions with equivalent macros to avoid gl_PrimitiveID undefined error.
This commit is contained in:
parent
3279bb3950
commit
de3e706379
@ -160,7 +160,8 @@ void emit(int index, vec3 normal)
|
||||
#else
|
||||
vec2 st = inpt[index].v.tessCoord;
|
||||
#endif
|
||||
vec2 uv = ComputeFaceVarying2(/*fvarOffset=*/0, st);
|
||||
vec2 uv;
|
||||
OSD_COMPUTE_FACE_VARYING_2(uv, /*fvarOffset=*/0, st);
|
||||
outpt.color = vec3(uv.s, uv.t, 0);
|
||||
#endif
|
||||
|
||||
|
@ -248,68 +248,63 @@ uniform samplerBuffer g_fvarDataBuffer;
|
||||
#endif
|
||||
|
||||
// XXX: quad only for now
|
||||
float ComputeFaceVarying1(int fvarOffset, vec2 tessCoord)
|
||||
{
|
||||
float v[4];
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
v[i] = texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset).s;
|
||||
#define OSD_COMPUTE_FACE_VARYING_1(result, fvarOffset, tessCoord) \
|
||||
{ \
|
||||
float v[4]; \
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4; \
|
||||
for (int i = 0; i < 4; ++i) { \
|
||||
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
||||
v[i] = texelFetch(g_fvarDataBuffer, index).s \
|
||||
} \
|
||||
result = mix(mix(v[0], v[1], tessCoord.s), \
|
||||
mix(v[3], v[2], tessCoord.s), \
|
||||
tessCoord.t); \
|
||||
}
|
||||
return mix(mix(v[0], v[1], tessCoord.s),
|
||||
mix(v[3], v[2], tessCoord.s),
|
||||
tessCoord.t);
|
||||
}
|
||||
vec2 ComputeFaceVarying2(int fvarOffset, vec2 tessCoord)
|
||||
{
|
||||
vec2 v[4];
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
v[i] = vec2(texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 1).s);
|
||||
}
|
||||
return mix(mix(v[0], v[1], tessCoord.s),
|
||||
mix(v[3], v[2], tessCoord.s),
|
||||
tessCoord.t);
|
||||
}
|
||||
|
||||
vec3 ComputeFaceVarying3(int fvarOffset, vec2 tessCoord)
|
||||
{
|
||||
vec3 v[4];
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
v[i] = vec3(texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 1).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 2).s);
|
||||
#define OSD_COMPUTE_FACE_VARYING_2(result, fvarOffset, tessCoord) \
|
||||
{ \
|
||||
vec2 v[4]; \
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4; \
|
||||
for (int i = 0; i < 4; ++i) { \
|
||||
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
||||
v[i] = vec2(texelFetch(g_fvarDataBuffer, index).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 1).s); \
|
||||
} \
|
||||
result = mix(mix(v[0], v[1], tessCoord.s), \
|
||||
mix(v[3], v[2], tessCoord.s), \
|
||||
tessCoord.t); \
|
||||
}
|
||||
return mix(mix(v[0], v[1], tessCoord.s),
|
||||
mix(v[3], v[2], tessCoord.s),
|
||||
tessCoord.t);
|
||||
}
|
||||
|
||||
vec4 ComputeFaceVarying4(int fvarOffset, vec2 tessCoord)
|
||||
{
|
||||
vec4 v[4];
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
v[i] = vec4(texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 1).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 2).s,
|
||||
texelFetch(g_fvarDataBuffer,
|
||||
(primOffset+i)*OSD_FVAR_WIDTH + fvarOffset + 3).s);
|
||||
#define OSD_COMPUTE_FACE_VARYING_3(result, fvarOffset, tessCoord) \
|
||||
{ \
|
||||
vec3 v[4]; \
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4; \
|
||||
for (int i = 0; i < 4; ++i) { \
|
||||
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
||||
v[i] = vec3(texelFetch(g_fvarDataBuffer, index).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 1).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 2).s); \
|
||||
} \
|
||||
result = mix(mix(v[0], v[1], tessCoord.s), \
|
||||
mix(v[3], v[2], tessCoord.s), \
|
||||
tessCoord.t); \
|
||||
}
|
||||
|
||||
#define OSD_COMPUTE_FACE_VARYING_4(result, fvarOffset, tessCoord) \
|
||||
{ \
|
||||
vec4 v[4]; \
|
||||
int primOffset = (gl_PrimitiveID + LevelBase) * 4; \
|
||||
for (int i = 0; i < 4; ++i) { \
|
||||
int index = (primOffset+i)*OSD_FVAR_WIDTH + fvarOffset; \
|
||||
v[i] = vec3(texelFetch(g_fvarDataBuffer, index).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 1).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 2).s, \
|
||||
texelFetch(g_fvarDataBuffer, index + 3).s); \
|
||||
} \
|
||||
result = mix(mix(v[0], v[1], tessCoord.s), \
|
||||
mix(v[3], v[2], tessCoord.s), \
|
||||
tessCoord.t); \
|
||||
}
|
||||
return mix(mix(v[0], v[1], tessCoord.s),
|
||||
mix(v[3], v[2], tessCoord.s),
|
||||
tessCoord.t);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// patch culling
|
||||
|
Loading…
Reference in New Issue
Block a user