Question by
MobinYaqoob · Jun 01, 2021 at 03:00 PM ·
shadertexturematerial
Change Texture From World Position Amplify Shader
I Recenly wrote a shader which change the texture of a gameobject form world position it is working fine on PC , Android , Mac but not working on IOS. Here is a screen shot of shader:
if (Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit raycastHit;
if (Physics.Raycast(ray,out raycastHit,1000.0f))
{
material_hit = raycastHit.transform.gameObject.GetComponent<Renderer>().sharedMaterial;
//Get Texture
material_hit.SetTexture("_NormalMap1", material_hit.GetTexture("_NormalMap2"));
//Set Texture
normalIndex++;
normalIndex = normalIndex % 2;
material_hit.SetTexture("_NormalMap2", normals[normalIndex]);
//Get Color
material_hit.SetColor("_Diffuse1Color", material_hit.GetColor("_Diffuse2Color"));
//Set Color
material_hit.SetColor("_Diffuse2Color", Random.ColorHSV());
//material_hit.SetFloat("_speed", 1.9f);
material_hit.SetVector("_postion", raycastHit.point);
material_hit.SetFloat("_start_time", Time.timeSinceLevelLoad);
}
//
}
Comment