Announcement

Collapse
No announcement yet.

[Community Project] WIP Weather & Ocean Water Shader

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Originally posted by MagicBlueFrog View Post

    Yes, you are right! Thanks! It partially works now. If I set the sunlight to stationary instead of moveable then it gets rid of the strange shading/lighting I was seeing. I still cannot use the "Ultra" ocean shader or any of them that use SSR without getting strange effects in split screen, so now I use the one with Gerstner waves, Foam and Cubemap and it looks pretty good. Not as good as Ultra, but definitely better than the ocean I had before. And I guess I will have a hard time including any of the weather or time of day effects if I want to later, but for now it is a big improvement already.

    Cheers!
    The Sun is a DirectionalLight component, your main direct light, which to simulate a time pass would need to be Moveable. The indirect light is provided by another component called SkyLight, which usually will be set the same and your Sun (if Moveable, then SkyLight is also Moveable, and so on). You could have the SkyLight set as Stationaty while the Sun is Moveable but it might not work OK in night time, since the SkyLight will inject too many light into the scene, unless this is desirable.

    I will see if I can check the issue with the reflections today with split screen and get back to you.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post
    The shading and color might be caused by SkyLight placed in the scene. In order for you to test if it is the root cause, you just disable it in the level and play again.
    Yes, you are right! Thanks! It partially works now. If I set the sunlight to stationary instead of moveable then it gets rid of the strange shading/lighting I was seeing. I still cannot use the "Ultra" ocean shader or any of them that use SSR without getting strange effects in split screen, so now I use the one with Gerstner waves, Foam and Cubemap and it looks pretty good. Not as good as Ultra, but definitely better than the ocean I had before. And I guess I will have a hard time including any of the weather or time of day effects if I want to later, but for now it is a big improvement already.

    Cheers!

    Leave a comment:


  • replied
    Originally posted by MagicBlueFrog View Post

    No, other things get messed up for the second player too, like the shading and color, especially if the first player looks up at the sky. I will keep playing with it and see if I can get something to work and will let you know if I have any success. It will be difficult though, since I only understand about 30% of what's happening in the materials and roughly 0% (give or take) of why it's done that way.
    The shading and color might be caused by SkyLight placed in the scene. In order for you to test if it is the root cause, you just disable it in the level and play again. In multiplayer (the built-in one like in the video) we just call the recapture method, so both server and client are updated same way, this is important, because the SkyLight is the indirect light in the scene and if you have the main directional light moving the indirect light must update accordingly.

    I never used the split screen feature, so I will really need some time to look and understand whats going on. If it uses the built-in multiplayer in a special way, then there must be a way to fix everything. Actually it is hard to find someone with a good idea for split screen usage, so many assets probably are not made with that usage in mind Im afraid.

    Anyway all is part of the learning process, but in my opinion you are going to stuff a bit complex right now... it is really important to understand how materials works in the engine, since it is the base for everything else.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post
    Your issue on having the solution running on single process with a split screen will require a deep analysis. Is it the only thing messed up the reflections?
    The infinite Ocean to work really need a single camera reference, because the Infinite Ocean is an ilusion. It is just a plane very large which is moved with the camera giving a fake infinite ocean feeling.
    No, other things get messed up for the second player too, like the shading and color, especially if the first player looks up at the sky. I will keep playing with it and see if I can get something to work and will let you know if I have any success. It will be difficult though, since I only understand about 30% of what's happening in the materials and roughly 0% (give or take) of why it's done that way.

    Leave a comment:


  • replied
    Originally posted by MagicBlueFrog View Post

    Thanks for the video. It is a little hard to hear, especially when the waves come in (but I could mostly follow).

    But it is not really what I want. I really want a single process for a local split screen (not cool anymore?). I checked all the relevant Blueprints and the only one that had replication set was the skydome. Unsetting replication for that didn't help. I also checked all the C++ and none of them had replication explicitly (though the engine probably takes care of that in the background). I think the main issue is in the materials for the ocean shader since they all have references to camera position and direction, so assuming only one camera. There is also the InfiniteSystemComponent which follows Player 0, but setting follow mode to "stationary" just makes the waves very small and doesn't fix my split screen problem. I think in order to make it split screen compatible I need to edit the materials and make them not depend on the camera position, but I am not very familiar with materials and their functions, so the more I try to hack it the worse it looks and doesn't seem to get rid of the camera dependence. I wonder if I could create two materials and make one invisible to the other player or something like that... but I don't know how to make that work.
    Replication is only related to different processes, it won't work for a singtle process, so no change regarding that will make that work. Your issue on having the solution running on single process with a split screen will require a deep analysis. Is it the only thing messed up the reflections?

    The infinite Ocean to work really need a single camera reference, because the Infinite Ocean is an ilusion. It is just a plane very large which is moved with the camera giving a fake infinite ocean feeling.
    Last edited by NilsonLima; 05-04-2018, 02:02 PM.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post
    The only changes we do with blueprints is to set if they are replicated through network or not, and if so which variables should be replicated. The variables could be anything inside. The issue you are experiencing is really because the split screen is not a feature which allows the built-in multiplayer to work, since for it to work you need to network distinct process running in order to have an exchange of replicated values. So one single process can't handle multiplayer from the core, but as two process which matches the real situation in real world it works perfectly!
    Thanks for the video. It is a little hard to hear, especially when the waves come in (but I could mostly follow).

    But it is not really what I want. I really want a single process for a local split screen (not cool anymore?). I checked all the relevant Blueprints and the only one that had replication set was the skydome. Unsetting replication for that didn't help. I also checked all the C++ and none of them had replication explicitly (though the engine probably takes care of that in the background). I think the main issue is in the materials for the ocean shader since they all have references to camera position and direction, so assuming only one camera. There is also the InfiniteSystemComponent which follows Player 0, but setting follow mode to "stationary" just makes the waves very small and doesn't fix my split screen problem. I think in order to make it split screen compatible I need to edit the materials and make them not depend on the camera position, but I am not very familiar with materials and their functions, so the more I try to hack it the worse it looks and doesn't seem to get rid of the camera dependence. I wonder if I could create two materials and make one invisible to the other player or something like that... but I don't know how to make that work.

    Leave a comment:


  • replied
    Originally posted by MagicBlueFrog View Post

    I strongly suspect it is not a problem with the normal multiplayer but the fact that I am trying to use a network game as a local split screen game. Do you think it would be difficult for me to repurpose the project into a local multiplayer (I'm assuming this would fix the reflection problem) and do you have a pointer for where to start with that? Can I just delete all the network references?
    The steps I provided above are common to any project since the multiplayer is a built-in feature inside the Engine. The only changes we do with blueprints is to set if they are replicated through network or not, and if so which variables should be replicated. The variables could be anything inside.

    I have followed the steps above and the replication is fine for the waves and the reflections are ok too. The issue you are experiencing is really because the split screen is not a feature which allows the built-in multiplayer to work, since for it to work you need to network distinct process running in order to have an exchange of replicated values. So one single process can't handle multiplayer from the core, but as two process which matches the real situation in real world it works perfectly!

    Later I will post a small video showing the steps above in action, get back in 1 hour that the video should be up!

    The link is bellow:




    Last edited by NilsonLima; 05-03-2018, 09:22 AM.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post
    I will proceed the testings here to see if that issue with planar reflection is a wrong setup on the multiplayer part or something really caused by the split screen.
    I strongly suspect it is not a problem with the normal multiplayer but the fact that I am trying to use a network game as a local split screen game. Do you think it would be difficult for me to repurpose the project into a local multiplayer (I'm assuming this would fix the reflection problem) and do you have a pointer for where to start with that? Can I just delete all the network references?

    Leave a comment:


  • replied
    Originally posted by MagicBlueFrog View Post

    Yeah, it is a local multiplayer project. I am actually a physicist, so I'm not new to programming but I am a bit new to game dev and Unreal. I searched around and I cannot find any discussion of reflections in split screen mode or for multiplayer, so I am surprised this is an issue for me here... Thanks for looking into it.
    Technically, multiplayer uses what we call network replication, and the part which touches the point is the word "network" because to allow replication of a status for a material in multiplayer you relly on different processes to have the executable perform differently: one is the server part and the other is the client part, or in case of session hosting for cooperative mode, one is set as the hosting session while others join this one sharing the same map/environment etc.

    What looks here is that split screen are using the same set of data, so besides having different cameras per display tile, they are using the exactly same data, therefore obtaining the wrong perspective for the reflection (that part is the planar reflections, which is a separate component built-in Unreal Engine).

    You can start a coop mode the following way:

    - check your console key inside your project: Menu Edit -> Project Settings -> Engine: Input -> Console Keys ( I usually use the "[" key since it works best for my international keyboard)
    - you need to package your project for Windows (or Mac if you use it) with shortcut: Menu File -> Package Project -> Windows -> Windows 64bit
    - run the executable file generated as : your_project_name.exe or OceanProject.exe
    - you need to remember the name for your Map where you created your level or if using the Ocean project the one described bring up the console and type: open IslandMap?listen
    - run another executable in the same machine or in another machine
    - if you run in another machine, you need to know the IP address for the 1st one, here Im showing if you do in the same machine once the executable is loaded, bring the console and type: open 127.0.0.1

    The way I described above you will have a correct way for testing multiplayer.

    I will proceed the testings here to see if that issue with planar reflection is a wrong setup on the multiplayer part or something really caused by the split screen.

    Leave a comment:


  • replied
    Originally posted by NilsonLima View Post
    Is that part of your gameplay or is it a way to realize if the multiplayer part is ok?
    Yeah, it is a local multiplayer project. I am actually a physicist, so I'm not new to programming but I am a bit new to game dev and Unreal. I searched around and I cannot find any discussion of reflections in split screen mode or for multiplayer, so I am surprised this is an issue for me here... Thanks for looking into it.

    Leave a comment:


  • replied
    Originally posted by MagicBlueFrog View Post
    Here is an illustration of the problem in the island map. When I add a second local player in split screen the second player uses the reflections calculated by the first player's camera transform...
    I will check this for you, but as far as I remember the Ocean was not finalized in the multiplayer portion, but I might be wrong... lets hope it is just something missing somewhere. A question tho, why are you using split screen? Is that part of your gameplay or is it a way to realize if the multiplayer part is ok?

    Leave a comment:


  • replied
    Originally posted by Sir_Manfred View Post

    Thanks, I think I got it to work. It seems that sometimes it doesn't update but that might be a memory issue on my side. Not sure yet.

    As for memory, when you insert the heightmap into the modulation, that'll eat a lot of memory I imagine. Especially if you have a 16 bit heightmap @ 8k resolution. (Like I do).
    Would it be possible to modify the Ocean blueprints and shader to allow for a smaller sized 8-bit heightmap?
    Alternatively, do you think it would be possible to do modulation based on Distancefields instead? Like using distance to nearest surface, for example. Though I guess there would be interference from other objects with distance fields...

    Another thing I've been thinking about doing is to use a flowmap for wave direction. Mainly so that the waves travel towards the island and not necessarily away from it. I think perhaps a couple of gerstners could go the other way to fake some sorts of wave-bounce-thingy. Has this been tried before?
    Very interesting I like the idea of a flow map. but I think you would have it is the same "size and resolution" as the heightmap and use the same placement mechanism. But that doesnt sound like a problem. I'm very curious about this.

    Leave a comment:


  • replied
    Here is an illustration of the problem in the island map. When I add a second local player in split screen the second player uses the reflections calculated by the first player's camera transform...
    Attached Files

    Leave a comment:


  • replied
    Hi everyone,

    thanks for the beautiful ocean!
    But it seems to have problems in local multiplayer with split screen. When player 1 moves or rotates his camera it changes the reflections and shading for player 2 (although, not the other way around). Does someone know a way I can fix that or get around it?
    Last edited by SchattenJäger42; 05-02-2018, 02:47 AM.

    Leave a comment:


  • replied
    Originally posted by Sir_Manfred View Post

    Thanks, I think I got it to work. It seems that sometimes it doesn't update but that might be a memory issue on my side. Not sure yet.

    As for memory, when you insert the heightmap into the modulation, that'll eat a lot of memory I imagine. Especially if you have a 16 bit heightmap @ 8k resolution. (Like I do).
    Would it be possible to modify the Ocean blueprints and shader to allow for a smaller sized 8-bit heightmap?
    Alternatively, do you think it would be possible to do modulation based on Distancefields instead? Like using distance to nearest surface, for example. Though I guess there would be interference from other objects with distance fields...

    Another thing I've been thinking about doing is to use a flowmap for wave direction. Mainly so that the waves travel towards the island and not necessarily away from it. I think perhaps a couple of gerstners could go the other way to fake some sorts of wave-bounce-thingy. Has this been tried before?
    You can feed 8-bit, since it uses a Texture2D class inside the code and do:

    Tex2D->SRGB = true;
    Tex2D->CompressionSettings = TC_VectorDisplacementmap;
    Tex2D->UpdateResource();

    meaning that even if you feed 16bit it will become 8bit which is the VectorDisplacement format.

    Using Distance Fields will get interference from other objects, so it is required to mask out anything else which is not a Landscape, I am not sure yet how to accomplish it. Other objects you can use a SphereMask or BoxMask inverted and multiplied by the GetDistanceToNearestSurface node, but it wont work since there might be other objects in physical contact with the Landscape while inside the water mass, which in the end will make the modulation weird.

    For the wave direction thing thou, there might be other ways to make it work. If you are not with the camera above (flying in the sky) and following the cost, you can change the Wave Direction vector to face the camera, but to be a good effect, it must be really smoothed out to not get pops coming from the sudden change in direction. This way suppose you walk arond the entire island, it would appear the waves are always crashing to the shore. Its easier said then done, think in a situation you just give your back to the ocean, where the direction should point to? Now think you are now with the Ocean at your left or your right side, where the direction should point? With this in mind, you need to smooth the change into the direction as much as you can, meaning the more you are facing the ocean (90 degrees) the wave direction would be 100% facing the camera and a scalar to smooth the lerping to a different angle when moving to face the opposite direction. The nodes will get tricky, because you can walk into a hill and see both sides of the Island and when you rotate the camera, funny pops might appear.

    I know you will need to read the text above more than twice to picture the scene described, Im sorry but speaking my mind in another language to describe my thoughts can result in long and not well ponctuated sentences.

    Leave a comment:

Working...
X