Frictional Games Forum (read-only)
[LVL ED] Black&White screen effect possible? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [LVL ED] Black&White screen effect possible? (/thread-19743.html)

Pages: 1 2 3 4 5 6


Black&White screen effect possible? - Daemian - 12-31-2012

i know you can get a red screen effect using FadeSepiaColorTo
anyone knows how to make it colorless ?

ty


RE: Black&White screen effect possible? - FlawlessHappiness - 12-31-2012

Nope... I don't think it's possible...
You might have to implement some custom effects.. I have no idea how to do that


RE: Black&White screen effect possible? - Statyk - 12-31-2012

I haven't tested it, but you could try running shaders in a FC and edit the shader's .glsl with Notepad(++)... Perhaps some values in there could change things to make it greyscale. Again, I've never done it, it's just an idea. My guess is the shader just provides a color overlay, so I don't know if it will work the way you hope.

EXPERIMENTATION IS KEY.


RE: Black&White screen effect possible? - TheGreatCthulhu - 12-31-2012

I think what Statyk said could be the right way to go about it. Also, IIRC, the game achieves sepia tone filter by using a simple gradient image, black/dark-reddish -to- dark-orange -to- white, as a "color replacement file", so it could be possible to force it to use a different immage (black -to- gray -to- white gradient) to achieve the B&W effect in a custom story, but I'm not sure.


RE: Black&White screen effect possible? - BonesTheRabbit - 01-01-2013

(12-31-2012, 07:16 PM)TheGreatCthulhu Wrote: Also, IIRC, the game achieves sepia tone filter by using a simple gradient image, black/dark-reddish -to- dark-orange -to- white, as a "color replacement file", so it could be possible to force it to use a different immage (black -to- gray -to- white gradient) to achieve the B&W effect in a custom story, but I'm not sure.

I checked this out, but changing the file straight up didn't seem to work. There's something more to it. Needless to say, I'm following this thread's progress. I was also interested in a desaturated screen effect. I had intended on creating re-textured entities, but if there's a way to get a shader working, then hot dog!

P.S. What does FC stand for?


RE: Black&White screen effect possible? - FlawlessHappiness - 01-01-2013

Full Conversion


RE: Black&White screen effect possible? - BonesTheRabbit - 01-01-2013

I'm treading into pretty unknown territory right now. But I apparently found a black and white shader. I just have no idea how to apply it for use in the game yet. Still trying, though.

Code:
uniform sampler2D tex;

void main() {
   vec4 FragColor = texture2D(tex, gl_TexCoord);
   gl_FragColor = max(FragColor.r,max(FragColor.g,FragColor.b));
}

Update: Okay, so I believe that "amnesia the dark descent\core\shaders\posteffect_color_conv_tex_frag.glsl" is the sepia shader, based on my inference of the name, and the fact that fiddling with it makes the in-game sepia effect go pitch black (but nothing else). Closer, I guess! Now how to convert this from a sepia tone, to desaturation!

Code:
////////////////////////////////////////////////////////
// PostEffect Bloom Blur - Fragment Shader
//
// Blur effect for the bloom post effect
////////////////////////////////////////////////////////
#version 120

#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect diffuseMap;
@define sampler_diffuseMap 0

uniform sampler1D convMap;
@define sampler_convMap 1

@ifdef UseFadeAlpha
    uniform float afFadeAlpha;
@endif

void main()
{
    vec3 vDiffuseColor = texture2DRect(diffuseMap, gl_TexCoord[0].xy).xyz;
    
    vec3 vOutput =  vec3    (texture1D(convMap, vDiffuseColor.x).x,
                   texture1D(convMap, vDiffuseColor.y).y,
                 texture1D(convMap, vDiffuseColor.z).z);
    
    @ifdef UseFadeAlpha
        gl_FragColor.xyz = vOutput*afFadeAlpha + vDiffuseColor*(1-afFadeAlpha);
    @else
        gl_FragColor.xyz = vOutput;    
    @endif    
}

I'm starting to pick things apart. diffuseMap seems to be what determines the actual color of an object. The problem I'm seeing is that it also appears to be an overlay effect? Which means that it can't be used to desaturate, only adjust hues. I might be wrong in that.

"amnesia the dark descent\textures\effects\colorconv_sepia.tga" definitely plays a role in this. Adjusting the hue led to some odd effects. I changed it to a blue color instead of orange, and things got darker, but lights still remained red in color (torches, etc). Specular effects (shine and the like) seems to be a bright pink, as well.

Commenting out almost any part of the code results in a pitch black screen when the sepia effect is active. Trying to achieve a lack of effect and work from there. So desperately confused.

Update: Starting to identify pieces, I think. Bear in mind that I'm learning blind.

Code:
////////////////////////////////////////////////////////
// PostEffect Bloom Blur - Fragment Shader
//
// Blur effect for the bloom post effect
////////////////////////////////////////////////////////
#version 120

// I have no clue what this is.
#extension GL_ARB_texture_rectangle : enable

// Controls color diffusing? I don't know the syntax at all.
uniform sampler2DRect diffuseMap;
@define sampler_diffuseMap 0

// This is really throwing me off. I'm guessing this controls the lighting?
uniform sampler1D convMap;
@define sampler_convMap 1

// Defines fading early on.
@ifdef UseFadeAlpha
    uniform float afFadeAlpha;
@endif
// End of initial fading.

// Main effect variables.
void main()
{
    // This defines the color used for diffusing on the gradient, I think?
    vec3 vDiffuseColor = texture2DRect(diffuseMap, gl_TexCoord[0].xy).xyz;
    
    vec3 vOutput =  vec3(
    
                texture1D(convMap, vDiffuseColor.x).x,
                  texture1D(convMap, vDiffuseColor.y).y,
                texture1D(convMap, vDiffuseColor.z).z
                
                );
// End of effect variables.

// Fading in and out.
    // Checks to see if the effect is supposed to be only partially visible.
    @ifdef UseFadeAlpha
        // If it is, it adjusts the alpha accordingly.
        gl_FragColor.xyz = vOutput*afFadeAlpha + vDiffuseColor*(1-afFadeAlpha);
    @else
        // If it is not, then the alpha is 100% visible.
        gl_FragColor.xyz = vOutput;    
    @endif    
// End of fading.
}

Stepping away from this for a bit.


RE: Black&White screen effect possible? - TheGreatCthulhu - 01-01-2013

I was also looking at that shader, but didn't perform any tests yet. Like yourself, I'm not that familiar with GLSL, but from what I do know, my guess is that the shader samples the diffuse map (diffuse here just means object's color component), which is probably the screen buffer itself, and then simply picks some colors from the convMap ("conversion Map" - probably that sepia gradient image) based on the values of diffuse color components. The picked colors then replace the original colors in the output, or if UseFadeAlpha is defined, the two are blended.

Now, those gl_ variables are predefined variables, apparently used for input/output.

The final, output color of the pixels (or rather, fragments) is set in the final lines, where the value of gl_FragColor.xyz is assigned.

Line by (relevant) line, I'm pretty sure that this is what's happening:

Code:
vec3 vDiffuseColor = texture2DRect(diffuseMap, gl_TexCoord[0].xy).xyz;
The vec3 type is simply a 3-component vector, so vDiffuseColor is used to store the input RGB components for the current pixel (more precisely, texel). The texture2DRect function just samples the diffuseMap texture, whereby texture coordinates, gl_TexCoord[0].xy, are automatically advanced by the shader.
So, after that line, vDiffuseColor should contain the original screen color. You can test this by simply ignoring vOutput, by writing

vOutput.xyz = vDiffuseColor;

(or maybe: vOutput = vDiffuseColor;)

just under the vOutput calculation, and thus assigning vDiffuseColor to gl_FragColor intead. This should result in no changes (color-wise) when the sepia effect is invoked (didn't test yet though).

Now, for the B&W shader this line would go away, but I'd like to say what I think it does anyway:

Code:
vec3 vOutput =  vec3(
                texture1D(convMap, vDiffuseColor.x).x,
                texture1D(convMap, vDiffuseColor.y).y,
                texture1D(convMap, vDiffuseColor.z).z
                );

Each of the texture1D() calls sets a color component of the output. Now, convMap is treated as a 1D texture, that is, it's just a row of pixels. The second cparameter to texture1D function is the coordinate into the texture, 0.0 being on the left, 1.0 being on the right. As color components are also (I think) stored as values in the [0.0, 1.0] range, the value of the diffuse color component is used as an "index" to the replacement pixel's color component in the 1D texture. So, assuming that convMap is that sepia tone gradient, higher original color values, closer to white, will tend to be replaced by colors on the right of the gradient, while darker, lower values, by colors on the left.


Now, if what I said about vDiffuseColor is the case, there's a relatively simple way to convert to black and white, based on luminosity of the pixel.

To convert a color RGB pixel to black and white (or rather grayscale) the same way as "Desaturate" works in Photoshop, you just need to add all of the color components together and divide with 3.

It should look something like this (if anyone here is good with GLSL, make additional coorections to this code if required, maybe I've overlooked something):

Code:
float outputColor = vDiffuseColor.x + vDiffuseColor.y + vDiffuseColor.z;
outputColor /= 3.0f;

vec3 vOutput =  vec3(outputColor, outputColor, outputColor);

Will do a test soon. The real question is: can you make the game use this shader for a custom story, but not for the main game...

Yup, got grayscale image. Big Grin

[Image: 8333148947_932cedf6b4_c.jpg]

In case you're wondering why that map looks familiar - it's a small, stripped down test map I made from the original first level of amnesia (near the corridor where you wake up).

EDIT: Just in case, here's the shader (only the main() function, a simple change).
PHP Code:
void main()
{
    
vec3 vDiffuseColor texture2DRect(diffuseMapgl_TexCoord[0].xy).xyz;
    
    
// vec3 vOutput =  vec3    (texture1D(convMap, vDiffuseColor.x).x,
                   // texture1D(convMap, vDiffuseColor.y).y,
                 // texture1D(convMap, vDiffuseColor.z).z);
                 
    
float outputColor vDiffuseColor.vDiffuseColor.vDiffuseColor.z;
    
outputColor /= 3.0f;

    
vec3 vOutput =  vec3(outputColoroutputColoroutputColor);
    
    @
ifdef UseFadeAlpha
        gl_FragColor
.xyz vOutput*afFadeAlpha vDiffuseColor*(1-afFadeAlpha);
    @else
        
gl_FragColor.xyz vOutput;    
    @endif    


Now to figure out if this can be mod-specific...

BTW, I still wouldn't give up on the sepia gradient map - the one I was referring to is located at:
redist\textures\effects\colorconv_sepia.tga


RE: Black&White screen effect possible? - TheGreatCthulhu - 01-01-2013

Did some tests with the gradient map as well (redist\textures\effects\colorconv_sepia.tga); because of the way the (original) shader was written, the gradient map can only be used for color tinting (and in a somewhat unpredictable way at that...), but not for saturation. Using a grayscale gradient acts similar to the "Levels" photoshop filter (brightness affected, color hues same).

[Image: 8333321007_d7343df69a_b.jpg]

Larger image here.


RE: Black&White screen effect possible? - BonesTheRabbit - 01-02-2013

[Image: zR7lV.png]

Seriously, though. Well done sir! I feel like a sham in comparison, to be quite honest. But now I'm just wondering if the sepia effect shares with the wounded state. Tested and can confirm that they're different shaders. Thought so.