Author Topic: NWShader  (Read 9325 times)

Legacy_pkpeachykeen

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +0/-0
NWShader
« Reply #45 on: August 13, 2010, 09:09:23 pm »


               @faedanz: Relatively soon, we just have to tweak a few more things and finish up some components.



@Chico: I'm not sure what the problem with depth-of-field is. I've tested the code more than once, it is definitely correct. Using an old shader with the fix in this thread will work, until I can definitively figure out why the new method doesn't work.



@Tarot: You mean something like a radial blur, blurring out from a point on the screen? I haven't watched LoTR in a while, so I don't remember the scene, but I'm betting that's similar. It's definitely possible to only blur parts of the screen. You can also control the depth in DoF by a script, for a Witcher-like cinematic focus.
               
               

               
            

Legacy_nwn_martin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
NWShader
« Reply #46 on: August 13, 2010, 11:27:13 pm »


               hello pk, i believe he means the effect when you are trying to keep the visual proportions of frodo on the monitor intact while you physicaly move away (or towards the object) with the camera. to achieve that you have to rotate the objective to keep the object from changing. the surrounding then seems to move in a special way, and you get the feel of diving. but its just a perspective change effect.
               
               

               
            

Legacy_pkpeachykeen

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +0/-0
NWShader
« Reply #47 on: August 14, 2010, 03:41:29 am »


               Ah. That makes sense.



Well, in order to do that... there's no easy way to mask out one object in particular, but it's certainly possible to do some kind of zoom-type deal on an area. It's very similar to radial blur, kind of a stretch-out-from-center. The actual shader code should be relatively straight-forward, I think.
               
               

               
            

Legacy_chico400

  • Newbie
  • *
  • Posts: 37
  • Karma: +0/-0
NWShader
« Reply #48 on: August 14, 2010, 08:20:05 am »


               hi peachy,



I mean that all the screen is always blured, center, foreground and background, even if i rotate the camera or zoom/unzoom. It does not make this issue with Asgorath but only with the new one. (no logs because no crash)



I've looked at the new scripts and seen that the DOF script use new focus lines code, when i disabled this lines codes all the screen is clear, but the DOF effect go away *snif*.



i use last drivers nvidia version 258.96, an "outofthebox" Chronepsis 0.2.2.3's nwshader.

the only difference with your install is the localisation... i'm french.



could you remove the localisation in nwshader to test, because it make crash the nwshader GUI and may be involved in the DOF issue, or let us to select localisation manually?



i know that sometime localisation can be a problem for a program.



Is somebody localised too in Fr, to see if they have the same issue?



thanks friends '<img'>
               
               

               
            

Legacy_chico400

  • Newbie
  • *
  • Posts: 37
  • Karma: +0/-0
NWShader
« Reply #49 on: August 14, 2010, 08:56:02 am »


               i've made some tests, and it seems that "distance = tex2D(depthFrame, uv).r" function  always return the same value for me, in this code (tried too staticfocus mode),

as the shader consider that distance is always greater than tfocus, even if tfocus is fixed to staticfocus = 0.98f

i've checked and "calculated depth & focus" are activated in gui

float4 DoF(in float2 uv : TEXCOORD0) : COLOR
{
    float distance = 0;
    float tfocus = 0;
    float factor = 0;
    
    float n = 1.0;
    float f = 1000.0;

    float4 color = tex2D(lastShader, uv);
    float4 blur = tex2D(lastPass, uv);
    
    distance = tex2D(depthFrame, uv).r;

    if ( mode == 0 )
    {
        tfocus = focus; //tex2D(depthFrame, float2(0.5, 0.5)).r;
    } else {
        tfocus = staticfocus;
    }

    distance = (2.0 * n) / (f + n - distance * (f - n));
    tfocus = (2.0 * n) / (f + n - tfocus * (f - n));
    factor = abs(distance - tfocus); // Should be 0 - 0.5
    
    if ( distance < tfocus )
    {
        factor *= 2.175; // 0 - 1.250;
    } else {
        factor *= 2.075; // 0 - 1.125; <<<<<<<< always use this line
    }

    factor *= factor; // 0 - 1.26 if farther, 0 - 1.56 if near
    factor = clamp(factor, 0, 1.35);
    
    color.rgb = lerp(color.rgb, blur.rgb, factor.rrr);
    
    return float4(color.rgb, 1.0);
    
}

if i change the code to

"    if ( distance < tfocus )
    {
        factor *= 2.175; // 0 - 1.250;
    } else {
        factor *= 0; // 0 - 1.125;
    }
"

all my screen is clear with no blur so the shader always use the "distance > tfocus" case, it means , i guess' that "calculated depth " option does not function correctly for me
               
               

               


                     Modifié par chico400, 14 août 2010 - 08:35 .
                     
                  


            

Legacy_nwn_martin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
NWShader
« Reply #50 on: August 14, 2010, 10:07:53 am »


               how do you tell the shader to check distances against a our focal distance beginning at your camera coordinates (lets say center of the viewport for the simplicity of things), continuing along the perpendicular line of sight from the camera in front of you, and ending at the nearest object the line of sight colides with? i havent begun studying the cg language yet, oops.

edit: crunching through the nwshader wiki now. 'Posted
               
               

               


                     Modifié par nwn_martin, 14 août 2010 - 09:55 .
                     
                  


            

Legacy_chico400

  • Newbie
  • *
  • Posts: 37
  • Karma: +0/-0
NWShader
« Reply #51 on: August 14, 2010, 10:22:58 am »


               i confirm that the "Calculate Depth" function return always 1.0 for me

if i use this code

       distance = tex2D(depthFrame, uv).r;
    if ( distance < 0.9){
        factor = 0;
    } else {
        factor = 10.0;
    }

the screen is fully blured

if i use this

       distance = tex2D(depthFrame, uv).r;
    if ( distance < 1.1){
        factor = 0;
    } else {
        factor = 10.0;
    }

it is fully clear

so the problem seams to be on the "Calculate Depth" function in Basic setting of nwshader

peachy do you have a clue for me?

thank my friend ^^
               
               

               


                     Modifié par chico400, 14 août 2010 - 09:28 .
                     
                  


            

Legacy_nwn_martin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
NWShader
« Reply #52 on: August 14, 2010, 11:22:57 am »


               chico, the problem may be with the fact that nwshader supplies the shaders with a distance measured from a one of the the corners of the screen instead of center or sligtly above center, where the head of our character is supposed to be and watch from that point.
'Posted
peachy will have to enlighten us on that. 'Posted

the dof effect kind of works for me at least in that, if i zoom out, after one second the picture becomes clear from a blured state. i had to change the setting of the focusing speed in the nwshader gui, the default value of 2.00 is just too slow. i think it should not be so big or it confuses people and makes them think the bluriness will stay forever.
 'Posted
i remember reading something about smoothing the focusing function with some quadratic element, and if there is time involved, then 2.00 seconds become 4, if someone sets 3.00 then the blurriness will last 9 seconds before it changes, and so forth..
'Posted
dont mind my thinking aloud. 'Posted

edit: playing with the dof, i think it works, but the first obstacle from the camera is almost always the character you play, so thats why you cant focus far objects..
'Posted
we need to change the sampling coordinte for the camera in the line of sight. maybe people with the camera hack http://nwvault.ign.c....Detail&id=1358 are going to have this problem solved by itself, because the camera is situated in front of your character.
'Posted

edit2: forget about camera hack. set the camera min distance in nwshader gui to -0.5 before you start nwmain.exe (i cant seem to be able to change it while the game is running). set the focus shift to 1.00, so that it happens faster. in the game hit the "home" button to set the camera to the min distance. enjoy peachy dof zooming.
'Posted
               
               

               


                     Modifié par nwn_martin, 14 août 2010 - 12:23 .
                     
                  


            

Legacy_pkpeachykeen

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +0/-0
NWShader
« Reply #53 on: August 14, 2010, 06:21:21 pm »


               @chico: Did you have any problems with depth of field previously? I think I may know where the issue is, if only this latest version is broken. For better precision, I changed the depth buffer from being DF16 (16-bit floating point) to either D24S8 (depth 24-bit integer and 8-bit stencil) or DF32 (32-bit floating point). I've heard some rumors that certain cards, particularly old nVidia (if I remember correctly) had problems with 32-bit textures.

It should be possible to add an option to use any of those 3 formats, which should fix the issue for everyone.



@nwn_martin: The calculation is smoothly linear, that is, it uses this formula:

focal distance = linearly interpolate between (current focal distance, current distance, ( frame delta / set value ) )
Delta is the time between frames in seconds, so it adapts for faster/slower FPS.

It will constantly come closer to the true value, and in the set amount of time, should approximately equal the distance. You should be able to see that by zooming out quickly, it will lag for a moment, then quickly resolve. Same thing happens when you zoom in.

It does, on both smooth and instant, focus on the center of the screen (more or less, it may be off by half a pixel or so).



As far as using the camera hack, you don't need that with the latest NWShader, it's included. I've also increased the options, so you can tweak it quite a bit. You can't change it during the game, since it only applies when the game starts based on the saved settings, but you can do whatever.



And like you said, in first-person view with DoF, you get correct viewing. It especially looks great when you walk up to an NPC.
               
               

               
            

Legacy_nwn_martin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
NWShader
« Reply #54 on: August 14, 2010, 07:54:09 pm »


               pk, set the focus shift to 9.0, load an area, zoom out full with "end" key for the quickness of it, and just tell me how many seconds have to pass before the view starts to deblur. and then tell me why this initial delay has to be there.
ps: i think we may need a cross hair for aiming the center at objects, heh.

edit: also, the focus shift only controls focusing distant objects (enlarging the distance), where as focusing close objects is constant with various setting. its fast, which is not bad, but could use a setting too.

edit2: depth of field focus transfer:
               
               

               


                     Modifié par nwn_martin, 15 août 2010 - 12:53 .
                     
                  


            

Legacy_chico400

  • Newbie
  • *
  • Posts: 37
  • Karma: +0/-0
NWShader
« Reply #55 on: August 15, 2010, 08:37:31 pm »


               hi,

i did not have the problem with previous releases.
i used every days asgorath or older versions with absolutly no problems

my card is a nvidia 8600gts 512 mb ram, may be you're right with your clue

it would be great if you could correct this.

You know, i'm nwshader-adict  now^^

thanks peachy '<img'>
               
               

               


                     Modifié par chico400, 15 août 2010 - 07:45 .
                     
                  


            

Legacy_chico400

  • Newbie
  • *
  • Posts: 37
  • Karma: +0/-0
NWShader
« Reply #56 on: August 15, 2010, 10:33:04 pm »


               just tested Bahamut version, and DOF work fine with this one too.



i guess you're right peachy with the DF32 issue on Chronepsis version ^^



i hope it's easy to correct



ciao ^^
               
               

               
            

Legacy_Dark_Ansem

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
NWShader
« Reply #57 on: September 02, 2010, 09:16:36 am »


               we want this for Dragon age too!
               
               

               
            

Legacy_Jez_fr

  • Sr. Member
  • ****
  • Posts: 460
  • Karma: +0/-0
NWShader
« Reply #58 on: September 06, 2010, 04:04:00 pm »


               Is this stopped? :/
               
               

               
            

Legacy_nwn_martin

  • Newbie
  • *
  • Posts: 7
  • Karma: +0/-0
NWShader
« Reply #59 on: September 06, 2010, 07:47:12 pm »


               i hope not, jezira. i posted some feedback on the project's forum at sourceforge to engage in a discussion, let's see if it stirs things up. you can join with your feedback too and make complaints about somebody else's feedback '<img'>