Is there any way to modify shader params on a frame-by-frame basis when those parameters are within a subshader but not within a pass?
I have a world mesh with a 'clouds' texture that's on a separate mesh just over the world. I was getting z-fighting so I added an offset (simple enough), which works great until you start to zoom in and the z-fighting returns - this is because, as you move closer to the camera's near-clip plane, the depth layers become smaller and the offset just isn't doing as much. I could fix this by having a script dynamically set the Offset as a function of the mesh-to-camera distance, but I don't know how.
I'm trying to do something like this:
Forgive me if my code is way off - I'm rather new to shaders still, and it's hard to find a lot of documentation / examples / tutorials.
Note from below: To clarify: actually setting the value from a script isn't the issue. The issue is: how do I use a variable to set the Offset? It only seems to accept actual numbers - trying to set "Offset [_OFFSET], [_OFFSET]" throws a compilation error.
The question has been closed Oct 31 '11 at 08:25 PM by Julien.Lynge for the following reason:
Question is badly phrased and confusing.
I'm probably even newer to shaders than you, but have you looked into the Material.SetFloat() function?
I don't know much about shaders, but was able to manipulate the alpha value in one of ours using this function (and others like it)...
answered Oct 21 '11 at 08:19 PM