Sunday, January 10, 2010

Shaders

In the past week or so I've been playing around with HLSL and learning about shaders, DX10 / shader model 4. What I'm noticing, apart from the fact that the syntax is different, is that shaders are much more complex than I originally anticipated. I thought "Oh gee, I'll just do this and that and presto!" but nope! What is in fact the case is that unless the engine has a very well written, and almost intelligent renderer, there is quite a lot of communication that needs to happen explicitly between the render code and the shader.

It came as a surprise to me because the change I made to the shader which should have worked fine, they weren't making any difference what so ever. Upon talking with the person who wrote it he explained what I need to do in order for the shader to work like I intend it to.

The simple answer is that I wasn't actually doing anything with the pixels I was altering. They were using up GPU cycles and simply being discarded because I wasn't writing them to a render target. So the final pass, which was reading the same frame buffer was the only pass that was displaying any changes... being the final pass and all. That and the fact that I wasn't even calling my passes had something to do with it as well ;)

All in all I'm still hard at work updating this shader with some simple bloom, but it's so interesting! I know I'll have it figured out sooner or later. And then I'll actually PLAY deus ex again. After all, that's why I installed it again in the first place after all this time.

Yet, what a strange coincidence that I found this DX10 renderer because I thought the old renderer was causing the game to crash. And this new renderer happen to use shaders, something I've been wanting to learn for some time now. Funny how life turns out sometimes :)

No comments:

Post a Comment