English 中文(简体)
Basic samples for shader in Managed DirectX
原标题:

I am new write a pixel shader and use in my managed directx project, where i can get some basic sample to start it.

最佳回答

I m assuming you know how to create a device.

First, you need to prepare the shader itself.

Here s a little sample pixel shader (which uses pixel shader 1.4, as seen by ps_1_4; r0 is a register that is read as the final result; v0 is a register that stores primary colour (of diffuse lighting)):

ps_1_4
mov r0, v0

This shader, which is in shader assembly, has to be assembled. You can do that as follows (note that you need D3DX library referenced, otherwise you won t see the ShaderLoader class):

Imports Microsoft.DirectX

  other code

Dim graphicsStream As GraphicsStream = Direct3D.ShaderLoader.FromString(shaderText, Nothing, Direct3D.ShaderFlags.None)

  other code.

After assembling the shader, you can finally create a PixelShader object as follows:

  other code

Dim p As Direct3D.PixelShader = New Direct3D.PixelShader(Device, graphicsStream)

  other code

To apply the pixel shader, use:

  other code

Device.PixelShader = p

  other code

where Device is the Direct3D Device.

A similar process applies for compiling shaders in case you use HLSL.

Edit: Just noticed this was an year old question.

问题回答

暂无回答




相关问题
In SSAS, can parent-child DATAMEMBER name be customised

In a parent-child dimension in SSAS, the datamember is automatically named the same as the parent. E.g. Division X Risk Register Division X Risk Register Department A Risk Register Department B ...

Adding a Total column to MDX

I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx ...

using colors in calculated member

Im using this query in MDX for a calculate measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption this will bring me this result Dimension1 ...

Using colors with MDX calculated measure

I m using this query in MDX for a calculated measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption This will bring me this result Dimension1 ...

Calculated Member for Cumulative Sum

First some background: I have the typical Date dimension (similar to the one in the Adventure Works cube) and an Account dimension. In my fact table I have daily transaction amounts for the accounts. ...

What is MDX and what is its use in SAP BPC

I would like to know more about "MDX" (Multidimensional Expressions). What is it? What is it used for? Why would you use it? Is it better than SQL? What is its use in SAP BPS (I haven t seen BPC, ...

热门标签