Let me be frank, I know nothing about making shaders (in games).
The idea is that when my character moves, and its leg hits the sand, the shader of the field of sand models will moves, which will be reflecting sunlight will move/rotates, as if like pushing each other, simulating tiny particles of sand, reflecting lights in different angles.
But I dont have any idea of how to do that with shaders. Will it work if I just change the value of the field heighmaps, or I have to make thousand of planes which will represent particles of sand, shades them, and move them procedurally?
Either way, it will use a lot of raw powers. I dont want to used a pre-determined effects of some shaders, I want dynamicity
Any suggestion? Sorry if it sound too far-fetched for a newb like me
*Trying to achieve same effect of the sands in Journey
What you maybe can try is, when the player's step hits the sand you want to convert the world space hit position to a UV position for the shader and displace vertices and rotate normals away from it depending on the distance from the hit point.
I think I have a good idea how to do that! One moment.
[editline]3rd October 2014[/editline]
Basically, what you'll want to do is have a cyclic gradient (along two dimensions, one wouldn't be enough) that overflows and wraps around at the end in the lookup. (Just let the raw value grow indefinitely.)
You should also have a noise texture (just for the finest layer(s), which probably still should have features larger than a single pixel; Larger structures with distinct features should have a larger, less repeating decal textures). You can also layer this noise.
The displacement doesn't necessarily have to be flat (0; 0) at the beginning, but it must be smooth.
You can experiment with ripples, but that's probably something better done in a shader since you'll want to move the displacement map around. (To do that it's better to shift UVs with [I]wrap mode: repeat[/I] than to shift the image to compensate player movement, I think.)
When the player steps down on the sand, you can progressively apply additive decals that shift the noise lookup, so that is looks like the small features move along the surface, away from the foot.
(For the glittering/grains just use per pixel random noise that stays consistent with the texture lookup and possibly to some extent the view.)
When the character lifts their foot again, apply some decals counteracting part of the effect but weak/small enough to leave a distortion. (If you want actual indentations in the surface just add the height map as third dimension in the displacement map and decal textures, then render with that raymarching technique that I forgot the name of again.)
Since you probably won't be able to fill the whole map with a high-res texture, you should have a step that slowly degrades the displacements back to the default value of (0; 0) as they are reaching the edge of the texture and "fall off" the persistent area. It could be a good idea to make the effect non-orientable though, to avoid square shapes if the player keeps running around in one spot.
I [I]think[/I] this is actually pretty similar to e.g. L4D2's flowing water shader, except that the noise texture is a ripple function or texture and the additive applications come from a flow map and not from decals.
(You can also consider making the decals signify speed of change, that way you can render at lower frame rates and only lose accuracy.)
[editline]3rd October 2014[/editline]
(It may also be a good idea to add a sparse layer that reacts more strongly to the displacement map, that way you get thrown/rolling grains for free. This could lead to weird effects when e.g. lifting a foot though.)
This won't help with your sand shader, however it's a great presentation that helped me understand shaders. [URL=http://et1337.github.io/shaders/]shaders, how do they work?[/URL]
Sorry, you need to Log In to post a reply to this thread.