- Home /
Texture alpha doesn't scroll with offset
I'm trying to get a parallax scrolling background working using the mainTextureOffset property on a material.
//
Vector2 textureOffset = new Vector2(Offset, 0);
_renderer.material.mainTextureOffset = textureOffset;
//
I also tried the following, since I'm using URP:
//
_renderer.material.SetTextureOffset("_BaseMap", textureOffset);
//
The problem is the texture scrolls fine, but the alpha channel doesn't appear to move at all. For example, in the attached image as the texture scrolls, the tall weeds are only visible when they line up with other tall points in the texture. (see image 1)
I've also tried making a shader via the ShaderGraph, which has the exact same behavior even with an extra node to account for the alpha channel (see image 2). This is actually worse because the alpha cutoff makes the texture look jagged and less transparent.
Answer by xibanya · Oct 09, 2020 at 05:02 AM
In the import settings for the sprite, change the Mesh Type to Full Rect
You can also scroll the UVs rather than the offset, either in a shader, or by using the RawImage component rather than the regular Image component. Do the scroll by adjusting the values in the UV rect fields.
Your answer
Follow this Question
Related Questions
How can i get my quad to only render my texture without stretching it? 1 Answer
How to change RGB base of material via scripting (Normal map + base RGB) ? 1 Answer
How does Material's "SetShaderPassEnabled" work? 1 Answer
Shader with two textures separated by an alpha channel? 1 Answer
Shader Shadow Effect Issues 0 Answers