Jump to content

Modified shader


Emton

Recommended Posts

Hey would anyone know about modifying the shader, I want to adjust it so the highlights (brightest parts) aren't so bright and overexposed (which makes detail get lost) I found the files in the shader folder but I don't know anything about this GLSL language. Anyone have an idea how to make this adjustment? I have to run with no shader because of this...

Link to comment
Share on other sites

What you need to find is the fragment (aka pixel) shader. This one determines the color of each pixel on the screen.

 

You can find it by looking for the statement:

void main(){    [...some code...]    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);}
In this example each fragment would be colored white (1.0 == white, 0.0 == black). Changing the brightness won't be trivial without knowing how the shader calculates it (and which values it receives from the application itself though.

When I played around with PZ's shaders I only did trivial stuff like scanlines or inverting the colors.

Link to comment
Share on other sites

What you need to find is the fragment (aka pixel) shader. This one determines the color of each pixel on the screen.

 

You can find it by looking for the statement:

void main(){    [...some code...]    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);}
In this example each fragment would be colored white (1.0 == white, 0.0 == black). Changing the brightness won't be trivial without knowing how the shader calculates it (and which values it receives from the application itself though.

When I played around with PZ's shaders I only did trivial stuff like scanlines or inverting the colors.

 

 

Ok well the only place gl_FragColor appears in the shaders folder is in screen frag file. "gl_FragColor = vec4(col, 1.0);"  vec4 shows up in "const vec4 tint = vec4(1,1,1,1);" I'll mess with the numbers some and see if it has an effect.

 

Edit: It does have an effect I changed the 1's to .1 and it made the scene darker so I'll increase until I get it where it's better but if I knew what each 1 in vec4(1,1,1,1) meant it would help.

Link to comment
Share on other sites

Just make sure that the shader returns a four-component vector in the end. That's the color the pixel on which the shader is applied will receive.

I used the screen.frag file to do this stuff like this:

virBV8w.jpg

IIRC correctly the shader also contains the code for applying different tints for night / day lights, but I don't know if the values are coded into the shader or sent over from the engine.

Link to comment
Share on other sites

Ok what I found that's giving a helpful effect is increasing the stuff on this line

const vec3 AvgLumin = vec3(0.4, 0.4, 0.4);

to .55

and  gl_FragColor = vec4(col, 1.0);

to .95

 

http://i.imgur.com/ql9uF1g.jpg

http://i.imgur.com/xEyAeYR.jpg

no shaders http://i.imgur.com/pNVh7fC.jpg

 

so if you look in those pictures you can see how the tile lines are a little easier to see. I'll keep trying it out and see how it looks in other places.

Link to comment
Share on other sites

Yeah, there is a contrast function in the shader where AvgLumin is subtracted from the rgb values, so the higher you

set it the darker it should become.

It's been a while since I played around with shaders, but you should leave the fourth component of gl_FragColor at 1.0 because that's the alpha channel (IIRC).

Link to comment
Share on other sites

Yeah, there is a contrast function in the shader where AvgLumin is subtracted from the rgb values, so the higher you

set it the darker it should become.

It's been a while since I played around with shaders, but you should leave the fourth component of gl_FragColor at 1.0 because that's the alpha channel (IIRC).

 

I think you're right in the 2nd picture you can see the erosion is more transparent. I think I'll leave it for now and see how it works. Well I like this so far thanks for your help, I think this is an improvement for recovering some of the details in the highlights, also it makes night time more dangerous as it's quite a bit darker. I still wish the devs would tweak it so you get back most if not all of the detail you can see using no shaders though...

 

original http://i.imgur.com/h9JR7kt.jpg

http://i.imgur.com/sVtv60v.jpg

no shader http://i.imgur.com/4chz0Sf.jpg

 

Here's the erosion you can see the transparency better, I think it looks pretty good, I always thought the game might look better with more transparency like in trees and grass, also more animation, maybe even stuff like bugs that jump around and the ability to catch and eat them, oh I'm such a treasure trove of ideas.

 

http://i.imgur.com/bpU8Fkk.jpg

Link to comment
Share on other sites

Athghggh it's just not good enough still have super bright areas where ever there's a light during the day more so. I've tried changing so many numbers just can't get that bright point highlight to be less, it needs to work like a curve where the highlight is less bright but the shadows and midtones stay where they're at.

Link to comment
Share on other sites

Hi there Emton,

I've played around with creating shaders from scratch for my own game engine quite a bit, and might be able to help you - a little at least.

 

The most obvious [simple] solution I can see, to your issue of brights being too bright, is to clamp the RGB values to something less than (0,1).

 

In a brief explanation, without having looked at the specific PZ shader in question, in layman's terms (I don't know how technical I can get without losing you)-

Those vec3 and vec4 values you're looking at are colours formatted as RGBA (or RGB in the case of vec3).

You probably understand the concept of red/green/blue combinations to represent a colour, but may recognise it in a different form (maybe as 0-F values, or 0-255).

The higher the value, the more of that colour is present, within the range 0-1. With 0 being none of a colour, or black if it's none of any colour, and 1 being full saturation of that colour, or white if all colours are fully saturated. (I think saturation is the right term to use here?)

You can imagine 'bright' things having a colour closer to white than black, or higher RGB values (playing around with the alpha channel is a dangerous game without knowing the exact consequences), than 'less bright' objects.

There's a GLSL function to clamp a value (you can Google for it), which is to either increase or decrease a given value so it falls within a given range. Depending on where you apply a clamp to the colours in the shader, will depend on what you're changing.

 

I'd imagine the easiest solution to your problem is to clamp colours to something like (0,0.8), to cut out the top range of brightness (without affecting the darker colours), while noting that this will also noticeably change other colours as it reduces the saturation range of each channel. Or maybe you'll want to play around some more (depending on your skill) and multiply colours by a (inverse?) logarithm or exponential function, or something else to work with your concept of a 'curve'.

I don't know exactly what, or why you'd want to do this, and I'm not sure it will give you back any detail in the overly bright places, because that will depend on the specific shader. Anyway, play around with clamping or reducing the colour values, and see what you come up with.

 

Depending on the type of lighting used in the PZ shaders, it might actually be easier to 'dim' the light rather than darken the objects.

Link to comment
Share on other sites

Ok well here is a screen shot with the shader:

 

http://i.imgur.com/8liVaRX.jpg

 

And no shader:

 

http://i.imgur.com/Qghwmxq.jpg

 

You can see a lot of detail on the bedsheets gets lost, even the pillows almost disappear, the texture on the mirror disappears too, it just looks way off how bright it is. I get it's adding contrast, giving the scene more punch or something but the shader should be smart enough to determine the brightest point (from the tile graphics) and not make it any brighter. If you ask me PZ graphics need all the detail it can get so it should avoid this overexposure.

 

Well i tried changing some of the existing clamp settings in the file and got some changes but not the correct one. Not sure where I should add in a clamp setting maybe around

const vec3 colHaze = vec3(63.0 / 255.0, 88.0 / 255.0, 155.0 / 255.0);const vec3 colDawn = vec3(165.0 / 255.0, 127.0 / 255.0, 64.0 / 255.0);const vec3 colDusk = vec3(215.0 / 255.0, 100.0 / 255.0, 13.0 / 255.0);orconst vec4 tint = vec4(1,1,1,1);orgl_FragColor = vec4(col, 1.0);

If I knew how to dim the light I'd try that, I tried increasing the "const vec3 AvgLumin = vec3(0.55, 0.55, 0.55);" it only helps a little bit and it makes everything darker. This language is pretty foreign to me I might just have to turn shaders off and try tweaking the tile graphics with photoshop...

Link to comment
Share on other sites

Well, Haze, Dawn, and Dusk are certainly not the ones to be clamping.

Tint, well, depending on what it is applying the tint to, it may be the one to drop, rather than clamp, to something like (0.8,0.8,0.8,1).

And lastly, frag colour is the colour applied to the fragment (pixel), so if you just want to desaturate the output colour, that would be the one to change (note, you wouldn't clamp that one, probably you'd just want to multiply it - add a line before).

 

The AvgLumin, as the name suggests, probably is the average/ambient brightness of the scene. You could drop that to something lower - but the dark parts will become much darker too!

 

Ideally, it would be none of those that you want to clamp, you're looking for an input colour (vec3 or vec4), which will be defined as Varying, not Constant.

It will probably look something like "varying vec3 vColor" or similar. You then want to find where that value is actually used within the calculations, and tweak things there. In an ideal situation though, if you haven't much experience with GLSL previously, it might be a bit difficult (It's pretty self-explanatory though, if you know or recognise basic lighting algorithms, you'll see the logic there).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...