Risultati da 1 a 6 di 6

Discussione: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

  1. #1
    heXen
    ospite

    Predefinito [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

    here's a water renderer I've been working on:



    vi riporto il comunicato e il codice, scusate se non traduco ma fra parole e codice io non ci capisco niente






    It uses a mirrorRenderMap and a custom shader to blend it with the current render, so far the features are:

    - viewangle dependent blending
    looking down shows you the bottom and looking into horizon will reflect (mirror)
    - normal map blending
    two maps scroll at different speeds and get blended for an "animated" result
    - specular highlights (optional, included as a separate material)

    MirrorRenderMap has a TON of bugs.
    Most annoying is the one that causes the texcoords to offset on X-axis, it seems to originate from the leveleditor. Adjusting the parameters at the surface inspectors sometimes fixes this.
    Then you can't put anything under the water. Things get mirrored above the water (looks really stupid).
    The engine likes to clip out the mirror alot, manytimes when the mirror is very much visible to the player. On one of my test levels I fixed this by making the surface larger, as if the mirror was clipped when player was not standing on it (even when the surface was underneath other surfaces).

    Anyhow, here's the file:
    http://www.johdin.net/waterdemo.pk4

    There's a map "water01" that demonstrates the water shaders. The fog is created in the leveleditor. I looked into making a depth relative fog but turns out you can only access one z value from the fragment program, that's the current z (would have needed previous z to compare).

    Inside the shader (water02.vfp) you can adjust the distortion size (it's marked with a comment) which seems to jump 10x from level to level. Sometimes 0.02 is apporiate and sometimes 0.2. There's also a line that temporarily fixes the offset bug (currently commented out).

    the interactions.vfp has been changed to an altered version of my other mod ( http://doom3.filefront.com/file/Brillian t_Highlights;55660) mainly to get the specular highlights look any good.

    I'm getting busy with my job towards the summer so I tought I release this for you guys to work on.

    Last edited by maha_x on Mon Feb 20, 2006 4:00 pm; edited 1 time in total





    i noticed this in your shader:

    Code:

    ### fetch, R2 is currentRender, R1 is mirrorRenderBuffer
    TEX R1, TC1, texture[1], 2D;
    TEX R2, TC2, texture[0], 2D;


    is it possible then to distort only the mirror image created by the mirrorRenderMap command?

    as you may have noticed, using "_currentRender" also distorts objects in front of the water. crank up the distortion and you'll easily see the player's hands and weapon distort along their edges.

    so far, i don't think anyone has solved this yet. even raven software didn't find a solution they were comfortable enough with.

    but here's the catch: for my water, i don't care about distorting objects under the water. i have deep lake water in my map so nothing is really visible below the surface anyway.

    i do care about distorting the reflected image.

    so is there a way to send the buffered mirror image to a pixel shader, distort it and then render it to the screen?

    i don't know how to write pixel shaders so i could use your help.


    I'm sure raven would have got it working if they needed it...

    anyhow, it should work like this (change this segment):

    Code:

    ### convert pixel position to texcoord
    MUL TC1, fragment.position, program.env[1];

    ### this fixes the occational offset bug temporarily
    #ADD TC1.x, TC1.x, -0.145;

    ### distort by localnormal
    ADD_SAT TC1, TC1, localNormal;

    MOV TC2, TC1;
    MUL TC2, TC2, program.env[0];

    ### fetch, R2 is currentRender, R1 is mirrorRenderBuffer
    TEX R1, TC1, texture[1], 2D;
    TEX R2, TC2, texture[0], 2D;


    change to

    Code:

    ### convert pixel position to texcoord
    MUL TC1, fragment.position, program.env[1];
    MOV TC2, TC1;

    ### this fixes the occational offset bug temporarily
    #ADD TC1.x, TC1.x, -0.145;

    ### distort by localnormal
    ADD_SAT TC1, TC1, localNormal;

    MUL TC2, TC2, program.env[0];

    ### fetch, R2 is currentRender, R1 is mirrorRenderBuffer
    TEX R1, TC1, texture[1], 2D;
    TEX R2, TC2, texture[0], 2D;


    this should bypass the distort for the currentRender (didn't test)

  2. #2
    La Borga L'avatar di covin
    Data Registrazione
    17-09-03
    Messaggi
    13,275

    Predefinito Re: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

    Mi pare buono!!!

  3. #3
    Lo Zio L'avatar di Vision83
    Data Registrazione
    21-07-02
    Località
    I'm Dead, Jim
    Messaggi
    1,541

    Predefinito Re: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)



    è davvero interessante, nonchè fatto decisamente bene.

    "Then you can't put anything under the water. Things get mirrored above the water (looks really stupid)."

    questo è veramente speriamo che lo corregga, anche se in certi frangenti può essere interessante.

    in pratica, piazzi un oggetto sott'acqua, e questo viene duplicato sopra per effetto specchio inverso

  4. #4
    heXen
    ospite

    Predefinito Re: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

    esatto


    voglio le onde

  5. #5
    Lo Zio L'avatar di mattoxo
    Data Registrazione
    12-09-02
    Località
    Roma
    Messaggi
    3,159

    Predefinito Re: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

    bello!

  6. #6
    Lo Zio L'avatar di Vision83
    Data Registrazione
    21-07-02
    Località
    I'm Dead, Jim
    Messaggi
    1,541

    Predefinito Re: [DooM III] : in lavorazione Shader per l'acqua (attenzione 56k)

    Post Up tutorial utile [Anti Apocafud]

Permessi di Scrittura

  • Tu non puoi inviare nuove discussioni
  • Tu non puoi inviare risposte
  • Tu non puoi inviare allegati
  • Tu non puoi modificare i tuoi messaggi
  • Il codice BB è Attivato
  • Le faccine sono Attivato
  • Il codice [IMG] è Attivato
  • Il codice HTML è Disattivato