So this is a topic that doesn't seem to get brought up at all about TS2014. Maybe it's because it's rather scary and leaves people confused
I was reminded of my previous efforts on these shaders before, when the subject was brought up in the 'on going projects' thread. I had attempted to re-write parts of a shader provided in said folder, with no differing outcomes. Despite most games being written with the DirectX libraries, there's a very scattered community of HLSL 'activists' on the web that provide teaching support or general discussion/experiments with .fx files.
I know Jordi has worked with the shaders in the past, but I'd rather not bother him again about another topic I can't seem to grasp as well as him
So on to my issues, if anyone even has an answer
-the shader takes in vertex/index data
-the data is transformed to screen projection coordinates with vertex shaders
-the vertex groups are rasterised into polygons
-the polygon space occupied on-screen is allocated pixels on the screen
-these pixels are colored by the pixel shaders given lighting data/normals etc.
-the techniques are the last part of the .fx file where the desired vertex shader is compiled, then an accompanying pixel shader adds the desired effect to the given pixel.
-multiple techniques can be used to layer basic effects together in multiple passes to create something complex like TrainBumpSpecEnvMask.fx
I took a sample effect off the web that is supposed to take a given pixel's coloring data and convert it to greyscale. Here's the code:
- Code: Select all
float4 greyscale(float2 texCoord : TEXCOORD0) : color0
{
float4 colour = tex2D(diffuseSampler, texCoord.xy);
colour.rgb = 1 - colour.rgb;
return colour;
}
I thought that I would see if I could actually modify DTG's code to produce a new effect. Admittedly I didn't (and still don't) know whether what I was doing was actually correct, in fact I didn't even know what I was doing, I just followed the example that the existing code provided me. I don't know if the above example code does what it says it does (don't know how subtracting the rgb values from 1 gives the greyscale), but I went with it anyway. So I stuck this greyscale pixel shader in below the other pixel shaders (below TrainPSLow() ) and thought it would need to be put into a technique/pass to be put into effect in-game. So I first created a new technique with the exact same syntax as the one above it (the LOW technique) and gave it a different name (TEST). I changed the pixel shader used in that pass from TrainPSLow() to greyscale(), saved the file and compiled it with DirectX's utility fxc.exe. After a bit of fidgeting with the compiler, I got the .fx file compiled into an .o file. I thought that was great, no compiler errors so I wasn't doing anything wrong (I had to change the texture sampler name so that it used the one from the shader and not the example one, which solved previous compiler errors). I overwrote the old shader object file (I made a backup
So I was expecting that anything which has TrainBumpSpecEnvMask.fx applied to it in-game would appear in greyscale. But surprisingly, nothing had changed. All my rolling stock rendered in color as it used to, which I found odd as I thought that if I did something wrong then the shader would behave weird in game, but nothing was awry. So I decided to see if I could actually break the shader to get some sort of response to show that I was making an impact. I decided to remove all techniques except the deferred one (fxc threw an error if I removed them all), but amazingly without 3 of it's passes, anything in game with the shader applied looked no different than the 4-pass version.
So if someone on here knows anything about shaders or has successfully modified them, would they mind inputting on this? I'd like to get into the proper stuff of graphics, I think this could be very useful to me in the long run.
Thanks,
Kevin
