0
Under review

square shadows

Triadne 5 years ago updated 5 years ago 63

I have a couple of issues. first is that my shadows are square. it has the detail shadows, but it has square shadows as well. looks like it's casting both billboard and detail shadow at the same time. 

second issue is that it seems to have done something to my original trees. I can't use my original trees on my terrain now at all. it worries me. also, you have divide by zero errors when i run the tree conversion scene, and it won't stop running and i had to force quit unity.

Last thing, my unity trees had the ambient occlusion effect enabled. these new LOD trees do not seem to be showing it.

I've never used breakpoints before, I usually use debug log, so I'll just need to do some reading and I'll get back to you later once I've managed it.

Oh... ack... you might not even be using Visual Studio to debug. Are you using a windows computer? If you are using windows, you can get it for free from https://visualstudio.microsoft.com/vs/community/

You'll need to install it, and make sure it installs C# for you. Once that install is done, you'll need to restart unity probably, and then in the unity editor, go to Edit->Preferences->External Tools-> and set the external script editor to Visual Studio. Once that's done, you simply double click a script in your project window, and it should open it in visual studio for you. Then you can go to line 777 or whatever, click the line, and press F9 to set a break point. Then.. uh... click the green arrow at the top to "attach to Unity", which hopefully it attaches with no errors. Once it says it is ready, then run the scene like normal and it should stop it when it hits that line, and you can then hover your mouse over each variable to see what their exact values are. And then you can tell it to continue one line at a time (there's a button along the top to tell it to go forward one line at a time), so you can see where it goes next and what it's doing.

But if you are using an Apple Mac computer then you might be out of luck.

Oh I forgot to say, during the install process for visual studio, you probably will see an option to install "tools for Unity", you might need to make sure it installs that also, in case that's important, probably is.

I don't like visual studio, I'm used to mono. but it appears to have a breakpoint function, so I'm just trying to locate the variables bit while running through it.

Oh, okay that might work. I was worried you might have been using notepad or something.

okay, here is what I've ascertained. 
screenshotpic_nobark.getpixels yields an array full of valid colours. 
when it comes to the foreach loop at 2199 though, the array it is drawing from is full of empty colours.
This can only mean that for some reason, line 2195 is not resulting  in an array of the necessary colours. I can't say for sure because I can't check every value of the array, but totalpixelcount is definitely zero and that is causing the divide by zero error.

maybe I'm missing something but line 1971 in shadowtextureloop seems to be telling the script to delete the pixels if they are different from the background pixels...

You say screenshotpic_nobark is full of valid colors... but are they all the same color..? the background color? or is it full of different colors, such as the colors of a tree? I'm guessing it's an arroy full of nothing but the background color. And if so, then the problem must be back on line 777 to 822, where it takes the screenshot of specific parts of the tree, I think it's turning the entire tree transparent and taking a screenshot of nothing but background pixels. If you can step through the lines at 777 through 822 you can find out if it is successfully turning "on" the leaves, or if it's failing to find any leaves and simply turning the entire tree transparent.

nope, when i said valid colours I meant many different colours as would  be expected of a leaf texture.

background colour is 0,0,0,0.68, the array contains all sorts of different values. it is taking a valid screenshot.  but as i said, the line 1971 appears to be asking for
!(col.r == background.r && col.g == background.g && col.b == background.b)

and then replacing with an empty pixel if true. so it's changing any colour that is different from the background colour into a transparent black pixel. I don't know the entirety of the script so this may be intentional but it seems to me that this line is effectively deleting all my leaf pixels. 

I would test removing the ! but it looks like this is intentional. It doesn't make sense to me so I won't try changing any code until you tell me to.

Good catch on noticing that exclamation point. Yes, it does appear to be intentional, because I see the same exclamation point in the 2018.1 version which I definitely know was working correctly. You are correct though, and it's making my head hurt just looking at it. The comments seem to suggest it's skipping background pixels, but the code looks like it is skipping everything BUT background pixels. It could very well be that my comments were from a really old version and I never changed the comments... so the comment could be misleading possibly. But the exclamation point is in every version, so it's definitely intentional.

I see that it calls the ShadowTextureLoop() twice, and the second time, it passes the colors of the tree again, so it's not "deleting pixels".. it calls the function again and passes the colors of the tree a second time. So it's doing it in two passes. Anyway, so perhaps the opposite was true, and there are actually NO background pixels in your screenshot? So maybe your tree is somehow filling every single pixel in the screenshot so that it can't find any background pixels? 


When it's actually taking the screenshots, you should be able to very briefly see the tree, and it'll turn the tree to several different angles, as it is taking the screenshots. The tree should basically fit the view perfectly. it resizes the tree (or the camera, I can't remember) so that it fits... I think I see that resizing code on line 713. So the tree should fit the view perfectly. So it's unusual if it can't find even a single background pixel. The tree would have to be perfectly square or something. When you click the Play button to start the screenshotting, do you see like a huge tree that fills the whole view? Or is it somehow possible that you are running some kind of full screen effect that is altering the color of your camera's background, so that the background behind the tree's isn't completely black? Also... make sure that the tree doesn't somehow have a billboard attached to it... as that billboard could actually BE square, and could potentially fill the whole view, which might explain if it can't see the background in the back at all.

Actually yes that is what happens, like I said earlier, the billboard tree just appears as a close up of the leaves in a crisscross pattern. Like three big rectangles of leaves stuck together. So it seems like that must be what happened, its taking the screenshot really close, or the tree is too large for it. I don't know what to do about that. I don't think my trees are abnormal sizes.

It duplicates the tree at line 684, and puts it into the lod0 variable.

Then it makes lod0 to be the child of a game object named renderParent... that happens on line 693.

Then it gets the bounds of the parent, which basically will be the size of a box around the tree, which happens on line 710.

Then it shinks the tree down to basically a scale of 1,1,1... so the tree is very tiny... which happens on line 713.

The GetBounds() function's source code is there, in case you want to step through it to see if it looks like it is correctly adding up all the boundaries of the tree. The goal of the function is to find out exactly how big the tree is, like what is the smallest box that the tree would perfectly fit into.

Obviously the function is returning a bounds size that is too smal and the tree is much bigger. Only thing I can think of that would cause that is if there is something weird about your tree... i mean... the bounds function is a built-in unity function so it's not supposed to fail to get a perfect bounds... but looking at the source for GetBounds I see that it has to loop through each part of the tree and add together all the bounds, so maybe your tree somehow is different than what it is expecting, so it isn't adding together everything and some parts of your tree aren't be included in the bounds it is adding up?

The reason it creates a bounding box for the tree is so that it can shrink the tree down to a size of 1,1,1.. so that it'll perfectly fit into the camera, since the camera is set to screenshot at a size of 1,1,1... which has no benefits... I mean I could have simply increased the size of the camera instead, but that would have failed just the same if it isn't correctly getting the bounds of the tree. This is definitely an issue I've never seen before, which really makes me wonder if there is anything about your tree that isn't normal for a typical Unity Tree Creator tree...

I guess it could be bounding up the tree correctly... the other possibility is that it is failing to size the camera correctly... it looks like it does set the camera's settings as well, between lines 721 and 730... so there's a small chance the issue could be there but I'd rather believe it is the tree than that it is the camera, since those camera settings have been working for everyone else.

One way to tell though if it is the camera is to load up the original converter scene that has my trees in it, and run the scene on my trees and see if it works without errors. If you think you changed the scene in any way, you might need to reimport the whole LushLOD project, a clean import, just to ensure there isn't anything you might have changed. If it converts my trees just fine but doesn't convert yours, then at least we'd know it's something about your specific tree that is confusing it.

I have tested your unchanged scene, all perfect.  I pulled your trees into my scene. I put one of your trees in the 'put trees here' without any others. it performed as intended. I put my tree in as well as one of yours, yours worked as intended, mine did not.  I looked to identify differences in the leaves, because the bark appears on my screen at the correct size. my leaves are billboards while yours are mesh. I temporarily changed my leaves to tricross... it rendered as intended. 
So, the billboards are failing to resize correctly.  thinking about this now, it does not surprise me that it is unity billboards causing a problem. they have been the source of many problems for me and actually the reason I bought your asset to replace all my trees and have better billboards.

As I try to resize my trees manually, the billboards refuse to resize as well. they end up becoming bunched up and will result  in the screen being filled with leaves if you're photographing them, at a reduced size.  There is a leaf size control in my tree prefab but I don't really want to mess with that as it could ruin my tree irreparably. 

I didn't know unity billboards couldn't be resized. Strange that this has't been reported before. The solution would be that instead of resizing the trees to be smaller to fit the camera, the camera should be resized bigger to fit the trees. I'm gonna try off the top of my head to write the code you'd need. This is the code between lines 712 and 730. Replace that code with this and see if it works correctly. This is untested code, I wrote this off the top of my head... hopefully I didn't make a mistake...

// Transform Render Obj to occupy in Unit Cube
//renderParent.transform.localScale = new Vector3((1f / bounds.size.x),(1f / bounds.size.y),(1f / bounds.size.z)); //<-- this is what used to shrink the tree, so this line is now commented out.

// Recalculate Cube Bounds
Bounds cubeBounds = GetBounds(renderParent);

// Init Camera
BillboardCamera.transform.position = cubeBounds.center; //<-- camera is put into the center of the box that the tree is in.
BillboardCamera.transform.rotation = Quaternion.LookRotation(Vector3.left, Vector3.up);
BillboardCamera.transform.localScale = Vector3.one; //<-- I'm not sure if this actually does anything. I don't think this affects the size of the picture though. Might be okay to comment out this line.
BillboardCamera.orthographic = true;

float LargestBoundsSide = Mathf.Max(Mathf.Max(bounds.size.x, bounds.size.y), bounds.size.z); //<-- this should get the size of the bounds that is the largest... either x, or y, or z, whichever of those three is biggest.

BillboardCamera.orthographicSize = LargestBoundsSide / 2f; //<-- pretty sure the camera size needs to be half the size of whatever it is taking a picture of... this is an off-the-top-of-my-head guess, I didn't test this.
BillboardCamera.nearClipPlane = -LargestBoundsSide; //<-- the camera is in the center of the tree, so we have to allow the camera to see "backwards", which is why the negative sign on this one.
BillboardCamera.farClipPlane = LargestBoundsSide; //<-- how far the camera can see forward.
BillboardCamera.rect = new Rect(0f, 0f, (float)BillboardTextureSize / Screen.width, (float)BillboardTextureSize / Screen.height); //<-- I didn't change this.. I think this simply ensures that the picture being taken will be square. It's possible this also might control the size in pixels of the resulting screenshot image, not sure.
BillboardCamera.enabled = true;
Selection.activeGameObject = BillboardCamera.gameObject;

Thank you, this seems to have resolved that issue completely! 

Still an issue with no ambient occlusion though... but did you say I had to upgrade my unity version to get that? 

now that the trees are being created correctly, I have noticed another issue. the tree is not transitioning to billboard. I set it to 10, the minimum distance to turn into a billboard, and yet it does not change at all. I've tried moving the camera really really far away and also, the editor window really far away but it's definitely not showing the billboard version. I selected the Lod_1 and moved it about just to make sure.

Did you try creating a new scene, and putting the tree into that scene, and then select the tree and follow all the setup steps (to create the manager and everything)? Maybe try also putting one of my trees into the scene next to yours, and see if mine is transitioning, while yours isn't?

good point, I'll try that now

Yea I think I added a slider to control how much ambient occlusion... but that's only in 2018.1.

You can install 2018.1 into a separate folder from your 2017.1 installation, to have both copies of unity on your computer at the same time. They don't interfere with each other. I have copies of unity installed for versions all the way back to 5.0 I think. 


Then copy your entire project folder, and add "2018.1" to the end of the folder name, for the new copy. That way you won't mess anything up if you need to switch back to 2017. Then load that new copy into 2018.1 of unity and see if it's as bad as you feared, lol. Just be sure that on the 2018.1 copy, you'll need to download the LushLOD trees asset again, because then it'll give you the 2018.1 version, which hopefully will give you all the additional shadow options you were wishing you had.

okay, new scene, no change, with your tree, no change. it doesn't change to billboard at all

yes I'm thinking of trying upgrading my unity, but I'm worried that I won't catch all possible errors. I've been playtesting my game for 4 years now and I often forget which parts to test to see if there are any errors. 

Is my tree changing to billboard though, while it is right next to yours?

Maybe in the manager, select the "billboards only" option, and see what happens. That should switch it to the billboard. It won't transition, it's supposed to stay in billboard mode while you have that option selected.

It's possible that some or all of my 2018.1 version would actually run on 2017.1. I mean, I could send it to you and you could try it to see if it works. But first, you probably should at least get it working correctly on the 2017.1 version. :)

interesting. even if i set it to billboards only, it does not show a billboard. on any trees. the behaviour is the same regardless of which tree it is, mine or yours.

I'm gonna load up 2017 and copy over all the scripts and shaders from the 2018 version and see if it works. If it does, I'll put the scripts and shaders into a zip and send it to you. But don't get your hopes too high, I donno yet if it'll run on 2017. ;p

no worries, I'm just copying my files to a new folder to try on 2018. 10GB, yikes. in any case, it's still useful for me to help you debugging your 12017 version though isn't it?

Wow it works great actually, I just had to fix 5 lines that had errors and boom, I got ambient occlusion on 2017.1... gimme your email or something and I'll send you a zip with the scripts and shaders folders for 2018.1

can i send it to you via twitter? I'm @triadne on twitter

 

Wait, even my tree isn't transitiong? What about if you load my main demo scene... the one named Gaia Demo (not the "fast" one). If you run that scene, the trees definitely should be transitioning. If the trees are transitioning correctly in that demo scene, then maybe try making a copy of that demo scene, and then drop your tree into the scene, and click play. Then see what happens.

very weird.  I believe it seemed to work correctly in your scene. I cam back to my scene and now it's being really inconsistent. when i selected billboard only, it shows both the billboard and the full model at the same time.  now i set it to a long lod, and it transitioned correctly, but as i was moving the camera closer, it retained the billboard quite stubbornly until I was right next to the tree. 

Hmm I followed you on twitch but I don't see an option to send a zip file? Oh well, here's a link to directly download it. Let me know once you've done the download so I can cancel the link, because anyone can use this link lol.


[ link deleted ]

Be sure to close the project first, and exit out of unity probably.

Then delete the scripts folder form LushLOD/scripts and replace it with the scripts folder inside this zip. 

Then also delete the shaders folder from LushLOD/Internal Files/Shaders, and replace it with the shaders folder form this zip.

Then restart unity 2017.1 and it should all just work... try loading up my Gaia demo scene (not the "fast" one). The trees might look black first, but just select the manager and the manager will detect the problem and should instantly fix it. That should only happen just the first time, and it's because your trees were created on 2017 and the manager fixed them to work on 2018, or something like that.

And then click play, and they should transition... just fine. My trees that is, in that Gaia demo scene. Then in the manager, you should see a bunch of new slider bars to control the shadows, including an ambient occlusion slider. Try each slider and see what they do. The slider that controls night and day will appear to do nothing, but you just need to make the sun go down to see it (change the angle of the main directional light, to make the sun go down). The transluciency sliders are more noticeable if you are behind the trees (away from the sun). 

If it all looks correct, then again, I'd suggest trying to drop one of your trees right into that gaia demo scene and see if your tree busts the whole scene and makes all the trees stop transitioning, or... just see what happens. Might want to create a backup of the scene first though, so you don't have to redownload it in case you mess it up.

Just read your message... I suggest you try the manager's button at the bottom of the manager to "revert all"... and see if that puts the trees back into a working state. Something must have messed them up. Possibly you changed something while working with them. That button sometimes will just instantly fix everything. But if not, then I'd suggest you delete the whole LushLOD folder, and redownload a fresh copy of LushLOD... to get it back working agian. Then, install the 2018.1 upgrade from the zip I sent you. Then, open the Gaia scene and select the manager to make the tree's quit being black colored, and it should all transition fine when you click play.

The fact that the trees got messed up the way you are describing... that was because of a bug... and I'm pretty sure I fixed that bug in 2018, so hopefully you'll never see it again now that you're installing the 2018 scripts.

well. 
now it all appears to be working!  fingers crossed! 
I put my tree in the gaia scene with the new scripts and everything and it behaves correctly. I'm sure i can probably benefit from reconverting it along with all my other trees, but for the most part this all seems to be a success. thank you.

+1
Fixed

Nice! Well then, keep a copy of that zip file somewhere. Of course, if you lose the zip, or if I come out with any more major updates (which is unlikely........) just ask and I'll send it again. I'll go ahead and delete the link now. I'll mark this thread as solved, but if you run into any more problems we can keep talking on this thread. :)

I've already put the camera sizing fix in, so that in any future updates that fix will be included for everyone. But I'm probably not gonna rush an update out just because of that fix, since nobody else has ever reported this problem, so I think it's probably pretty rare.

Oh I just thought of something... if you had already put lushLOD trees into your scene, but you need to re-convert them for whatever reason, I believe the 2018 version has an option to upgrade the trees. I think you just select a lushLOD tree in your scene, and there should be a button to upgrade it to a newer prefab.

So if you run the converter scene again and you want to not lose any work you may have done on your scenes... like if you had already been adding lushLOD trees to your scenes... then if you run the converter again and you have a new output folder... you can go to the scenes you had been working on and select any lushLOD tree in your scenes and there should be a button on each tree to upgrade each type of tree to the newer prefab, so you don't have to place all your trees all over again. It only has to be done once for each scene, for each type of tree in the scene... even if you have thousands of copies of each type of tree.

Also, there's a converter to convert an entire scene... if the scene is using Unity Trees (not lushLOD trees), you can convert the whole scene into LushLOD trees, and keep all the positions of the trees intact. There's some extra steps you have to do though to make that work... like, you still have to run the converter scene first, and have an output folder ready with all the lushLOD prefabs, but it'll convert all the unity trees into the lushLOD trees, and save their positions on the map. All the info on how to do that should be in the online version of the documentation. Be aware that your documentation is for the 2017 version... so don't read your local copy of the documentation... use the online version of the documentation, which I think is all found here on this website.

well now it's got a divide by zero error on the tree converter script before i even try to run anything.
I don't have much patience for this, I'm going to focus on upgrading my project to 2018.

never mind, that divide by zero editor is the same as before, but I thought this was what was happening because there is a compile error somewhere. I'm reverting to the 2017 version, editing the code that you posted above, and then once my trees are built, if it does not display then i will try importing the scripts you sent me in google drive. hopefully everything wil display correctly, but I am worried about this compile error. if I open the tree converter things might go crazy. 

Also, is it supposed to take over 12 hours to upgrade the prefabs? I've got about 600 trees but I don't understand why it would take this long. I could manually replace them faster.

I'm sorry I can't deal with this. There are too many issues with the asset pack, I can't afford to be spending this kind of time trying to get this to work. I appreciate you taking your time to help with this, but I have to draw the line somewhere. If it's advertised as working for 2017, then it should be working and I shouldn't be having this much hassle. I'm going to leave a review and request a refund. people should know that A, you are dedicated to helping address issues, and B there are potentially a lot of bad issues. I hope you can resolve everything with it and i wish you success, but this is the end of the line for me. 

Under review

If you upgraded to 2018, and redownloaded the package, it might have over-written the converter script that had the fixes you made, which might be why the divide by zero error came back. I can't think of any other reason it would be back. It should be very fast to upgrade the prefabs, if it was going that slow then... assuming it wasn't spamming any errors in the console... it sounds like "undo" might have been enabled, I know undo can slow it down ridiculously during that particular loop, because it wants to save an undo state for the entire scene after each tree is changed. But I would think it would turn off undo during that process, so I don't know why it would have been saving undo states during that process. Sorry I didn't get back with you sooner, had family over. And sorry it didn't work out. I originally spent a full year creating this tree system (working like 16 hours a day on it)... the shaders are fantastically complex.... thinking it might compete with speedtree, but for some reason my trees never sold much, just a few each month, so after the initial release there just wasn't enough sales to justify me really working much more on it, so except for the 2018 update I haven't done much except try to help fix bug reports like yours, when they come in. But with the sales being so few, I don't actually get many bug reports either, I mean, the bugs you reported here were obviously in the package since day one and nobody said anything, so that tells you how low my sales have been. Anyway, I'm not trying to talk you into using the trees anymore, just wanted to give you some context so you'd understand that I'm not a big company, and that's part of the reason why you found problems in the package. But the real meat of the package is the shaders, which are what I spent most of that year working on.. but unfortunately you probably hardly got to see much of the shaders due to the scripts giving you so much problems. Sorry about that.

Thanks for the reply. I understand your position, I have also released assets on the store that did not do as well as I expected. I don't envy you having a code asset since i can imagine support for that is much more difficult and involved than for a simple set of models. 
I wish you all the best!

Hi, can I just confirm that I am requesting a refund? I can't find any information on how to do so, so I believe it has to be done manually?

What's the order number?

oh sorry! the order number is 5772610491429 . Thanks . 

I sent the ticket, it says they answer in 3-5 days, so you should see the refund some time after that.

Thank you very much. let me know if there's anything I can help you with.