forums | blogs | polls | tutorials | downloads | rules | help

Add new comment

Dungeon Siege 2 Effect States

Edit: Please note that I could be wrong, since I know of know GPG documentation on gas files (the ones you find in the bitmaps folder) that manipulate textures. I also want to clarify that I'm talking about the gas files you find in the bitmaps folder. It's is also important for understanding how to make your own SFXs, since they use the gas files we find in the bitmap folder extensively. Perhaps a gas file texture manipulation is needed that doesn't already exist. Shaders are also important for understanding how to create new SFXs. The terms used are also used frequently in DS2 SFX.

I've been working on understanding DS2 effect states for some time prior to my absence. Effect states and shaders fascinate me. We could also improve DS2 textures with effect states and shaders. This blog is more so a note about DS2 effect states. I only understand them partially. If I recall right, DS2 uses direct x 9. I found sources that will help shed light on them (I'll look for more detailed sources).

How MS briefly describes Effect States:

"Effect states are used to initialize pipeline states in preparation for vertex and pixel processing."

Link to source: http://msdn.microsoft.com/en-us/library/windows/desktop/bb173347(v=vs.85).aspx

The effect states I'm looking at in DS2 are specifically texture stage states.

How MS briefly describes Texture Stage States:

"Texture stage states set up textures and the texture stages in the multitexture blender."

MS isn't terribly helpful unfortunately. However, I believe I figured what these I want to tinker with is called.

This MS link on blending helps visualize how the texture stage states work:

Texture Blending (Direct3D 9)
http://msdn.microsoft.com/en-us/library/windows/desktop/bb206241(v=vs.85).aspx

We only have access what GPG allowed in gas files. They likely did this for easy tweaking, which is quite a feature.

Color operator or ColorOp at Nvidia's site:

http://http.developer.nvidia.com/Cg/ColorOp.html (colorop is a state DS2 uses often).

Colorarg is discussed briefly here:

http://http.developer.nvidia.com/Cg/ColorArg1.html

"Description

Specify that this texture-stage state is the first color argument for the stage. See the D3DTSS_COLORARG1 texture stage state description for DirectX 9.

The standard reset callback sets the ColorArg1 state to int(Texture)."

I have not tested any of the valid enumerants (Constant, Current, Diffuse, SelectMask, Specular, Temp, Texture, TFactor) . GPG uses the following valid enumerants mentioned here: texture, diffuse, and current in gas files. TFactor (texture factor) is mentioned but not used in glow.fx, but any of these valid enumerants would work in HLSL (the language .fx files are written in).

Here are some comments from glow.fx talking about TFactor (it's not used in glow.fx).

/*
// Can multiply by tFactor if needed
TextureFactor = 0xFFFF0000; // glow tfactor ( multiply glow texture with this color value )
ColorOp[0] = MODULATE;
ColorArg1[0] = TEXTURE;
ColorArg2[0] = TFACTOR;
*/

They clearly decided to ditch it. It would be interesting to reactivate it to see what effect it has. Perhaps it magnified the glow too much.

Edit:

From my past documentation I cited a book called "Definitions from Introduction to 3d Game Programming" on blending which helps understand terms and how this stuff works.

"Blending Chapter 12

Many objects in the real world are semi-transparent, such as water and glass. In this chapter, we examine a technique called blending that allows us to blend (combine) the pixels that we are currently rasterizing with the pixels that were previously rasterized to the back buffer; that is, if pij is the source pixel we are currently rasterizing, then pij is blended with the previous ijth destination pixel on the back buffer bij. This technique enables us, among other things, to render semi-transparent objects.

src = source (The pixel currently being computed that is to be blended with the pixel on the back buffer.)( dest = destination (written on the back buffer) (DestPixel: The pixel currently on the back buffer.
)
How would we accomplish this? As we are rasterizing the teapot's triangles on top of the crate, we need to combine the pixel colors being computed for the teapot with the pixel colors of the crate in such a way that the crate shows through the teapot. The idea of combining the pixel values that are currently being computed (source pixel) with the pixel values previously written on the back buffer (destination pixel) is called blending. Note that the effect of blending is not limited to ordinary glass-like transparency. We have a variety of options that specify how the colors will be combined as will be seen in §12.2."

GPG uses whats called srcblend (also used a lot in SFX) which specifies the source of what is to be blended I think.

blogs: