Post news Report article RSS Feed Giving the Mod a Graphical Edge

In this article Christiaan Bakker (AniCator) will update you about some of the progress we have made on a graphical level. At the start we also briefly touch on how we are going to handle future update posts.

Posted by AniCator on Jul 7th, 2013

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.

Post comment Comments
BadXFox Jul 7 2013 says:

Great :D

+8 votes     reply to comment
Taquito Jul 7 2013 says:

Can't wait to play this.

+2 votes     reply to comment
AncientT Jul 8 2013 says:

Thats what i wanna see! >:D

+3 votes     reply to comment
navysealguy3 Jul 8 2013 says:

this is how frostbite makes their textures look so good, specualrity and high res normals, you'll make any game look gret

+5 votes     reply to comment
AncientT Jul 8 2013 says:

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

+4 votes     reply to comment
ScicoPax Jul 11 2013 replied:

Yes! I want to know too!

+1 vote     reply to comment
[Tox(sic)] Jul 8 2013 says:

Good on you to give credit where it's due! The screenshots look marvelous.

+2 votes     reply to comment
Armageddon104 Jul 8 2013 says:

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?

+5 votes     reply to comment
adelina1985a Jul 8 2013 says:

this needs testing! hehehe

+2 votes     reply to comment
Mr.Scary Jul 8 2013 says:

Cant wait for the final thing, this has so much potential.

+1 vote     reply to comment
SalesKital Jul 8 2013 says:

now we just need new zombies that are actually scary lol. still, like what i see here.

+3 votes     reply to comment
AniCator Author
AniCator Jul 8 2013 replied:

You'd be surprised.

+1 vote   reply to comment
ThrillerProd Jul 9 2013 says:

It's really nice, you don't use the SSE ?

+1 vote     reply to comment
Drew++ Jul 11 2013 replied:

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!

+1 vote     reply to comment
sexydiddo Jul 9 2013 says:

Fantastic !

+1 vote     reply to comment
StegoSigma Jul 10 2013 says:

I cannot wait to play this.

+1 vote     reply to comment
ScicoPax Jul 11 2013 says:

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.

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Post news
Report Abuse
Report article
Related Mods
Related Games
Half-Life 2
Half-Life 2 First Person Shooter