- Home /
How do i Offset a Shader Graph material?
Hoping someone can help me here. I need to offset the Sand dune shader that we have, to match up with the chunks in the terrain generation. But i have never really worked with shaders, so i am hoping someone here can help me on how i offset the shader.
So i am not sure, since i have not worked with shaders before, but i would imagine that i would simply need to offset the starting point of the shader by the offset of each chunk that is being generated. I ofcourse know my offset of the chunks, but how do i translate that to the material that is being applied? I found the code for "material.SetTextureOffset" but i have not been able to get any results using that. But i am also not strong on this topic :) Hoping someone can enlighten me. So i am not sure, since i have not worked with shaders before, but i would imagine that i would simply need to offset the starting point of the shader by the offset of each chunk that is being generated. I ofcourse know my offset of the chunks, but how do i translate that to the material that is being applied? I found the code for "material.SetTextureOffset" but i have not been able to get any results using that. But i am also not strong on this topic :) Hoping someone can enlighten me.
I did notice that there is a component called "Tiling & Offset" for the shader graph. Do i need to apply that to the shader and then modify that through code? I never worked with shaders, so please do enlighten me.
Edit: So i found "Graphics.Blit" code, that should be able to project a shader onto a renderTexture. Then i should be able to apply that new rendertexture to a material.maintexture on the instantiated terrain, but that just simply makes my terrain black, as if it did not project the shader onto the rendertexture at all. Maybe someone knows how i can fix this problem? Guessing it is because the shader does not return any XY or UV properly?