@treivize i am sorry but IMHO your wind function is way too simple to be any kind of “official” solution and at the same time way too expensive: using “gradient noise”?!
Definitely, I have not your experience in this domain, but IMHO having a simple unrealistic model for the the wind function for the type of game we are building might not be a problem. At the end, it is just a way to make the environment lively where the wind effect will remain an artistical touch not part of the game mechanics or wow effects.
Next, regarding the cost of shader graph “gradient noise” it is really good to know that it is an expensive function. Do you have suggestions to replace it with something more efficient?
Apologies if this isnt the right place to comment on this, but i was looking at the Sail shader ticket.
I’m not quite sure why the existing wind solution wont work on the sail, how is the sail any different? The wind shader might be a little costly, but overall its excellently made!
Is it that the object itself moves, and the strength of the wind in that case should be increased? If thats the case, even a C# script that modulates the wind-strength property on the material (or more performant via materialpropertyblock!) would do.
I’m more worried about the mesh topology not working well for vertex-color modulation
There simply are too few polygons to animate properly, would it be possible for someone to export a higher poly model? This is the result at the moment, there are especially polygons missing in the middle of the sail to bulk out.
I see it the same way. I guess that’s taking economizing on triangles too far - especially when the hulk has 2178 triangles. So I couldn’t resist the challenge to create a credible sail with as little triangles as possible (which were 158):
I can add it to the PR I am about to raise anyway for the desserter if @cirocontinisio approves.
All i did there was paint some colors with PolyBrush, and slap on the existing Wind shader. If noone else picks it up i can make a script that sets the strength based on the current velocity of an object, that should be sufficient for the sail. And any other object that should flutter with the wind!
You’re right, the sail is very lowpoly, that’s why I mentioned in the card that the mesh probably needs to be changed. As for the shader, yeah… it might be the same as wind. But I figured, maybe for the sail it could be ok if it’s in Object space, rather than world?
Of course it’s just slightly unrealistic if the sail bloats in exactly the same way while it rotates, but it should be ok for our game.
But to be fair, both the sail and the plants blow to the same wind, right? So the direction should be the same.
If you have time and will, you can also tweak the existing Wind shader in a way that makes sense for the sail too. Optimising it too, if you want.
Thanks @Smurjo , it’s always better if PRs are separate (and you don’t need to write too many details for them, of course)
I have both ready. I have observed that any additional commits will be automatically added to an open PR if you have one. How can I avoid this and have 2 separate PR instead?
There seem to be some problems with importing, that you noticed too. In the prefab you’ve changed the scale of the wind sail, and rotated it around. This causes issues with the wind-shader, would it be possible to fix these in the modeling program?
It would be no problem, it is just that the sail is in the position and scale where I found it
The boat is made of 3 different objects, the original fbx too. Why is this? Its inefficient to render this as three different draw calls. It could be one for the entire thing, or perhaps two so we have a separate material for the sail. I dont see why the mast has to be another object.
Same here - it was 3 different objects. It would not be a problem to join them into 1, albeit we would then have the windshader on the hulk and would have to vertex-paint it black. Maybe it is better to have 2 separate objects. The only reason I can imagine why it was 3 objects is that you can actually steer the boat then - albeit you would then need to control the sail rotation and the rudder rotation separately - resulting in four objects. @cirocontinisio What do we want? Can we imagine we animate steering the boat in a cutscene?
I think its best to overwrite the current boat fbx, instead of making a new one with your name appended. With GIT we always have history of the project, so we can go back to the old version, or even see that you’ve made it. Like this we’d have a ton of models real fast, and we wouldnt know which one to use!
The model comes without vertex colors for the weight of the sail, do you think it makes sense to do so in the modeling program instead of in Unity?
I can certainly paint the vertex colors - it is just because you had painted them before I didn’t touch them. Do you have any specific wishes? In your videos I considered the movement of the outer edge somewhat too strong or I would have to make more edges there. P.S.: Living far from the coast, I personally have no experience with sail boats.
Ah thats a great reason i hadnt considered yet. Although at that point we could also consider using a skinned mesh.
I’m just a simple programmer, and added some colors for testing. I’ll try to commit the shader so you can play around with it and i’m sure you can get much better results than me.
Even when living below sea level this can be a struggle. I’m assuming something like Zelda Wind Waker is the goal, as seen here for example. What i’m currently aiming for:
The ripples we can see in the sail is the existing wind solution.
The bulging of the sail itself is an effect specifically for the sail shader. I was thinking of moving the sail out along the normal, based on the rotation of the boat, modulated by the vertex color red channel.
E.g. if we are looking world-space-forward we push it 100% along the normal, and the red vertex color makes sure it bulges out more in the middle, and hardly at all around the edges. And when you turn the boat backwards it would be point in the opposite direction of the normal.
This is pretty decent if you ask me! Lets iterate over this together, i’m certain you can get much better results than me.
I’ve also made a pull request, the shader works fine here on your model too, but you just have to increase the ‘SailBulgeStrength’ to 100, to counteract the scale. Because the sail object is scaled at 0.01 the bulge is also very small.
Please let me know if you have some suggestions in order to improve the effect.
I am now pushing the sail object to the right, not along the normal, because this caused the sail to rip apart. Makes a lot of sense that this happens, on the one side the normals point the other way.
I’d like to see if i can make the direction less linear, right now if you are sailing east the sail hardly bulges. Hopefully not making it linear but something extreme like quadratic it will bulge much faster, and those directions that have no bulge are rarer. It all kind of depends on the intended use case though.
It’s pretty decent except the sail goes through this upper horizontal piece on the mast. Could we have blue vertex color to limit the bulging in the other direction? I would then adapt the mesh yet again, and we can make it look as if was blown against this piece of wood.
[quote=“TJHeuvel-net, post:14, topic: 816713, username:TJHeuvel-net”]
right now if you are sailing east the sail hardly bulges.
[/quote] It is quite possibly the reality that you can’t sail in any direction as you desire. I think if you want to go against the wind you need to do it in zigzag.
Sounds like an excellent solution, i will look into that. Maybe even tweaking the vertex colors i filled in will do the trick, not allowing any bulge in that area.
Looking at the reference i arbitrarily choose, the sail is very simple, and attached only in a few specific points. This makes it possible to flutter much more, thats probably a very deliberate decision.
I have added the vertex colors including a blue channel and put it into the pull request. I think we need different channels as we want the sail to bulge when it doesn’t hit the wood.
I have also sorted out the pivots, scales and positions. The boat can be steered now.
Thank you! I will take a look today, so the top of the sail only bulges in one direction.
I’m not artist, but what do you think about removing that side-beam, and attaching it in fewer places, so the sail can move more dynamically? I think in the end it would look better, more interesting.
Will it look more interesting without the side-beam? Definitely not if we can pull it off to make the sail look as if it was blown against the wood but doesn’t go through it. If we don’t manage we can always fall back to removing the beam.
Would your shader possibly need a Vector3 then to tell it the “red” - direction of the bulging? I am thinking we could then use the same shader e.g. for the cover of a market stall bulging downward due to gravity.
I thought so too, thats why i wanted to use the normal at first. But that didnt work, so i just tried pushing it to object-space-right, and that looked ok.
We could encode the direction in something else as well, such as uv2 or in a separate texture. Or just use vertexcolor for this, where black means no movement, red fully to the right, blue fully up etc. That could even be relative to the normal. Not quite sure how to then also encode the limit, e.g. some part is allowed to move all the way in the direction and the opposite, and some parts are not.
Ill first make the version that limits motion to the left according to the blue channel.