# How to use shaders from psh & vsh files?

## Recommended Posts

Hi, so far I've been able to use a shader from an fx file, but I'd like to use psh & vsh files as I think this is the proper way to learn them (so theres no surprises later on or anything). So whats needed, can you still use HLSL with them? Are they written the same as an fx file but just loaded as vsh & psh, also what function is used to load them. At the moment I'm using D3DXCreateEffectFromFile to load my fx file. Thanks in advance for any help & replys.

##### Share on other sites
I just search "vsh" in dx docs, and I find this one, HLSLwithoutEffects Sample.
Have you tried it?

##### Share on other sites
Thanks for that I'll take a look.

Um, One other thing, for some reason I've never been able to get any of the sample programs to work, I keep getting COFF & Manifest file errors, does any one know of a solution to this?

##### Share on other sites
Here I use directx(dec 2005), the sample project can be installed from directx sample brower. After installation, the sample project can be compiled and run properly here.

##### Share on other sites
Hi, thanks supersonicstar, yeah, I can check out the code for hlsl with out effects, but I might have to ask on another forum about the COFF file problem?

##### Share on other sites

Depending on when you want to create your shaders, they can either be assembled into binary shaders at build time using vsa.exe and psa.exe or passed to functions such as D3DXAssembleShaderFromFile().

Apart from the above traditional uses of those types of files, really .vsh and .psh are nothing more arbitrary filename extensions - they're just text files. In their traditional guise, the first line of the file usually has the shader version number that the code targets, e.g. ps.1.4 or ps_1_4

One sneaky thing you /can/ do is load a psh or vsh file from inside an effect file, using something like:

// myEffect.fxtechnique Blah{    pass P0    {           VertexShader = compile vs_2_0 VS();        PixelShader  = asm {            #include "C:\myPixelShader.psh"        };    }}

##### Share on other sites
<shameless-plug>

The HDRPipeline sample (in both the Dec'05 and Feb'05 SDK's) use HLSL shaders directly from a number of vsh and psh files. Could be another useful example if you want to see how it can be done...

</shameless-plug>

hth
Jack

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628334
• Total Posts
2982143

• 9
• 24
• 9
• 9
• 13