本文整理汇总了C#中GraphicsContext.SetShaderProgram方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsContext.SetShaderProgram方法的具体用法?C# GraphicsContext.SetShaderProgram怎么用?C# GraphicsContext.SetShaderProgram使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.SetShaderProgram方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: render
public override void render(GraphicsContext context)
{
shaderColored.SetUniformValue(0, ref sceneTransform);
shaderColored.SetUniformValue(1, ref screenMatrix);
shaderColored.SetUniformValue(2, 1f);
context.SetShaderProgram(shaderColored);
context.SetVertexBuffer(0, vertexBuffer);
context.DrawArrays(DrawMode.TriangleFan, 0, vertexBuffer.VertexCount);
}
示例2: render
public override void render(GraphicsContext context)
{
if (vertexBuffer == null) return;
program.SetUniformValue(0, ref sceneTransform);
program.SetUniformValue(1, ref screenMatrix);
program.SetUniformValue(2, 1f);
context.SetShaderProgram(program);
context.SetVertexBuffer(0, vertexBuffer);
context.SetTexture(0, texture);
context.DrawArrays(DrawMode.TriangleFan, 0, vertexBuffer.VertexCount);
context.SetTexture(0, null);
}
示例3: Draw
/// BasicMaterial に設定された ShaderName から、ShaderProgram を探して描画する
public void Draw(
GraphicsContext graphics,
ShaderContainer shaderContainer,
Matrix4 viewProj,
Vector4 eye
)
{
foreach ( var bone in Bones ) {
int worldCount = 0;
int[] blendBones = bone.BlendBones ;
if ( blendBones == null ) {
worldCount = 1;
matrixBuffer = new Matrix4[ 1 ] ;
matrixBuffer[ 0 ] = bone.WorldMatrix;
}else{
int blendCount = blendBones.Length ;
if ( blendCount > matrixBuffer.Length ) matrixBuffer = new Matrix4[ blendCount ] ;
for ( int i = 0 ; i < blendCount ; i ++ ) {
matrixBuffer[ i ] = Bones[ blendBones[ i ] ].WorldMatrix * bone.BlendOffsets[ i ] ;
}
}
int[] blendSubset = defaultBlendSubset ;
foreach ( var index in bone.DrawParts ) {
BasicPart part = Parts[ index ] ;
foreach ( var mesh in part.Meshes ) {
if ( blendBones != null && blendSubset != mesh.BlendSubset ) {
blendSubset = ( mesh.BlendSubset != null ) ? mesh.BlendSubset : defaultBlendSubset ;
worldCount = blendSubset.Length ;
if ( worldCount > blendBones.Length ) worldCount = blendBones.Length ;
}
BasicMaterial material = Materials[ mesh.Material ];
if( material != null ){
setPolygonMode( graphics, material );
BasicProgram program = findBasicProgram( shaderContainer, material, worldCount, this.lightCount );
graphics.SetShaderProgram( program );
program.SetViewProj( viewProj );
program.SetMaterial( ref material );
if( material.LightEnable != 0 ){
program.SetLightCount( lightCount );
// program.SetLights( ref this.WorldMatrix, ref eye, ref lights );
program.SetLights( ref matrixBuffer[ 0 ], ref eye, ref lights );
}else{
program.SetLightCount( 0 );
}
setLayers( graphics, program, material );
program.SetWorldCount( worldCount );
for( int i = 0; i < worldCount; i++ ){
program.SetMatrixPalette( i, ref matrixBuffer[ blendSubset[ i ] ] );
}
program.Update();
}
graphics.SetVertexBuffer( 0, mesh.VertexBuffer ) ;
graphics.DrawArrays( mesh.Primitives ) ;
}
}
}
}
示例4: render
public override void render(GraphicsContext context)
{
base.render(context);
program.SetUniformValue(1, ref screenMatrix);
program.SetUniformValue(0, ref sceneTransform);
context.SetShaderProgram(program);
context.SetVertexBuffer(0, vertexBuffer);
foreach ( CellData cell in cells ){
program.SetUniformValue(3, (float) cell.val);
program.SetUniformValue(2, (float) cell.time);
pos.X = cell.x * (CELL_SIZE + 5) - CELL_SIZE * .5f;
pos.Y = cell.y * (CELL_SIZE + 5) - CELL_SIZE * .5f;
program.SetUniformValue(4, ref pos);
context.DrawArrays(DrawMode.Triangles, 0, vertexBuffer.VertexCount);
}
}
示例5: render
public override void render(GraphicsContext context)
{
if (dirtyBuffer) {
validateBuffer();
}
if (vertexBuffer == null) return;
program.SetUniformValue(0, ref sceneTransform);
program.SetUniformValue(1, ref screenMatrix);
program.SetUniformValue(2, (float) sceneAlpha);
context.SetShaderProgram(program);
context.SetVertexBuffer(0, vertexBuffer);
if (program == shaderUniversal) context.SetTexture(0, texture);
context.DrawArrays(DrawMode.Triangles, 0, vertexBuffer.VertexCount);
if (program == shaderUniversal) context.SetTexture(0, null);
}
示例6: DrawCapsule
/// カプセル描画
public void DrawCapsule( GraphicsContext graphics, GeometryCapsule trgCap, Camera cam, Rgba color )
{
if( debShader == null || trgCap.R <= 0.00001f ){
return ;
}
/// 球体部分
///---------------------------------------------
DrawSphere( graphics, new GeometrySphere( trgCap.StartPos, trgCap.R ), cam, color );
DrawSphere( graphics, new GeometrySphere( trgCap.EndPos, trgCap.R ), cam, color );
/// パイプ部分
///---------------------------------------------
setCapsulePipeVertex( trgCap );
debVb2.SetVertices( 0, debMesh2.Positions );
debVb2.SetIndices( debMesh2.Indices );
Matrix4 localMtx;
if( trgCap.StartPos.X == trgCap.EndPos.X && trgCap.StartPos.Z == trgCap.EndPos.Z ){
localMtx = Matrix4.LookAt( trgCap.EndPos, trgCap.StartPos, new Vector3(0.0f, 0.0f, 1.0f));
}
else{
localMtx = Matrix4.LookAt( trgCap.EndPos, trgCap.StartPos, new Vector3(0.0f, 1.0f, 0.0f));
}
Matrix4 world = localMtx.Inverse() * Matrix4.Scale( new Vector3( trgCap.R, trgCap.R, trgCap.R ) );
world.M41 = trgCap.StartPos.X;
world.M42 = trgCap.StartPos.Y;
world.M43 = trgCap.StartPos.Z;
Matrix4 worldViewProj = cam.Projection * cam.View * world;
// uniform value
debShader.SetUniformValue( debUIdWVP, ref worldViewProj );
Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );
graphics.SetShaderProgram( debShader );
graphics.SetVertexBuffer( 0, debVb2 );
graphics.DrawArrays( debMesh2.Prim, 0, debMesh2.IndexCount );
}
示例7: drawMesh
/// private メソッド
///---------------------------------------------------------------------------
/// 描画
private void drawMesh( GraphicsContext graphics, Camera cam, Rgba color )
{
Matrix4 world = Matrix4.Translation( new Vector3( 0, 0, 0 ) );
Matrix4 worldViewProj = cam.Projection * cam.View * world;
// uniform value
debShader.SetUniformValue( debUIdWVP, ref worldViewProj );
Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );
graphics.SetShaderProgram( debShader );
graphics.SetVertexBuffer( 0, debVb );
graphics.DrawArrays( debMesh.Prim, 0, debMesh.IndexCount );
}
示例8: DrawSphere
/// 球描画
public void DrawSphere( GraphicsContext graphics, GeometrySphere trgSph, Camera cam, Rgba color )
{
if( debShader == null ){
return ;
}
debVb.SetVertices( 0, debMesh.Positions );
debVb.SetIndices( debMesh.Indices );
Matrix4 world = Matrix4.Translation( new Vector3( trgSph.X, trgSph.Y, trgSph.Z ) ) * Matrix4.Scale( new Vector3( trgSph.R, trgSph.R, trgSph.R ) );
Matrix4 worldViewProj = cam.Projection * cam.View * world;
// uniform value
debShader.SetUniformValue( debUIdWVP, ref worldViewProj );
Vector4 a_Color = new Vector4( (color.R / 255.0f), (color.G / 255.0f), (color.B / 255.0f), (color.A / 255.0f) );
debShader.SetUniformValue( debShader.FindUniform( "IAmbient" ), ref a_Color );
graphics.SetShaderProgram( debShader );
graphics.SetVertexBuffer( 0, debVb );
graphics.DrawArrays( debMesh.Prim, 0, debMesh.IndexCount );
}