I'd like to call upon all the shader gurus here for some help :)
I've been experimenting with writing some of my own effects, meaning I'm a HLSL newbie, and have been using NVIDIA's FX Composer to do my work. After producing a cool (albeit simple) effect, I decided to try using it in my little model viewer. The problem is that the way it shows up through XNA is different than the way it shows up in FX Composer, and I can't figure out why.
You can find the code to my effect here: http://www.hiranipra.com/data/help_attach/gb1_shader.txt - it's just fairly simple environment mapping-ish stuff.
A screenshot of what it looks like in FX Composer: http://www.hiranipra.com/data/help_attach/FxComposer1.jpg - it's hard to tell, but the model has a nice shine to it, and as it rotates the shine changes. Looks like metal.
And the problem, a screenshot of what it looks like through my viewer: http://www.hiranipra.com/data/help_attach/Xna1.jpg - note the sharp edges on the shine areas.
So obviously I'm applying the effect right (as the model shows and such), and the textures are all there (when they aren't there is nothing displayed), but it's just not working.
The shader takes in two parameters - the worldViewProj matrix and the viewInverse matrix. Both of these are set each frame in my code:
effect.Parameters[
"worldViewProj" ].SetValue( _transformMatrix * transforms[ mesh.ParentBone.Index ] * _view * _projection );effect.Parameters[
"viewInverse" ].SetValue( Matrix.Invert( _view ) );This seems right, I think.
In an attempt to get more debugging information, I set the pixel shader to return the color of the cubemap. This gave the predicted results in FX Composer: http://www.hiranipra.com/data/help_attach/FxComposer2.jpg - but look at what it did in XNA: http://www.hiranipra.com/data/help_attach/Xna2.jpg - completely wrong!
Finally, I recorded a run of FX Composer with PIX and looked through the results - I don't see FX Composer doing anything different when it comes time to render my model (sets the texture states as I have them in the effect, and draws the vertices).
So then my question is, what else do I need to set to get things looking right Is this an issue with FX Composer setting states I don't know about, or something in XNA setting defaults that are different than normal, or my shader code doing something stupid (maybe all of the above :)