Continued bicubic patch shader cleanup

Removed superfluous vertex and fragment/pixel shaders
This commit is contained in:
David G Yu 2013-06-27 17:26:22 -07:00
parent b5d182b7be
commit 8fae6511f7
9 changed files with 40 additions and 271 deletions

View File

@ -107,12 +107,7 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
switch (desc.GetType()) {
case FarPatchTables::QUADS:
case FarPatchTables::TRIANGLES:
sconfig->vertexShader.source = bsplineShaderSource;
sconfig->vertexShader.target = "vs_5_0";
sconfig->vertexShader.entry = "vs_main";
sconfig->pixelShader.source = bsplineShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
// do nothing
break;
case FarPatchTables::REGULAR:
sconfig->vertexShader.source = bsplineShaderSource;
@ -124,9 +119,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.source = bsplineShaderSource;
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->pixelShader.source = bsplineShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
break;
case FarPatchTables::BOUNDARY:
sconfig->vertexShader.source = bsplineShaderSource;
@ -139,9 +131,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.source = bsplineShaderSource;
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->pixelShader.source = bsplineShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
break;
case FarPatchTables::CORNER:
sconfig->vertexShader.source = bsplineShaderSource;
@ -154,9 +143,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.source = bsplineShaderSource;
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->pixelShader.source = bsplineShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
break;
case FarPatchTables::GREGORY:
sconfig->vertexShader.source = gregoryShaderSource;
@ -168,9 +154,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.source = gregoryShaderSource;
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->pixelShader.source = gregoryShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
break;
case FarPatchTables::GREGORY_BOUNDARY:
sconfig->vertexShader.source = boundaryGregoryShaderSource;
@ -182,9 +165,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.source = boundaryGregoryShaderSource;
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->pixelShader.source = boundaryGregoryShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
break;
default:
delete sconfig;
@ -205,9 +185,6 @@ OsdD3D11DrawRegistryBase::_CreateDrawSourceConfig(
sconfig->domainShader.target = "ds_5_0";
sconfig->domainShader.entry = "ds_main_patches";
sconfig->domainShader.AddDefine("OSD_PATCH_TRANSITION");
sconfig->pixelShader.source = bsplineShaderSource;
sconfig->pixelShader.target = "ps_5_0";
sconfig->pixelShader.entry = "ps_main";
int pattern = desc.GetPattern() - 1;
int rotation = desc.GetRotation();

View File

@ -104,12 +104,7 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
switch (desc.GetType()) {
case FarPatchTables::QUADS:
case FarPatchTables::TRIANGLES:
sconfig->vertexShader.source = bsplineShaderSource;
sconfig->vertexShader.version = "#version 410\n";
sconfig->vertexShader.AddDefine("OSD_VERTEX_SHADER");
sconfig->fragmentShader.source = bsplineShaderSource;
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
sconfig->fragmentShader.version = "#version 410\n";
// do nothing
break;
case FarPatchTables::REGULAR:
sconfig->vertexShader.source = bsplineShaderSource;
@ -121,9 +116,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.source = bsplineShaderSource;
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_BSPLINE_SHADER");
sconfig->fragmentShader.source = bsplineShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
break;
case FarPatchTables::BOUNDARY:
sconfig->vertexShader.source = bsplineShaderSource;
@ -136,9 +128,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.source = bsplineShaderSource;
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_BSPLINE_SHADER");
sconfig->fragmentShader.source = bsplineShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
break;
case FarPatchTables::CORNER:
sconfig->vertexShader.source = bsplineShaderSource;
@ -151,9 +140,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.source = bsplineShaderSource;
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_BSPLINE_SHADER");
sconfig->fragmentShader.source = bsplineShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
break;
case FarPatchTables::GREGORY:
sconfig->vertexShader.source = gregoryShaderSource;
@ -165,9 +151,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.source = gregoryShaderSource;
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_GREGORY_SHADER");
sconfig->fragmentShader.source = gregoryShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
break;
case FarPatchTables::GREGORY_BOUNDARY:
sconfig->vertexShader.source = boundaryGregoryShaderSource;
@ -179,9 +162,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.source = boundaryGregoryShaderSource;
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_BOUNDARY_GREGORY_SHADER");
sconfig->fragmentShader.source = boundaryGregoryShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
break;
default:
// error
@ -203,9 +183,6 @@ OsdGLDrawRegistryBase::_CreateDrawSourceConfig(OsdDrawContext::PatchDescriptor c
sconfig->tessEvalShader.version = "#version 410\n";
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TESS_EVAL_BSPLINE_SHADER");
sconfig->tessEvalShader.AddDefine("OSD_PATCH_TRANSITION");
sconfig->fragmentShader.source = bsplineShaderSource;
sconfig->fragmentShader.version = "#version 410\n";
sconfig->fragmentShader.AddDefine("OSD_FRAGMENT_SHADER");
int pattern = desc.GetPattern() - 1;
int rotation = desc.GetRotation();

View File

@ -242,10 +242,42 @@ void main()
vec2 UV = gl_TessCoord.xy;
#endif
vec3 WorldPos, Tangent, BiTangent;
vec3 cp[16];
for(int i = 0; i < 16; ++i) cp[i] = inpt[i].v.position.xyz;
EvalBSpline(UV, cp, WorldPos, Tangent, BiTangent);
float B[4], D[4];
Univar4x4(UV.x, B, D);
vec3 BUCP[4], DUCP[4];
for (int i=0; i<4; ++i) {
BUCP[i] = vec3(0);
DUCP[i] = vec3(0);
for (int j=0; j<4; ++j) {
#if OSD_TRANSITION_ROTATE == 1
vec3 A = inpt[4*(3-j) + i].v.position.xyz;
#elif OSD_TRANSITION_ROTATE == 2
vec3 A = inpt[4*(3-i) + (3-j)].v.position.xyz;
#elif OSD_TRANSITION_ROTATE == 3
vec3 A = inpt[4*j + (3-i)].v.position.xyz;
#else // OSD_TRANSITION_ROTATE == 0, or non-transition patch
vec3 A = inpt[4*i + j].v.position.xyz;
#endif
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
}
vec3 WorldPos = vec3(0);
vec3 Tangent = vec3(0);
vec3 BiTangent = vec3(0);
Univar4x4(UV.y, B, D);
for (int k=0; k<4; ++k) {
WorldPos += B[k] * BUCP[k];
Tangent += B[k] * DUCP[k];
BiTangent += D[k] * BUCP[k];
}
vec3 normal = normalize(cross(Tangent, BiTangent));
@ -275,37 +307,3 @@ void main()
}
#endif
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
#ifdef OSD_VERTEX_SHADER
layout (location=0) in vec4 position;
layout (location=1) in vec3 normal;
layout (location=2) in vec4 color;
out block {
OutputVertex v;
} outpt;
void main() {
gl_Position = ModelViewProjectionMatrix * position;
outpt.v.color = color;
}
#endif
//----------------------------------------------------------
// Patches.FragmentColor
//----------------------------------------------------------
#ifdef OSD_FRAGMENT_SHADER
in block {
OutputVertex v;
} inpt;
void main() {
gl_FragColor = inpt.v.color;
}
#endif

View File

@ -563,37 +563,3 @@ void main()
}
#endif
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
#ifdef OSD_VERTEX_SHADER
layout (location=0) in vec4 position;
layout (location=1) in vec3 normal;
layout (location=2) in vec4 color;
out block {
OutputVertex v;
} outpt;
void main() {
gl_Position = ModelViewProjectionMatrix * position;
outpt.v.color = color;
}
#endif
//----------------------------------------------------------
// Patches.FragmentColor
//----------------------------------------------------------
#ifdef OSD_FRAGMENT_SHADER
in block {
OutputVertex v;
} inpt;
void main() {
gl_FragColor = inpt.v.color;
}
#endif

View File

@ -299,46 +299,3 @@ Univar4x4(in float u, out float B[4], out float D[4])
D[2] = A1 - A2;
D[3] = A2;
}
void EvalBSpline(vec2 uv, vec3 cp[16],
out vec3 position,
out vec3 utangent,
out vec3 vtangent)
{
float B[4], D[4];
Univar4x4(uv.x, B, D);
vec3 BUCP[4], DUCP[4];
for (int i=0; i<4; ++i) {
BUCP[i] = vec3(0);
DUCP[i] = vec3(0);
for (int j=0; j<4; ++j) {
#if OSD_TRANSITION_ROTATE == 1
vec3 A = cp[4*(3-j) + i];
#elif OSD_TRANSITION_ROTATE == 2
vec3 A = cp[4*(3-i) + (3-j)];
#elif OSD_TRANSITION_ROTATE == 3
vec3 A = cp[4*j + (3-i)];
#else // OSD_TRANNSITION_ROTATE == 0, or non-transition patch
vec3 A = cp[4*i + j];
#endif
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
}
position = vec3(0);
utangent = vec3(0);
vtangent = vec3(0);
Univar4x4(uv.y, B, D);
for (int i=0; i<4; ++i) {
position += B[i] * BUCP[i];
utangent += B[i] * DUCP[i];
vtangent += D[i] * BUCP[i];
}
}

View File

@ -398,37 +398,3 @@ void main()
}
#endif
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
#ifdef OSD_VERTEX_SHADER
layout (location=0) in vec4 position;
layout (location=1) in vec3 normal;
layout (location=2) in vec4 color;
out block {
OutputVertex v;
} outpt;
void main() {
gl_Position = ModelViewProjectionMatrix * position;
outpt.v.color = color;
}
#endif
//----------------------------------------------------------
// Patches.FragmentColor
//----------------------------------------------------------
#ifdef OSD_FRAGMENT_SHADER
in block {
OutputVertex v;
} inpt;
void main() {
gl_FragColor = inpt.v.color;
}
#endif

View File

@ -193,7 +193,7 @@ HullVertex hs_main_patches(
pos += B[j][k]*H[k];
}
#else
#else // not OSD_PATCH_BOUNDARY, not OSD_PATCH_CORNER
float3 H[4];
for (int l=0; l<4; ++l) {
H[l] = float3(0,0,0);
@ -309,7 +309,7 @@ void ds_main_patches(
float3 A = patch[4*(3-i) + (3-j)].position.xyz;
#elif OSD_TRANSITION_ROTATE == 3
float3 A = patch[4*j + (3-i)].position.xyz;
#else // OSD_TRANNSITION_ROTATE == 0, or non-transition patch
#else // OSD_TRANSITION_ROTATE == 0, or non-transition patch
float3 A = patch[4*i + j].position.xyz;
#endif
BUCP[i] += A * B[j];
@ -353,27 +353,3 @@ void ds_main_patches(
output.positionOut = mul(ProjectionMatrix, float4(WorldPos, 1.0f));
}
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
void vs_main( in InputVertex input,
out OutputVertex output)
{
output.positionOut = mul(ModelViewProjectionMatrix, input.position);
}
//----------------------------------------------------------
// Patches.PixelColor
//----------------------------------------------------------
cbuffer Data : register( b2 ) {
float4 color;
};
void ps_main( in OutputVertex input,
out float4 colorOut : SV_Target )
{
colorOut = color;
}

View File

@ -593,27 +593,3 @@ void ds_main_patches(
output.positionOut = mul(ModelViewProjectionMatrix, float4(WorldPos, 1.0f));
}
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
void vs_main( in InputVertex input,
out OutputVertex output)
{
output.positionOut = mul(ModelViewProjectionMatrix, input.position);
}
//----------------------------------------------------------
// Patches.PixelColor
//----------------------------------------------------------
cbuffer Data : register( b2 ) {
float4 color;
};
void ps_main( in OutputVertex input,
out float4 colorOut : SV_Target )
{
colorOut = color;
}

View File

@ -429,27 +429,3 @@ void ds_main_patches(
output.positionOut = mul(ModelViewProjectionMatrix, float4(WorldPos, 1.0f));
}
//----------------------------------------------------------
// Patches.Vertex
//----------------------------------------------------------
void vs_main( in InputVertex input,
out OutputVertex output)
{
output.positionOut = mul(ModelViewProjectionMatrix, input.position);
}
//----------------------------------------------------------
// Patches.PixelColor
//----------------------------------------------------------
cbuffer Data : register( b2 ) {
float4 color;
};
void ps_main( in OutputVertex input,
out float4 colorOut : SV_Target )
{
colorOut = color;
}