karasusan / OpenVDBForUnity

Unity plugins for OpenVDB
MIT License
261 stars 41 forks source link

It works in 2020.1 #21

Open geslotencirkel opened 4 years ago

geslotencirkel commented 4 years ago

Had to do some VDB work and checked this out - after sometime and seeing the issues here I figured i'd share how you can get it to work:

follow instructions upto the "Packages->OpenVDB->Download Library" - this is the broken part potentially on everyones Windows installs.

When upgrading the project, clean it up, otherwise Unity doesn't correctly resolve the UnityEngine methods for EXR conversion - I had to nuke the Library and all of the other nonessential folders.

To get the latest available plugin, you will need to download and place it manually - depending on your OS, you will find the download URLs in LibraryDownloader.cs - for win64bit its here https://dl.bintray.com/kazuki/conan/kazuki/OpenVDBNativePlugin/0.0.1/stable/0/package/2c0ede688cb6609cf77dafa57a7200b861971804/0/conan_package.tgz

Open this with 7zip and get the openvdbi.dll and place it into Assets\OpenVDB\Scripts\Plugins and restart the project.

You should be able to reimport the .vdbs included with the project as stated in the instructions.

MattTree commented 4 years ago

Good tips. I'm stuck on:

Library\PackageCache\com.unity.render-pipelines.high-definition@8.2.0\Runtime\Utilities\HDTextureUtilities.cs(17,33): error CS1061: 'Texture2D' does not contain a definition for 'EncodeToEXR' and no accessible extension method 'EncodeToEXR' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?)

I tried deleting the file (my interpretation of your "nuke" term), but Unity rebuilt it.

I looked up the documentation to find a potentially missing 'using directive', but the documentation's code matches the code in this file.

I will add any other clues I find.

geslotencirkel commented 4 years ago

I'm not sure why that happens exactly but removing Library, ProjectSettings and UserSettings directories from the project folder before starting it up will make Unity regenerate the configs and fix issues like that. Sometimes you also have to remove and re-add the packages - i think for this Texture2D error you have to remove the HDRP package sometimes.

Healing downloaded projects is something you gotta do especially if you use diifferent versions of Unity than the one that the project was first created in.

MattTree commented 4 years ago

It worked. The key was deleting ProjectSettings and UserSettings to prevent the outdated Library folder from being generated.

This got me to a new but easy error which required me to install Unity's post processing package.

Side note / heads up: The VDB rendered objects in 2020.1 seem to clip / disappear early. In 2018.2 you can fly your camera all the way through the cloud without any clipping / disappearance.

2020.1 reference image: image

As you get closer in 2020.1 (disapparance): image

2018.2 reference image: image

As you get closer in 2018.2 (no disappearance): image

The same is true for other VDB objects.

MattTree commented 4 years ago

If I comment out ENABLE_TRACE_DISTANCE_LIMITED in VolumeStandard.shader, the cloud stops disappearing up close, but now the background turns black when you get close. Below is an animation of the camera flying straight through the cloud:

image image image image image

Another clue: If I turn the sun intensity up from 10 thousand to 10 million, the background shows (but now the sun is at 10 million).

image image

(Added a cube and another cloud)

Note that the brown ground has become gray due to the super bright sun.


Edit

The background turning black might be a 2020.1 HDRP thing in general. I found this effect with Visual Effect Graph particle systems, too:

Reference image: image

Background disappears (darkens): image

Background appears if I turn the sun up to 10 million: image

lizelive commented 4 years ago

@geslotencirkel could you make a pr?

lejeanf commented 3 years ago

Does anyone know how to use animated VDBs? I tried to make a C# script to activate/deactivate them in sequence but of course it is way too slow. Works well with 10 but over that it's not usable...

ohiro26 commented 3 years ago

Had to do some VDB work and checked this out - after sometime and seeing the issues here I figured i'd share how you can get it to work:

follow instructions upto the "Packages->OpenVDB->Download Library" - this is the broken part potentially on everyones Windows installs.

When upgrading the project, clean it up, otherwise Unity doesn't correctly resolve the UnityEngine methods for EXR conversion - I had to nuke the Library and all of the other nonessential folders.

To get the latest available plugin, you will need to download and place it manually - depending on your OS, you will find the download URLs in LibraryDownloader.cs - for win64bit its here https://dl.bintray.com/kazuki/conan/kazuki/OpenVDBNativePlugin/0.0.1/stable/0/package/2c0ede688cb6609cf77dafa57a7200b861971804/0/conan_package.tgz

Open this with 7zip and get the openvdbi.dll and place it into Assets\OpenVDB\Scripts\Plugins and restart the project.

You should be able to reimport the .vdbs included with the project as stated in the instructions.

Can somebody upload the dll again please? The link is broken. Thank you.

JacobVan3D commented 3 years ago

@MattTree @geslotencirkel @lizelive Would it be possible for one of you to upload the package again? Bintray seems to be down.

supuo commented 6 months ago

@MattTree

I found that the reason of it is Unity uses camera relative rendering in HDRP. The GetCameraPosition returns an absolute world space pos, but space transition matrices all use relative world space. So IsInnerCube will return a wrong value and the cloud disappears as you get closer to the cube.

So GetCamerPosition should be

inline float3 GetCameraPosition() {
  #if (SHADEROPTIONS_CAMERA_RELATIVE_RENDERING != 0)
  return 0;
  #else
  return _WorldSpaceCameraPos;
  #endif
}

Another thing is that the nearCameraPos should be float3 nearCameraPos = cameraPos + GetCameraNearClip() * cameraDir / dot(cameraDir, GetCameraForward()). Otherwise, you can't get a near clip plane but a near clip sphere.

My Unity version is 2022.3.