I have couple of queries regarding using shader.
If I want to add sparkling effect on some material and for that do I need to wright whole shader program while the Lightning shader is available? can we extend the Lightning shader just for additional sparkling effect? " sparkling effect" is just en example. I mean to ask is can we extend and re use existing nice work instead of writing new buggy implementation? if we can re use that how to do it?
If I wants to use vertex shader only than is it compulsory to make fragment shader from scratch. I mean to aske is can we use Lightning shader + additional vertex shader to perform some deformation.
I want to show some dynamic parallax mapping on surface without modifying Lightning shader. i.e. show vehicle tyre trek on light mud ground or showing foot trek on soft surface like snow or desert surface. how to do that.
Sorry for silly questions but these are huge for me…
Well you don’t have to rewrite it, you can copy the code from the existing lighting material and add what you want.
Or the alternative is to use shader nodes that allows to do exactly what you asked here.
I am little confused here. most of time I use tiled images for texturing. now my problem is how to set parallax map for specific bunch of coordinates. e.g. see below image. green blocks are tiles on surface. Red lines (amusing parallax map) I wants to draw/paint at run time on surface.
Then you can’t, you have to use a normal map for the entire area, but if you want small details on big meshes, this is not a viable solution of course.
I don’t think there are other alternatives, this or custom shader/shader nodes.
Well, let me recap.
You can do it by modifying the normal map, but this won’t work if it’s tiled. So you can’t use this method.
You can use a custom version of Lighting or shader nodes, and there are plenty ways to do it.
For example you could check triplanar mapping for projecting the track texture on your terrain, and you could use a gray scale texture for the entire terrain to mask it. This can also be done in screen space with post filters, but it is more complex.
Apart form that there is another way that now comes to my mind, that is generating one quad per each wheel that contains the track and extend/deform it behind the wheel, you can’t keep extending it forever of course, but you could make its length fixed,split it multiple segments,and move it altogether with the car, and then use either the Mesh class or a vertex shader to deform it when the car turns.
But i don’t know how this will perform with many sources that leave tracks behind, imo the other ones are better.
When you build the mask you will need to store where the center of the wheel is in order to align the texture correctly, and with triplanar mapping you can apply the texture without stretching it, it’s not necessary if your terrain is flat.