Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 3 additions & 35 deletions src/IECoreGL/Primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,51 +130,19 @@ static Shader *constant2()
return s.get();
}


static Shader *flatConstant()
{

static const char *vertexSource =

"#version 120\n"
""
"#if __VERSION__ <= 120\n"
"#define in attribute\n"
"#define out varying\n"
"#endif\n"
""
"uniform vec3 Cs = vec3( 1, 1, 1 );"
""
"in vec3 vertexP;"
"in vec3 vertexCs;"
""
"out vec3 geometryCs;"
""
"out vec3 fragmentCs;"
""
"void main()"
"{"
" vec4 pCam = gl_ModelViewMatrix * vec4( vertexP, 1 );"
" gl_Position = gl_ProjectionMatrix * pCam;"
" geometryCs = Cs;"
""
" fragmentCs = geometryCs;"
"}";

static const char *fragmentSource =

"#if __VERSION__ <= 120\n"
"#define in varying\n"
"#endif\n"
""
"in vec3 fragmentCs;"
"uniform vec3 Cs;" // get colour from uniform Cs, bypassing vertexCs
""
"void main()"
"{"
" gl_FragColor = vec4( fragmentCs, 1 );"
" gl_FragColor = vec4( Cs, 1 );"
"}";

static ShaderPtr s = new Shader( vertexSource, fragmentSource );
static ShaderPtr s = new Shader( "", fragmentSource );
return s.get();
}

Expand Down
33 changes: 33 additions & 0 deletions test/IECoreGL/ShadingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,39 @@ def testColorAttributeDoesntAffectWireframe( self ) :
]
)

def testVertexCsDoesntAffectWireframe( self ) :

m = self.mesh()
m["Cs"] = IECore.PrimitiveVariable(
IECore.PrimitiveVariable.Interpolation.Vertex,
IECore.Color3fVectorData(
[ IECore.Color3f( 0 ) ] * len( m["P"].data )
)
)

g = IECore.Group()
g.addChild( m )

g.addState(
IECore.AttributeState(
{
"gl:primitive:solid" : IECore.BoolData( True ),
"gl:primitive:wireframe" : IECore.BoolData( True ),
"gl:primitive:wireframeColor" : IECore.Color4f( 0, 1, 0, 1 ),
"gl:primitive:wireframeWidth" : 6.0,
}
)
)

image = self.renderImage( g )
# wireframe is green, and vertex Cs is black,
# so there should be no contribution from
# wireframe or solid shading in the red channel.
self.assertEqual( sum( image["R"].data ), 0 )
# black vertex colour should have no effect on
# green wireframe, so we should have some wireframe
# contribution in the green channel.
self.assertTrue( sum( image["G"].data ) > 0 )

def testUniformFloatArrayParameters( self ) :

Expand Down