Texture offset not working with shader
As soon as I added a shader from the asset store onto a quad object in my game, I was unable to use renderer.material.mainTextureOffset or the offset slider in the inspector to shift the texture of the material on the quad. I have little experience with shaders, so I was hoping someone would take a look at this code to confirm my suspicions that the shader is not allowing texture offset:
Shader "Black Hole" {
Properties {
_MainTex ("Main", 2D) = "white" {}
_Center ("Center", Vector) = (0.5, 0.5, 0, 0)
_Distortion ("Distortion", Float) = -2
_DarkRange ("Dark Range", Float) = 0.1
_Warp ("Warp", Float) = 30
}
CGINCLUDE
#include "UnityCG.cginc"
sampler2D _MainTex;
float2 _Center;
float _Distortion, _DarkRange, _Warp;
float4 frag (v2f_img input) : SV_TARGET
{
float2 uv = input.uv;
float2 center = _Center * _ScreenParams.xy;
float dist = distance(center, uv * _ScreenParams.xy);
float2 warp = normalize(_Center - uv) * pow(dist, _Distortion) * _Warp;
warp.y = -warp.y;
uv = uv + warp;
float light = saturate(_DarkRange * dist - 1.5);
return tex2D(_MainTex, uv) * light;
}
ENDCG
SubShader {
ZTest Off Cull Off ZWrite Off Blend Off Fog { Mode Off }
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
ENDCG
}
}
FallBack Off
}
I imagine there is an easy explanation for this, but I must have missed it during my searching through forums and documentation. Any help on this issue would be much appreciated.
Your answer
![](https://koobas.hobune.stream/wayback/20220613055234im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
procedural Texture antialiasing issue 0 Answers
Mix Shaders Question -- Multiple Textures, Recolorable? 1 Answer
shader graph messes up the texture (2D) 0 Answers
Texture offset look at 3D position 0 Answers
Inside of a shader how can I convert a world direction relevant to a vertex's local position 1 Answer