How to change directional light's texture in code?

Hello,

I was writing script for a directional light (moon) change its texture in a specific moment I want, and when I tried to find the “Surface texture” field in my moon’s object, I couldnt. Basically I dont see a field that allows me to change Surface texture of my moon in code.

Does anyone know how to set surface texture for my moon through code?

I assume you are talking about the property from HDRP’s celestial body system.

I think you can do something like this. HDRP stores renderpipeline-specific properties in a separate component

var hdLight = myLightGameObject.GetComponent<HDAdditionalLightData>();
hdLight.surfaceTexture = myTexture;
1 Like