OpenVDBForUnity icon indicating copy to clipboard operation
OpenVDBForUnity copied to clipboard

It works in 2020.1

Open geslotencirkel opened this issue 5 years ago • 9 comments

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.

geslotencirkel avatar May 05 '20 20:05 geslotencirkel

Good tips. I'm stuck on:

Library\PackageCache\[email protected]\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.

MattTree avatar Aug 24 '20 15:08 MattTree

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.

geslotencirkel avatar Aug 25 '20 07:08 geslotencirkel

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 avatar Aug 25 '20 11:08 MattTree

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

MattTree avatar Aug 25 '20 11:08 MattTree

@geslotencirkel could you make a pr?

lizelive avatar Aug 30 '20 05:08 lizelive

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...

lejeanf avatar Nov 27 '20 21:11 lejeanf

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.

ohiro26 avatar Jun 02 '21 19:06 ohiro26

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

JacobVan3D avatar Aug 16 '21 20:08 JacobVan3D

@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.

supuo avatar Apr 08 '24 12:04 supuo