It has been quite a long time since last posted a proper development update article. Of course we did not intend to leave you in the dark. Gathering information about all our progress takes time, and it is easier to write things on the spot than looking at it in retrospect.
Instead of focusing on multiple new features like we have in previous development update, we will be focusing on one new feature instead.
This article is a rather technical one and the subject may not interest everyone of you. We hope you will have a fun read!
Ripping out the Shader Editor
Source Shader Editor is something we distributed with the last Estranged Alpha - on a simple level it lets us create shaders (programs that take data from the game and tell the graphics card how to show it on screen) in an editor.It was a third party tool created by a mod developer named Biohazard.
Now why would we rip out the Shader Editor? The answer is pretty simple. We are now able to write our own shaders directly for Source. Which allows us to interact with the Source Engine on a deeper level.
Why would we not just keep both the editor and our own code, it shouldn't affect the project that much at all. In fact we still have the Shader Editor materials sitting in our mod acting like nothing has ever happened.
We ripped it out because we are trying to keep things clean. The Shader Editor is a pretty bulky buddy, adding a bunch of extra files to the codebase and also its own shader data files, the so called ‘canvas' files.
One of our new friends, Drew Watts, has also been helping integrating some of his custom shaders into our mod. We don't want these files to just be out there in some canvas files because they are not our work, they're Drew's.
Now what does programming shaders from scratch without the Shader Editor allow us to do that we can't do when using the editor. Well, as it turns out. Quite a lot!
The Phong Reflection Model
A bunch of modders out there may be familiar with the ‘VertexLitGeneric' (model shader) VMT parameters named ‘$phong' and all of its children: ‘$phongfresnelranges', ‘$rimlight', etc... An good example of a model that uses the Phong reflection model is the character model of Alyx.You can find more information about the Phong for these materials on the Valve Developer Community wiki.
Now what is this Phong? Or more specifically in this case; what is the Phong reflection model?
It is a mathematical model that allows you to calculate the local illumination of points on a surface. A.k.a. it allows you to calculate light reflection of the lights in the area.
World geometry in Source usually uses the ‘LightmappedGeneric' shader and does not support the ‘$phong' parameter and its children.
Specular Phong support for World Geometry
This is where it gets interesting. Estranged's ‘LightmappedGeneric' isn't using the default shader code anymore. It has been customized and made to support up to 10 lights. This means that we can input a maximum of ten lights for Phong reflection calculations.
The system isn't completely stable yet but most of it is working properly now. It wasn't easy to get it all to work but it was worth the effort.
A few things had to be done to get it to work properly. Initially we used the same function that the Phong shading for ‘VertexLitGeneric' uses to get its light information. This function supplied us with four lights that turned on and off rather rapidly fading into existence based on ‘ambient cube' information.
After asking around we found out that we can make our own interface to allow the client to interact with the shader DLL files. So a function was written to get us 10 lights instead and BAM! The shader could now process up to ten lights! The best part of it all is that we are able to control how they are handled instead of having to rely on an inaccessible function.
Great :D
Can't wait to play this.
Thats what i wanna see! >:D
this is how frostbite makes their textures look so good, specualrity and high res normals, you'll make any game look gret
I am quite curious on how you guys customized it to support 10 lights and get Phong to work on geometry! How did you guys figure out how to do this? I am so curious right now! >:D
Yes! I want to know too!
Good on you to give credit where it's due! The screenshots look marvelous.
I love all the little additions you guys are adding.
While the graphical features are great I hope the brushwork is being overhauled, many of the locations make no sense and many areas are extremely blocky and could be fixed up easily.
Also will you ever consider releasing this phong shader in a more complete form for the community?
this needs testing! hehehe
Cant wait for the final thing, this has so much potential.
now we just need new zombies that are actually scary lol. still, like what i see here.
You'd be surprised.
It's really nice, you don't use the SSE ?
Not anymore. It's on our developer build simply to prototype shaders. Using C++ and our own .dll gives use much more control on blending to the scene, and lets us optimize much better!
Fantastic !
I cannot wait to play this.
How did you start to make shaders for Source? I want to learn, but I haven't found a good tutorial, and I really want to learn how to make shaders.