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

    Thanks again. Printing might be useful but for me it was more a matter of being able to trigger various thing depending on ToD. Like those birds circling from UE4Lanscape demo, best to have them gone at night and so on ... Now I can do that!

    Comment


      problems packaging the plugin

      First of all, thanks for the excellent work on this project. I LOVE it. It is perfect for my island map project.

      Ever since this was converted to a plugin, I am not able to get this to work after building my project.

      I am using the latest version of the plugin and UE 4.7.3

      Everything works great in the editor. I can package the project without an error but when I try and run the exe after packaging I get error that the plugin cannot be found.

      I have read all I can find on the forums about this. My plugin is in the plugins folder within my project folder. \Unreal Projects\IOTA\Plugins\OceanPlugin\OceanPlugin.uplugin

      I have tried suggestions (at least the ones I can understand). Some of the comments suggest rebuilding the plugin project (I think) but I don't understand how I can do that with this plugin as it does not seem to have all the files I would need to rebuild source in visual studio (or I just don't understand how to do it i.e. how do I get a .sln file for this?). FYI I have also tried rebuilding the UE4 engine via github etc.

      Also, I was able to build and use this shader just fine before it was converted to a plugin. It is quite likely that I am just missing some simple step. I have no experience with VS beyond just following the step by step instructions for rebuilding project via github.

      I am fairly new to game development and need simple/basic instructions on how to make this plugin work. Please forgive my inexperience with all this. Any help would be greatly appreciated.

      Thanks very much!

      Comment


        I don't know if the current code does this but the forces are applied with AddImpulse instead of AddForce to ignore the mass of the object.

        I just read the technique from the unity forum and it's dividing the volume up automatically and testing all those points along the volume, this is more accurate. Keep in mind that they are also doing buoyancy against the water level and thus a flat plane without wave calculations.

        My approach is to manually place the points along the volume to simply calculate Force/Torque vectors at those points. It's a big simplification that is meant to greatly reduce the amount of calculations per object. When I first implemented this I had no idea on performance. Center of mass is always assumed to be the objects center/pivot. As for specific gravity and buoyancy, I simply use the buoyancy factor to multiply the force at a point. Factor of 1 will apply the full force of the points volume (cubic, not spherical) upward and a factor of -1 sinks with the force of gravity as if there is no water. 0 is neutral and that point will not apply any force. Mass/density distribution is not implemented and is instead faked by these manual points.

        Because there are too few points it's possible that the objects are a bit unstable. Adding a bool to autogenerate the points/voxels might not be a bad idea for more complicated objects since it appears that the gerstner wave calculation is not too heavy on the CPU and testing 3x3x3 grid of point could be doable.

        And there is another optimization that should be brought to the buoyancy calculation, if the point is far enough away from the water surface (greater than max amplitude), then the wave calculation should be skipped. Only points near the surface need to care and only when the waves are significantly large.

        Anybody who knows a bit about physics and buoyancy that knows a better simulation approach please chime in.
        Last edited by Handkor; 03-25-2015, 03:28 PM.

        Comment


          Originally posted by Handkor View Post
          I don't know if the current code does this but the forces are applied with AddImpulse instead of AddForce to ignore the mass of the object.
          Thats interesting. So my 200,000kg object will sink with -1 on all the test points the same as if I override my mass to 300kg?

          I'd love to improve the buoyancy in anyway possible, I can code in C++, just slowly cause I'm not familiar with the Unreal API yet at all, any any testing I'm spending 11-15 hours a day working on submersibles and surface ships exclusively and extremely accuratly/realistically, nothing land based, plus my studios partner putting in probably about the same amount of hours.

          I have maybe a half dozen to a dozen different c# buoyancy scripts that I can pastebin just the parts that actually calculate where, why, how and when to apply force.

          Edit: I didn't realize all 3 of us are Canadian. Too bad you and dot arnt Edmontonians!
          Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

          Comment


            @Nsomnia, Handkor
            You guys should check out my branch of the plugin, I actually have added just yesterday a second buoyancy component that uses a more physically-based approach to buoyancy, it's what I use

            4.10 Update! -> [Community Project] WIP Weather & Ocean Water Shader
            WIP Interactive Water Shader, WIP 2D Water Sim
            WIP FFT Ocean w/ Foam, Quad-tree Infinite Ocean LOD

            Comment


              Originally posted by Handkor View Post
              I don't know if the current code does this but the forces are applied with AddImpulse instead of AddForce to ignore the mass of the object.

              I just read the technique from the unity forum and it's dividing the volume up automatically and testing all those points along the volume, this is more accurate. Keep in mind that they are also doing buoyancy against the water level and thus a flat plane without wave calculations.

              My approach is to manually place the points along the volume to simply calculate Force/Torque vectors at those points. It's a big simplification that is meant to greatly reduce the amount of calculations per object. When I first implemented this I had no idea on performance. Center of mass is always assumed to be the objects center/pivot. As for specific gravity and buoyancy, I simply use the buoyancy factor to multiply the force at a point. Factor of 1 will apply the full force of the points volume (cubic, not spherical) upward and a factor of -1 sinks with the force of gravity as if there is no water. 0 is neutral and that point will not apply any force. Mass/density distribution is not implemented and is instead faked by these manual points.

              Because there are too few points it's possible that the objects are a bit unstable. Adding a bool to autogenerate the points/voxels might not be a bad idea for more complicated objects since it appears that the gerstner wave calculation is not too heavy on the CPU and testing 3x3x3 grid of point could be doable.

              And there is another optimization that should be brought to the buoyancy calculation, if the point is far enough away from the water surface (greater than max amplitude), then the wave calculation should be skipped. Only points near the surface need to care and only when the waves are significantly large.

              Anybody who knows a bit about physics and buoyancy that knows a better simulation approach please chime in.
              The mass is being effected by your add impulse however. I believe it depends on the type of BP you are using and its physics type. See if you put it to kinematic then its completely ignores all of your test points and the mass of the object and sets a default test point to the center/pivot just like you are saying but you cant adjust any values for the test points they are completely ignored. We however wanted to influence the test points individually so we set the physics type to default. This of course acts with the mass of the object against your add impulse. Double check what type of BP object you our using, pawn, actor? Then try increasing the mass of the object and make sure your physics type is set to pawn or physics actor I believe. I also don't think you notice the effect of mass on your objects because your probably using objects that don't have much mass to begin with.

              Comment


                Originally posted by TK-Master View Post
                @Nsomnia, Handkor
                You guys should check out my branch of the plugin, I actually have added just yesterday a second buoyancy component that uses a more physically-based approach to buoyancy, it's what I use
                Interesting I would like to see that, I feel like it would help us out to examine another way for the physically-based approach.

                Comment


                  Has anyone noticed that increasing cloud opacity removes visibility of the ocean mesh from underneath? Happy to take a look at it if no one if working on that..

                  Comment


                    Originally posted by L0rdCha0s View Post
                    Has anyone noticed that increasing cloud opacity removes visibility of the ocean mesh from underneath? Happy to take a look at it if no one if working on that..
                    What commit are you using? I'll look into it.

                    Heres my tiny contribution I whipped up tonight in my spare time a simple bearing indicator that reads 360 aka 0 degrees for north (+Y) all the way around any pawns rotation. Just add to your content folder, built for a first person character template just switch your gamemode hud to 1PHUD (had to make a new one has my other hud had a ton of prototyping in it). Hope this helps people who get aggrivated trying to figure out why it switches from positive to negative values or from -90 to 180 or 270 etc. The get rotation node used here seems to be "missed" a lot.

                    Its really easy heres an example and the blueprint, create a horizontal box on your canvas then add 3 text boxes to it. The first one "Bearing: " the next one anything I use "000" and bind it to a function built as below and the last one the degree symbol. Then on your HUD class blueprint (like the 1PHUD.uasset blueprint from the .rar) add a "add widget" node with owning player set to get owning player controller node and choose compass class and then add to viewport and connect blue to blue and execute to execute. This can be used as a readout like it is or to make a simple compass. I'll show you how to use it to build a simple GUI compass with a rotating needle if there is interest; I'm just keeping the high-quality stuff to myself lol.

                    http://www.blendertek.com/Compass_Content.rar - download


                    Heres the blueprint, again if anyone really wants it I can, or anyone can convert it to C++ really easily. Tried to keep the width under 1000px if its too wide I'll link it.



                    Show off any simple stuff you guys feel comfortable sharing that has to do in anyway with the ocean/ships/exploration etc. were decimating Unity's approach to a community ocean plugin.

                    A fun thing to do is to do the same thing on enemy boats to make an easy way to calculate angle off bow (your bearing from the enemys ship that you enter into your torpedo firing computer) but, I dont think anyone else is developing a subsim. I saw one guy was, but he quit just like everyone else. Were the last indie subsimmers standing except WoTA on Unity and hes been going 4 years with only 1 trailer for mobile. Not a single tech demo or anything.
                    Last edited by Nsomnia; 03-26-2015, 02:53 AM.
                    Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

                    Comment


                      Originally posted by Nsomnia View Post
                      What commit are you using? I'll look into it.

                      .
                      Head of master branch - steps to reproduce:

                      1. Set cloud opacity up (e.g. 3), so you can see the clouds
                      2. Go under the water mesh
                      3. Look up

                      Comment


                        Originally posted by L0rdCha0s View Post
                        Head of master branch - steps to reproduce:

                        1. Set cloud opacity up (e.g. 3), so you can see the clouds
                        2. Go under the water mesh
                        3. Look up
                        Will attempt to reproduce now. So people know

                        Tk's branch with his alternate buoyancy system... buoyancycomponent now takes into effect density of object, density of water, and radius of test point. Now you can say make it the density of steel, or wood to get different effects. The density is measured in grams per cubic centimeter (g/cm3) and the forumla to calculate force (since for handkors, its a little more complicated)

                        Code:
                        Edit: I noticed in TK's dev branch that the sun sets in +Y which makes north +X (which it should be) so my bearing indicator/compass preview above is off by 90 degrees if you use it. If anyone doesnt know how to change that I'll post the new one, its very simple. Now we have proper light that rises in the east and sets in the west. That should be in the master branch if it isnt already (maybe I accidently rotated my entire skybox in my projects? lol)
                        
                        			/**
                        			* --------
                        			* Buoyancy force formula: (Volume(Mass / Density) * Fluid Density * -Gravity) / Total Points * Depth Multiplier
                        			* --------
                        			*/
                        Here is the foruma for depth multiplier

                        Code:
                        			float DepthMultiplier = (waveHeight - (worldTestPoint.Z + _SignedRadius)) / (TestPointRadius * 2);
                        			DepthMultiplier = FMath::Clamp(DepthMultiplier, 0.f, 1.f);
                        _Signed radius goes as follows [ _SignedRadius = FMath::Sign(GetGravityZ()) * TestPointRadius; ]

                        It also apparently can draw debug spheres as yellow above water blue below.
                        Code:
                        			FColor DebugColor = FLinearColor(0.8, 0.7, 0.2, 0.8).ToRGBE();
                        			if (isUnderwater) { DebugColor = FLinearColor(0, 0.2, 0.7, 0.8).ToRGBE(); } //Blue color underwater, yellow out of watter
                        			DrawDebugSphere(GetWorld(), worldTestPoint, TestPointRadius, 8, DebugColor);
                        sic [water] TK

                        TK was nice enough to comment his work extremely well, he must be like me, has more lines of comments than code. Heres most of the header file with comments incase people want to know more, if you dont want your public source shown TK just let me know.
                        Code:
                        	/* Density of fluid */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float MeshDensity;
                        
                        	/* Density of water */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float FluidDensity;
                        
                        	/* Linear damping when object is in fluid */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float FluidLinearDamping;
                        
                        	/* Angular damping when object is in fluid */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float FluidAngularDamping;
                        
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	FVector VelocityDamper;
                        
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	bool ClampMaxVelocity;
                        
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float MaxUnderwaterVelocity;
                        
                        	/* Radius of the points */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	float TestPointRadius;
                        
                        	/* Test point array. At least one point is required for buoyancy */
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	TArray<FVector> TestPoints;
                        
                        	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buoyancy Settings")
                        	bool DrawDebugPoints;
                        BuoyancyMovmentComponent is stil the same as Handkors latest version as of writing and destructable buoyancy uses Handkors technique as well It looked like.

                        If anything is wrong TK let me know, just very few people actually look at the code to see how it works.


                        Heres an idea (which I'll be incorporating into my game for both density and for sonar (sound travels faster the colder it gets cause its more dense) anways, the density of fluid at temperature would make it that 0.01% more accurate

                        Anyways, wood you would find on an old wooden ship was arround 6.75-7.20 g/cm3 in desnity. Water is 1 salt water is 1.03g·cm3 (due to different heavy water isotopes not found in fresh water) plastics are generally around 1.1-1.12g·cm3 cast iron is generally around 77.5g·cm3 and steel is about 78.0g·cm3 sometimes as high as 80.5g·cm3 if its a high quality steel with different alloys and depending on its carbon content I believe I was taught standard mild steel is said to be 7.88g·cm3. Titanium, which Russians used to build a submarine hull once weighs 4.506 g·cm3. Ps you can also write these values out at g/cc (cubic centimeter). Air, if you need to simulate that, varies a ton depending on water content, co2/nitrogen/o2 content etc. altitude and temperature. Its average value is 0.001225 g·cm3.

                        Edit: In TK's dev the sun now sets in the west and rises in the east just like in real life. If this isnt in the master branch I would add it (maybe I rotated my skybox by accident in all my projects? lol) anyways, that throws my little compass/bearing indicator off because I was using +Y was north and +y is now west. +X is the new North, just like it would be. If you cant figure out how to fix that, let me know I'll post how to fix the bearing indicator or include it when I show how to make a basic needle compass.

                        Edit2: I didnt realize there was a "sun axis offset" variable. set to -90 to make it rise in the east and set in the west aka proper north in the +X. Then get rid of -90 in my BP script (I think, I cant visualize code from blueprints, I'd have to try it. You want to face straight +x and get 0 aka 360 bearing though.

                        Originally posted by L0rdCha0s View Post
                        Head of master branch - steps to reproduce:

                        1. Set cloud opacity up (e.g. 3), so you can see the clouds
                        2. Go under the water mesh
                        3. Look up


                        In regardings to the cloud opacity I see what your talking about. Remember this is all very alpha/pre-alpha. The only work around I can think of is a value of 0.99 or so but the clouds still dont get less opaque with depth. I can easily show you how to do that in BP if you dont know how to do it yourself? That way you can make it so say 10m underwater they are gone, and above that they get more and more opaquie all the way to the stock 2.12 value. They sky actually seems to be getting lighter the lower you go, that seems backwards, but I'm using TK's branch to reproduce this not the master.
                        I dont know if I should be saying this (if not, let me know but weather/atmosphere update is supposed to be coming this weekish.
                        Last edited by Nsomnia; 03-26-2015, 12:33 PM. Reason: Sun doesnt set in the south LMAO
                        Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

                        Comment


                          Originally posted by Nsomnia View Post
                          Heres the blueprint, again if anyone really wants it I can, or anyone can convert it to C++ really easily. Tried to keep the width under 1000px if its too wide I'll link it.
                          A very cool idea thank you!

                          Comment


                            Originally posted by CraigColby View Post
                            First of all, thanks for the excellent work on this project. I LOVE it. It is perfect for my island map project.

                            Ever since this was converted to a plugin, I am not able to get this to work after building my project.

                            I am using the latest version of the plugin and UE 4.7.3

                            Everything works great in the editor. I can package the project without an error but when I try and run the exe after packaging I get error that the plugin cannot be found.

                            I have read all I can find on the forums about this. My plugin is in the plugins folder within my project folder. \Unreal Projects\IOTA\Plugins\OceanPlugin\OceanPlugin.uplugin

                            I have tried suggestions (at least the ones I can understand). Some of the comments suggest rebuilding the plugin project (I think) but I don't understand how I can do that with this plugin as it does not seem to have all the files I would need to rebuild source in visual studio (or I just don't understand how to do it i.e. how do I get a .sln file for this?). FYI I have also tried rebuilding the UE4 engine via github etc.

                            Also, I was able to build and use this shader just fine before it was converted to a plugin. It is quite likely that I am just missing some simple step. I have no experience with VS beyond just following the step by step instructions for rebuilding project via github.

                            I am fairly new to game development and need simple/basic instructions on how to make this plugin work. Please forgive my inexperience with all this. Any help would be greatly appreciated.

                            Thanks very much!
                            To package a game with the plugin you need to add a code file to your project, even if it is totally empty (sounds silly I know, hopefully this will not be necessary in 4.8). To do so click on File -> Add Code to Project and choose either Actor or Blank, and give it a name that is not in use (you can't use your projects name for example). This will create the source files along with a *.sln file that you can use to view everything in VS if you'd like, but that's not required.

                            Once you have added your new code you should now be able to package the project without any issues. Let me know if you run into any problems though!

                            Originally posted by L0rdCha0s View Post
                            Has anyone noticed that increasing cloud opacity removes visibility of the ocean mesh from underneath? Happy to take a look at it if no one if working on that..
                            I have noticed this as well. It shouldn't be happening since the Translucency Sort Priority for each mesh has been set properly (unless something went wrong when I migrated the skydome from another project), I will have a look at it again this morning before updating the master branch. The clouds as they are now will be much different once Skydome overhaul has been completed, I'm currently testing out a couple new ideas and may end up removing the current cloud-dome mesh in favor of a new one. More on that soon, still testing.

                            Originally posted by Nsomnia View Post
                            I didn't realize all 3 of us are Canadian. Too bad you and dot arnt Edmontonians!
                            Oh there's more! At last count there were 9 of us either working on or with the project (probably a lot more than that, that's just the ones who have mentioned it so far).

                            And thanks Nsomnia for the Compass! I'll add it in this morning

                            -----------------
                            One last note:

                            Also just wanted to say that I will be merging in TK's (awesome) new additions into Master today, along with a few other small fixes. Will let you guys know when it's up, I may even create a 1.1 branch since there are so many new features. Should be up soon
                            Free Community Ocean & Sky Project || Join us on Discord! || Trello Roadmap

                            Comment


                              Well. The whole copy and paste didnt work. I'm not gonna dive too hard into this yet. Handkors solutions is working for us. Just TK's is much more realistic. I get this error, no code errrors just a runtime error? I've never coded without debugging and outside the standard libraries before. For anyone whos wondering, I'm trying to take TK's buoyancy system and have it work like handkors where the location, radius, and buoyancy (which will just be the meshDensity.... fluidDensity will be a global variable) can be set on a testpoint-by-testpoint basis so that you can "flood" parts of damaged ships or build submarines like we are.

                              Code:
                              1>------ Build started: Project: OceanDemo, Configuration: Development_Game x64 ------
                              1>  Parsing headers for OceanDemo
                              1>  Reflection code generated for OceanDemo
                              1>  Performing 17 actions (3 in parallel)
                              1>  PCH.UELinkerFixups.UELinkerFixupsName.h.cpp
                              1>  PCH.OceanPlugin.OceanPluginPrivatePCH.h.cpp
                              1>  PCH.OceanDemo.OceanDemo.h.cpp
                              1>  UELinkerFixups.cpp
                              1>  [5/17] Resource OceanDemo.rc
                              1>  BuoyantDestructible.cpp
                              1>  OceanPlugin.cpp
                              1>  OceanPlugin.generated.cpp
                              1>  OceanManager.cpp
                              1>  FishState.cpp
                              1>  FlockFish.cpp
                              1>  FishManager.cpp
                              1>  BuoyancyComponent.cpp
                              1>  BuoyancyMovementComponent.cpp
                              1>  [16/17] Link OceanPlugin-Static.lib
                              1>  OceanDemo.cpp
                              1>  [17/17] Link OceanDemo.exe
                              1>     Creating library D:\#UnrealEngine 4\Plugins\OceanProject-TK-s-Dev\Binaries\Win64\OceanDemo.lib and object D:\#UnrealEngine 4\Plugins\OceanProject-TK-s-Dev\Binaries\Win64\OceanDemo.exp
                              1>UELinkerFixups.cpp.obj : error LNK2019: unresolved external symbol "void __cdecl EmptyLinkFunctionForStaticInitializationOceanPlugin(void)" (?EmptyLinkFunctionForStaticInitializationOceanPlugin@@YAXXZ) referenced in function "void __cdecl UELinkerFixups(void)" (?UELinkerFixups@@YAXXZ)
                              1>D:\#UnrealEngine 4\Plugins\OceanProject-TK-s-Dev\Binaries\Win64\OceanDemo.exe : fatal error LNK1120: 1 unresolved externals
                              1>  -------- End Detailed Actions Stats -----------------------------------------------------------
                              1>ERROR : UBT error : Failed to produce item: D:\#UnrealEngine 4\Plugins\OceanProject-TK-s-Dev\Binaries\Win64\OceanDemo.exe
                              1>  Cumulative action seconds (6 processors): 0.00 building projects, 205.46 compiling, 0.00 creating app bundles, 0.00 generating debug info, 9.33 linking, 0.00 other
                              1>  UBT execution time: 100.95 seconds
                              1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat" OceanDemo Win64 Development "D:\#UnrealEngine 4\Plugins\OceanProject-TK-s-Dev\OceanDemo.uproject" -rocket" exited with code -1.
                              ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
                              Heres the .H http://pastebin.com/EDfHkzmt and the .CPP http://pastebin.com/UiPvgpvj


                              I wouldnt call that a compass, its just a bearing indicator and only works with a possessed pawn. When I actually make a graphic compass that points to north (now that I figured out where north actually should be ingame) it would be worth including maybe. Anyone can build that blueprint in 5 minutes. I'll share some of the C++ I outsource to a freelancer for our game like parts of a world map and streaming/infinite ocean/etc as my contribution
                              Last edited by Nsomnia; 03-26-2015, 07:51 PM.
                              Tek LLC a personal Candaian Company running BlenderTek & UnrealTek is currently looking for help to bring back submarine simulator gaming with a new genre of sub sims: Cold War! (1945-1991) Operation: Trident SubSim Dev Diary Thread - Donations

                              Comment


                                Originally posted by L0rdCha0s View Post
                                Has anyone noticed that increasing cloud opacity removes visibility of the ocean mesh from underneath? Happy to take a look at it if no one if working on that..
                                You can fix by unchecking "use translucency vertex" in M_clouds MAT - At least it corrected my problem of clouds visible through water
                                Last edited by Zeroy; 03-26-2015, 08:54 PM.

                                Comment

                                Working...
                                X