Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Level Editor Help Black&White screen effect possible?
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#1
Video  Black&White screen effect possible?

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

ty

12-31-2012, 05:14 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Black&White screen effect possible?

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

Trying is the first step to success.
12-31-2012, 01:26 PM
Find
Statyk Offline
Schrödinger's Mod

Posts: 4,390
Threads: 72
Joined: Sep 2011
Reputation: 241
#3
RE: Black&White screen effect possible?

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.
12-31-2012, 06:35 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#4
RE: Black&White screen effect possible?

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.
(This post was last modified: 12-31-2012, 07:17 PM by TheGreatCthulhu.)
12-31-2012, 07:16 PM
Find
BonesTheRabbit Offline
Member

Posts: 68
Threads: 20
Joined: Feb 2012
Reputation: 2
#5
RE: Black&White screen effect possible?

(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?
(This post was last modified: 01-01-2013, 07:19 AM by BonesTheRabbit.)
01-01-2013, 07:05 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#6
RE: Black&White screen effect possible?

Full Conversion

Trying is the first step to success.
01-01-2013, 10:26 AM
Find
BonesTheRabbit Offline
Member

Posts: 68
Threads: 20
Joined: Feb 2012
Reputation: 2
#7
RE: Black&White screen effect possible?

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.

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!

////////////////////////////////////////////////////////
// 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.

////////////////////////////////////////////////////////
// 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.
(This post was last modified: 01-01-2013, 03:48 PM by BonesTheRabbit.)
01-01-2013, 01:07 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#8
RE: Black&White screen effect possible?

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:

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:

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):

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: (Select All)
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
(This post was last modified: 01-01-2013, 05:46 PM by TheGreatCthulhu.)
01-01-2013, 05:11 PM
Find
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#9
RE: Black&White screen effect possible?

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.
(This post was last modified: 01-01-2013, 06:28 PM by TheGreatCthulhu.)
01-01-2013, 06:25 PM
Find
BonesTheRabbit Offline
Member

Posts: 68
Threads: 20
Joined: Feb 2012
Reputation: 2
#10
RE: Black&White screen effect possible?

[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.
(This post was last modified: 01-02-2013, 12:41 AM by BonesTheRabbit.)
01-02-2013, 12:35 AM
Find




Users browsing this thread: 2 Guest(s)