[WIP] waterPack

ywabyywaby Posts: 10Member
edited May 22 in Projects


project at github
still in develop, not ready

Tagged:

Tags :

Comments

  • emo10001emo10001 Posts: 84Member

    Nice work so far! Looks good.

    Keep us posted. I'll definitely be watching.

    -emo

  • ywabyywaby Posts: 10Member

    I don't konw how to get reflection work, anyone has any idea?
    I had try to use camera to reflection.but something under water would effect reflect.

  • MegalomaniakMegalomaniak Posts: 748Admin

    Why reinvent the wheel why not use the godot internal reflection(roughness = 0;) assuming you are dealing with godot 3.

  • SIsilicon28SIsilicon28 Posts: 28Member

    Oh man I hate that!
    No not your addon! It's coming along great. :)
    I mean that darn bug with the geometry reflection. The only way I'd know to remove it is with clip planes. Which can indeed be implemented in a shader, but to use it on all shaders within the reflection rendering pass. I definitely would do a feature request to define clip planes to a viewport.

  • ywabyywaby Posts: 10Member

    reflection probe is just cubemap at point, not suitable

    SSR is just screen fx with screen texture, not suitable.

    I think suitable ways is:
    * unity FXWaterPro use separate render, upwater for reflection and render underwater for refraction,then mix it

    // Setup oblique projection matrix so that near plane is our reflection
     // plane. This way we clip everything below/above it for free.
    Vector4 clipPlane = CameraSpacePlane(reflectionCamera, pos, normal, 1.0f);
    reflectionCamera.projectionMatrix = cam.CalculateObliqueMatrix(clipPlane); // separate at water plane , only render upwater
    // Set custom culling matrix from the current camera
    reflectionCamera.cullingMatrix = cam.projectionMatrix * cam.worldToCameraMatrix;
    

    this way is fine for plane reflect, but not suitable for ocean with vertex wave .I don't konw how to get it in godot3.

    • real time ray tracing
      I think it perfect way for reflection and refraction. feature not support yet.

    I will leave reflection aside until find a way to achieve.

  • SIsilicon28SIsilicon28 Posts: 28Member

    Let me know if you figure out anything. K? ;)

  • ywabyywaby Posts: 10Member

    add foam and fix some bug.

  • SIsilicon28SIsilicon28 Posts: 28Member
    edited June 3

    Yeah. So after a lil bit of digging I found this post. It's a question from Zylann similar to yours. It may look like it didn't get an answer, but if you keep reading the comments you'll find out that he (sort of) answered his own question. It's really a hack. He suggests to use the method forward_spatial_gui_input. Its two parameters are an event and get this. The editor's camera! That's right! Planar reflection in editor are now within your grasp :wink:
    Now there are obviously a couple of problems. For one the method is owned only by the EditorPlugin class. But that shouldn't be an issue for you. And it also only gets called when you are currently editing a node from said plugin.

  • SIsilicon28SIsilicon28 Posts: 28Member
    edited June 3

    Nice ocean. Have you considered taking a look at mine? You can take some stuff out if you want. It's infinite too. :)

  • SIsilicon28SIsilicon28 Posts: 28Member

    I did a pull request for your project to help you out. ;)

  • ywabyywaby Posts: 10Member

    @SIsilicon28 said:
    I did a [pull request][1] for your project to help you out. ;)

    [1]: https://github.com/ywaby/godot-WaterPack/pull/1

    thanks I will merge it

  • ywabyywaby Posts: 10Member

    @SIsilicon28 said:
    Nice ocean. Have you considered taking a look at [mine][1]? You can take some stuff out if you want. It's infinite too. :)

    [1]: https://github.com/SIsilicon/Godot-Ocean-Demo

    I have look your code, good job, but inifine water will do after lod feature.

  • ywabyywaby Posts: 10Member

    @SIsilicon28 said:

    Yeah. So after a lil bit of digging I found [this post][2]. It's a question from Zylann similar to yours. It may look like it didn't get an answer, but if you keep reading the comments you'll find out that he (sort of) answered his own question. It's really a hack. He suggests to use the method forward_spatial_gui_input. Its two parameters are an event and get this. The editor's camera! That's right! Planar reflection in editor are now within your grasp :wink:
    Now there are obviously a couple of problems. For one the method is owned only by the EditorPlugin class. But that shouldn't be an issue for you. And it also only gets called when you are currently editing a node from said plugin.

    [2]: https://godotengine.org/qa/6369/how-to-get-the-editors-camera?show=6369#q6369

    I am moveing project to a addon now. that will make water more easy to used.
    but "forward_spatial_gui_input" not be called when spatial editor input, still look reason.

    tool
    extends EditorPlugin
    
    func forward_spatial_gui_input(p_camera, p_event):
        print("spatical action0")
        for node in get_root().get_nodes_in_group("water"):
            var reflect_camera = node.get_node("./reflect_vp/reflect_cam")
            mirror(p_camera, reflect_camera) 
        print("spatical action")
    
    func mirror(origin, target):
        target.transform = get_global_transform().affine_inverse()*origin.get_global_transform()
        target.transform.origin.y *= -1
        target.transform.basis.y.x *= -1
        target.transform.basis.x.y *= -1
        target.transform.basis.z.y *= -1
        target.transform.basis.y.z *= -1
    
    func _enter_tree():
        print("enter plugin tree")
        add_custom_type("water", "MeshInstance", preload("./script/water.gd"), preload("water.png"))
    
    func _exit_tree():
        remove_custom_type("water")
    
  • SIsilicon28SIsilicon28 Posts: 28Member

    @ywaby
    Yeah I was confused at first too. Then I did even further and found set_input_forwarding_always_enabled(true). You have to call this at least once to always get input. Every mouse click. Every mouse movement. Everything.

  • SIsilicon28SIsilicon28 Posts: 28Member
    edited June 6

    Also, I am considering to implement LOD.
    "I'm being so helpful. :)"

    Edit: Well actually I've pretty much completed wet dirt today. I'll add the ability to add ripples with it before I do another pull request.

  • ywabyywaby Posts: 10Member

    project develop roadmap discuss
    https://github.com/ywaby/godot-WaterPack/issues/2

  • aztecsenseiaztecsensei Posts: 19Member

    thank for sharing ywaby!
    can this use as toon/cel shaded water too? or its a diferent shader?

  • SIsilicon28SIsilicon28 Posts: 28Member

    @aztecsensei
    When you say toon/cell shared water, do you mean low poly water? If so, we got that done already. You can check it out in the repository.

  • MegalomaniakMegalomaniak Posts: 748Admin
    edited June 13

    No this is not a cel shader.

  • SIsilicon28SIsilicon28 Posts: 28Member

    @Megalomaniak
    I see.. We'll look into that.

  • ywabyywaby Posts: 10Member

    not, not yet. what toon water look like? any reference image?

  • SIsilicon28SIsilicon28 Posts: 28Member

    Have you seen Legend of Zelda wind waker? It's ocean is toon based.
    Although now that I mention it, there is actually quite a lot of styles too based water could have.

  • aztecsenseiaztecsensei Posts: 19Member

    thanks for answer.
    i mean something like " zelda wind waker".

  • MegalomaniakMegalomaniak Posts: 748Admin

    @SIsilicon28 said:
    Have you seen Legend of Zelda wind waker? It's ocean is toon based.

    It is not cel shaded however, simply shadeless(emission only). People using wrong technical terms only creates confusion. ;)

  • SIsilicon28SIsilicon28 Posts: 28Member

    @Megalomaniak said:
    It is not cel shaded however, simply shadeless(emission only). People using wrong technical terms only creates confusion. ;)

    Thank you for that. Guess I'm going to need to do more research on the subject matter before I attempt to implement it. :sweat_smile:

  • MegalomaniakMegalomaniak Posts: 748Admin

    All the 'effects' of the wind waker water are textures. :)

  • SIsilicon28SIsilicon28 Posts: 28Member
    edited June 14

    Yeah I noticed. Just need to figure out how to create those textures. :smile:

  • aztecsenseiaztecsensei Posts: 19Member

    @SIsilicon28 said:

    @Megalomaniak said:
    It is not cel shaded however, simply shadeless(emission only). People using wrong technical terms only creates confusion. ;)

    Thank you for that. Guess I'm going to need to do more research on the subject matter before I attempt to implement it. :sweat_smile:

    lol,yeah all this game dev terms still confuse me too! :s

Sign In or Register to comment.