Ticket #2111: hqdofFix.patch

File hqdofFix.patch, 2.6 KB (added by wraitii, 10 years ago)
  • binaries/data/mods/public/shaders/effects/postproc/HQDOF.xml

     
    44        <require shaders="glsl"/>
    55        <pass shader="glsl/hqdof">
    66            <define name="manualdof" value="true"/>
     7            <define name="showFocus" value="false"/>
    78
    8             <define name="focalLength" value="1000"/>
    9             <define name="fstop" value="200"/>
     9            <define name="focalLength" value="1000.0"/>
     10            <define name="fstop" value="200.0"/>
    1011
    1112            <define name="samples" value="3"/>
    1213            <define name="rings" value="3"/>
     
    1617            <define name="fdofstart" value="30.0"/>
    1718            <define name="fdofdist" value="40.0"/>
    1819
    19             <define name="maxblur" value="2"/>
     20            <define name="maxblur" value="2.0"/>
    2021
    2122            <define name="threshold" value="0.9"/>
    2223            <define name="gain" value="2.0"/>
  • binaries/data/mods/public/shaders/glsl/hqdof.fs

     
    5353----------------------
    5454
    5555*/
     56#version 120
    5657
    5758uniform sampler2D renderedTex;
    5859uniform sampler2D depthTex;
     
    6667uniform float focalDepth;  //focal distance value in meters, but you may use autofocus option below
    6768//uniform float focalLength = 1000; //focal length in mm
    6869//uniform float fstop = 200; //f-stop value
    69 uniform bool showFocus = false; //show debug focus point and focal range (red = focal point, green = focal range)
     70//uniform bool showFocus = false; //show debug focus point and focal range (red = focal point, green = focal range)
    7071
    7172/*
    7273make sure that these two values are the same for your camera, otherwise distances will be wrong.
     
    119120float bdepth(vec2 coords, float blursize) //blurring depth
    120121{
    121122    float d = 0.0;
    122     float div = 0;
     123    float div = 0.0;
    123124    float kernel[9];
    124125    vec2 offset[9];
    125126
     
    218219        float b = (a-fdofstart)/fdofdist; //far DoF
    219220        float c = (-a-ndofstart)/ndofdist; //near Dof
    220221        blur = (a>0.0)?b:c;
    221         blur /= max((fDepth / 15) - 7, 1);
     222        blur /= max((fDepth / 15.0) - 7.0, 1.0);
    222223    }
    223224    else
    224225    {
     
    233234        blur = abs(a-b)*c;
    234235    }
    235236
    236     return clamp(blur, 0, 1);
     237    return clamp(blur, 0.0, 1.0);
    237238}
    238239
    239240varying vec2 v_tex;
     
    283284    vec3 samplecolor = color;
    284285    float samplediv = 1.0;
    285286
    286     int ringsamples;
     287    float ringsamples;
    287288
    288289    for (int i = 1; i <= rings; i += 1)
    289290    {