Hi! I have a question about Shader Graph property overrides together with Entity Graphics.
I want to use the mouse position on the screen in my shader graph shader. I wrote the following code for this, which works in editor but not in build.
Vector3 mousePosition = Input.mousePosition;
// Convert the mouse position to a 0-1 range
Vector2 mousePositionNormalized = new Vector2(mousePosition.x / Screen.width, mousePosition.y / Screen.height);
material.SetVector(MousePositionProperty, mousePositionNormalized);
In Shader graph, the property has as shader declaration ‘Per Material’. The material used for this is used by entities in an ECS subscene. In the documentation I found that it is possible to override a Shader Graph property by using a IComponentData
and shader declaration ‘Hybrid Per Instance’.
I think this would work but since this data would be the same across all instances it makes more sense to me to set it once per material.
Is it possible to make the ‘Per Material’ setting work in this context or should I switch to ‘Hybrid Per Instance’ and override per entity? Any insight would be greatly appreciated!