Multiple textures within a shader
Hey, everyone. Having a bit of trouble here.
I'm trying to draw two textures using a single shader, instead of having to use two separate ones. I was under the impression I could change internal shader parameters using the CommitChanges method. Here's my code:
| spriteBatch.End(); |
| spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); |
| HP.Begin(); |
| foreach (EffectPass pass in HP.CurrentTechnique.Passes) |
| { |
| pass.Begin(); |
| HP.Parameters["green"].SetValue(1); |
| HP.Parameters["health"].SetValue((float) pseudoPlayerHealth / playerMaxHP); |
| HP.CommitChanges(); |
| spriteBatch.Draw(Sphere, new Vector2(300, 400), null, Color.White); |
| HP.Parameters["green"].SetValue(0); |
| HP.Parameters["health"].SetValue((float)pseudoFoeHealth / foeMaxHP); |
| HP.CommitChanges(); |
| spriteBatch.Draw(Sphere, new Vector2(800, 400), null, Color.White); |
| pass.End(); |
| } |
| spriteBatch.End(); |
| HP.End(); |
| spriteBatch.Begin(SpriteBlendMode.AlphaBlend); |
But, alas, both textures are drawn exactly the same, using the second pair of values for both. The shader handles both green == 0 and green == 1 cases fine when they're done separately.
What's going on?
Multiple textures within a shader
Hey, everyone. Having a bit of trouble here.
I'm trying to draw two textures using a single shader, instead of having to use two separate ones. I was under the impression I could change internal shader parameters using the CommitChanges method. Here's my code:
| spriteBatch.End(); |
| spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); |
| HP.Begin(); |
| foreach (EffectPass pass in HP.CurrentTechnique.Passes) |
| { |
| pass.Begin(); |
| HP.Parameters["green"].SetValue(1); |
| HP.Parameters["health"].SetValue((float) pseudoPlayerHealth / playerMaxHP); |
| HP.CommitChanges(); |
| spriteBatch.Draw(Sphere, new Vector2(300, 400), null, Color.White); |
| HP.Parameters["green"].SetValue(0); |
| HP.Parameters["health"].SetValue((float)pseudoFoeHealth / foeMaxHP); |
| HP.CommitChanges(); |
| spriteBatch.Draw(Sphere, new Vector2(800, 400), null, Color.White); |
| pass.End(); |
| } |
| spriteBatch.End(); |
| HP.End(); |
| spriteBatch.Begin(SpriteBlendMode.AlphaBlend); |
But, alas, both textures are drawn exactly the same, using the second pair of values for both. The shader handles both green == 0 and green == 1 cases fine when they're done separately.
What's going on?
Celebration (MP3 Download) newly tagged "blu-ray"
Customer Rating:
First tagged “blu-ray” by Porfie Medina “Porfie Jr. Medina”
Customer tags: music(2), blu-ray(2), the, madonna celebration new song pop greatest hits, mtv, celebration, most successful female recording artist, porfie, madonna, madonna celebration, dvd
PhysX and TriangleMesh
I write next code:
ModelMesh mesh = model.Meshes[0];
Matrix[] transforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(transforms);
int countTr = mesh.MeshParts[0].PrimitiveCount;
int countVert = mesh.MeshParts[0].NumVertices;// / 3;
int countInd = countTr;// *3;
Vector3[] vertices = new Vector3[countVert];
int[] indices = new int[countInd];
mesh.VertexBuffer.GetData(vertices);
mesh.IndexBuffer.GetData(indices);
TriangleMeshDescription triangleMeshDesc = new TriangleMeshDescription();
triangleMeshDesc.TriangleCount = countTr;
triangleMeshDesc.VertexCount = countVert;
triangleMeshDesc.AllocateTriangles(triangleMeshDesc.TriangleCount);
triangleMeshDesc.AllocateVertices(triangleMeshDesc.VertexCount);
triangleMeshDesc.TriangleStream.SetData(indices);
triangleMeshDesc.VerticesStream.SetData(vertices);
MemoryStream s = new MemoryStream();
Cooking.InitializeCooking();
Cooking.CookTriangleMesh(triangleMeshDesc, s);
Cooking.CloseCooking();
s.Position = 0;
TriangleMesh triangleMesh = core.CreateTriangleMesh(s);
TriangleMeshShapeDescription triangleMeshShapeDesc = new TriangleMeshShapeDescription()
{
TriangleMesh = triangleMesh,
Flags = ShapeFlag.Visualization
};
ActorDescription actorDesc = new ActorDescription()
{
BodyDescription = new BodyDescription(10.0f),
GlobalPose = Matrix.CreateTranslation(0, 0, 0),
Shapes = { triangleMeshShapeDesc }
};
actorDesc.Shapes.Add(triangleMeshShapeDesc);
actor = scene.CreateActor(actorDesc);
but here
Cooking.CookTriangleMesh(triangleMeshDesc, s);
Error: Attempt of reading or record in the protected memory.
Sorry, I not freely speak on English. (i'm from Russia)
Help me!
‘We Were De-Splendored’
Read MoreAdvice on Octree and collision with Model Mesh
Hi Guys!
| public struct Poly |
| { |
| public Vector3[] verts; |
| public Poly(Vector3 v1, Vector3 v2, Vector3 v3) |
| { |
| verts = new Vector3[3]; |
| verts[0] = v1; |
| verts[1] = v2; |
| verts[2] = v3; |
| } |
| } |
Advice on Octree and collision with Model Mesh
Hi Guys!
| public struct Poly |
| { |
| public Vector3[] verts; |
| public Poly(Vector3 v1, Vector3 v2, Vector3 v3) |
| { |
| verts = new Vector3[3]; |
| verts[0] = v1; |
| verts[1] = v2; |
| verts[2] = v3; |
| } |
| } |
separate calls to DrawUserIndexedPrimitives ignoring depth information
Hello,
I have a series of triangles and lines in indexed vertex buffers that I am drawing. I want the line to be in front of some triangles, but behind others.
To do this, I made sure to specify that it's z-coordinate was between the z-coordinates of the respective triangles. I am rendering using an Orthographic projection.
Here's my drawing code (it is very like the code used in the drawing primitives example):
| device.VertexDeclaration = vertexDeclaration; |
| basicEffect.Begin(); |
| basicEffect.CurrentTechnique.Passes[0].Begin(); |
| // Draw whatever the user wanted us to draw |
| device.DrawUserIndexedPrimitives<VertexPositionColor>( |
| PrimitiveType.TriangleList, triangleVertices, 0, triangleVertices.Length, |
| triangleIndices, 0, trianglesAdded); |
| device.DrawUserIndexedPrimitives<VertexPositionColor>( |
| PrimitiveType.LineList, lineVertices, 0, lineVertices.Length, |
| lineIndices, 0, linesAdded); |
| // and then tell basic effect that we're done. |
| basicEffect.CurrentTechnique.Passes[0].End(); |
| basicEffect.End(); |
As it is, the line is always visible on top. When I exchange the two calls to DrawUserIndexedPrimitives, the line becomes hidden behind all the triangles.
How can I fix this?
separate calls to DrawUserIndexedPrimitives ignoring depth information
Hello,
I have a series of triangles and lines in indexed vertex buffers that I am drawing. I want the line to be in front of some triangles, but behind others.
To do this, I made sure to specify that it's z-coordinate was between the z-coordinates of the respective triangles. I am rendering using an Orthographic projection.
Here's my drawing code (it is very like the code used in the drawing primitives example):
| device.VertexDeclaration = vertexDeclaration; |
| basicEffect.Begin(); |
| basicEffect.CurrentTechnique.Passes[0].Begin(); |
| // Draw whatever the user wanted us to draw |
| device.DrawUserIndexedPrimitives<VertexPositionColor>( |
| PrimitiveType.TriangleList, triangleVertices, 0, triangleVertices.Length, |
| triangleIndices, 0, trianglesAdded); |
| device.DrawUserIndexedPrimitives<VertexPositionColor>( |
| PrimitiveType.LineList, lineVertices, 0, lineVertices.Length, |
| lineIndices, 0, linesAdded); |
| // and then tell basic effect that we're done. |
| basicEffect.CurrentTechnique.Passes[0].End(); |
| basicEffect.End(); |
As it is, the line is always visible on top. When I exchange the two calls to DrawUserIndexedPrimitives, the line becomes hidden behind all the triangles.
How can I fix this?
CodePlex Daily Summary for Friday, July 31, 2009
CodePlex Daily Summary for Friday, July 31, 2009
New Projects
- DoLines: It is great idea
- Legend Fakes: A dynamic fake framework. * Easier semantics, all fake objects are just that - fakes - the use of the fakes determines whether they're mocks or st…
- ManaObject: Learning environment for object oriented programming. Written in C# .NET 3.5, IDE based on Visual Studio 2008 Shell.
- nPress: nPress is a "port" of WordPress in asp.net Mvc (c#).
- OneDAL: Simple framework for Data Access Layer. Developed in C#. It is simple, but has high performance. Providing you with strong typed object.
- Secure Fields: Secure Fields is a solution design to allow the user to set some permission on a list field.
- SharePoint Solution and Packaging Guidance: WSPSolution is the SharePoint Solution and Packaging Guidance project. The project recommends standards for: building SharePoint solutions in Visu…
- Silverlight / WPF - Multi Touch: Silverlight / WPF custom controls to enable multi touch gestures and features.
- Sports Schedule: This DotNetNuke module allows you to display a schedule of sports. Site admin can add and remove sports, tournaments and actual sporting events. Id…
- SQLSTAT2005: SQLSTAT2005 is a data collection and a data warehouse service based on SQL Server 2005 DMV and DMF performance views and functions. This product wi…
- StyleCop for CodeRush: Implementation of Micrsoft's StyleCop for Devexpress CodeRush.
New Releases
- All-In-One Code Framework: All-In-One CodeFx 2009-7-30: Improved and Newly Added Examples:For an up-to-date list, please refer to All-In-One Code Framework Examples. Examples for Silverlight Name D…
- Content Dejour: WESNet_ContentDejour_05.01.01_Source: This release is identical in function and file content to the v 04.01.01 release except that it is packaged for the new DNN v 5 installer. Both ver…
- iExporter - iTunes playlist exporting: iExporter - v2.1.0.0: Paypal donate! Added a new feature Feature 1. Now you can specify if you need album subfolders inside the chosen export location Example With al…
- J programs web browser (fast and easy to use web browser) - desktop lock: J programs: SEND ME FEEDBACK ON WHAT YOU THINK ABOUT THE PROGRAMS!!!ණ Jbrowser, web browser http://www.jwilliamfinc.tech.officelive.com/images/jbrowser…
- Legend Fakes: Fakes version 0.1.0.0: First alpha release of Legend.Fakes.
- Microsoft Distributed Cache (Velocity) Admin Tool: MDC (Velocity) Admin Tool 1.0: Project DescriptionThe Microsoft Distributed Cache (code name Velocity) Admin Tool help you manage the Microsoft Distributed Cache.
- NetXForum: Alpha .2: Implemented AJAX login Implemented Register User Added Loading indicator Fixed problems with creating and replying to posts Added Widget function…
- NUnit for Team Build: Version 1.1: This release removes the dependencies on the nxslt utility and MSTest. You can now load your NUnit results into the TFS Build Store without needin…
- OneDAL: 1DAL.1.0.0.0: Ah, this is the first publish for the framework though, it has run in my concrete project for a long time. It is simple, but has high performance. …
- Open Studio IDE: Open Studio Alpha 5: Many enhancements plus, a sdk for plugin development.
- Ox Game Engine: Release 62 - Updated Docs, Nixed Scope, Full Name: The scope name and full name concepts impeded play-time serialization. They also weren't terribly effective at what the did. So I removed them. You…
- PhluffyFotos: v3 Windows Azure: This release has been updated for Windows Azure. Please use the included Provision.cmd to bootstrap the deployment (for either cloud or local). T…
- Secure Fields: Secure Fields 1.0: Secure Fields allow the user to put some permission on list fields.
- SharePoint Developer Explorer: SPDevExplorer 2.4: Release 2.4. This is the first release after a major overhaul of the code by Serge van den Oever. Installation: ======= 1. Unzip to a folder, fo…
- SharePoint Solution and Packaging Guidance: WSPSolution Source: This is the initial release to accompany the article on Building and Packaging SharePoint Solutions: http://weblogs.asp.net/erobillard/archive/200…
- Sports Schedule: 17 jun release: source and installer files
- SQLSTAT2005: SQLSTAT2005 version 1.1: Release candidate 1.1 Included in this release: - Performance data warehouse - Reports for doing analysis - Documentation
- The Sharp Project: Create RSS Feed for Podcast - XML: Learn how to create an RSS feed for a podcast. By Luneth
- Validator Toolkit for ASP.NET MVC: Validator Toolkit 2.2 (20090730): This release of the Validator Toolkit for ASP.NET MVC contains the source code including a sample website. Most important changes are: Updated so…
- VCC: Latest build, v2.1.20730.0: Automatic drop of latest build
- ZipStorer - A Pure C# Class to Store Files in Zip: ZipStorer 2.00: Now ZipStorer can compress! It supports Deflate algorithm while keeping its small footprint. Just ZipStorer.cs file needed to be embedded in any .n…
Most Popular Projects
- Rawr
- AJAX Control Toolkit
- WBFS Manager
- Silverlight Toolkit
- Windows Presentation Foundation (WPF)
- Microsoft SQL Server Product Samples: Database
- Google Book Downloader
- DotNetNuke® Community Edition
- ASP.NET
- Microsoft SQL Server Community & Samples
Most Active Projects
- Rawr
- patterns & practices – Enterprise Library
- PHPExcel - OpenXML - Create Excel2007 documents in PHP - Spreadsheet engine
- DotNetZip Library
- Facebook Developer Toolkit
- Farseer Physics Engine
- BlogEngine.NET
- NB_Store - Free DotNetNuke Ecommerce Catalog Module
- Windows Presentation Foundation (WPF)
- Pcap.net











