public static void SetLightingUniforms(Shader shader, Camera camera) { // fresnel sky/ground color for characters & stages ShaderTools.LightColorVector3Uniform(shader, Runtime.lightSetParam.fresnelLight.groundColor, "fresGroundColor"); ShaderTools.LightColorVector3Uniform(shader, Runtime.lightSetParam.fresnelLight.skyColor, "fresSkyColor"); shader.SetVector3("fresSkyDirection", Runtime.lightSetParam.fresnelLight.getSkyDirection()); shader.SetVector3("fresGroundDirection", Runtime.lightSetParam.fresnelLight.getGroundDirection()); // reflection color for characters & stages float refR, refG, refB = 1.0f; ColorTools.HsvToRgb(Runtime.reflectionHue, Runtime.reflectionSaturation, Runtime.reflectionIntensity, out refR, out refG, out refB); shader.SetVector3("refLightColor", refR, refG, refB); // character diffuse lights shader.SetVector3("difLightColor", Runtime.lightSetParam.characterDiffuse.diffuseColor.R, Runtime.lightSetParam.characterDiffuse.diffuseColor.G, Runtime.lightSetParam.characterDiffuse.diffuseColor.B); shader.SetVector3("ambLightColor", Runtime.lightSetParam.characterDiffuse.ambientColor.R, Runtime.lightSetParam.characterDiffuse.ambientColor.G, Runtime.lightSetParam.characterDiffuse.ambientColor.B); shader.SetVector3("difLightColor2", Runtime.lightSetParam.characterDiffuse2.diffuseColor.R, Runtime.lightSetParam.characterDiffuse2.diffuseColor.G, Runtime.lightSetParam.characterDiffuse2.diffuseColor.B); shader.SetVector3("ambLightColor2", Runtime.lightSetParam.characterDiffuse2.ambientColor.R, Runtime.lightSetParam.characterDiffuse2.ambientColor.G, Runtime.lightSetParam.characterDiffuse2.ambientColor.B); shader.SetVector3("difLightColor3", Runtime.lightSetParam.characterDiffuse3.diffuseColor.R, Runtime.lightSetParam.characterDiffuse3.diffuseColor.G, Runtime.lightSetParam.characterDiffuse3.diffuseColor.B); shader.SetVector3("ambLightColor3", Runtime.lightSetParam.characterDiffuse3.ambientColor.R, Runtime.lightSetParam.characterDiffuse3.ambientColor.G, Runtime.lightSetParam.characterDiffuse3.ambientColor.B); // character specular light shader.SetVector3("specLightColor", LightTools.specularLight.diffuseColor.R, LightTools.specularLight.diffuseColor.G, LightTools.specularLight.diffuseColor.B); // stage fog shader.SetBoolToInt("renderFog", Runtime.renderFog); shader.SetVector3("difLight2Direction", Runtime.lightSetParam.characterDiffuse2.direction); shader.SetVector3("difLight3Direction", Runtime.lightSetParam.characterDiffuse2.direction); if (Runtime.cameraLight) { // Camera light should only affect character lighting. Matrix4 invertedCamera = camera.MvpMatrix.Inverted(); Vector3 lightDirection = new Vector3(0f, 0f, -1f); shader.SetVector3("lightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized()); shader.SetVector3("specLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized()); shader.SetVector3("difLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized()); } else { shader.SetVector3("specLightDirection", LightTools.specularLight.direction); shader.SetVector3("difLightDirection", Runtime.lightSetParam.characterDiffuse.direction); } }