If you take a look through the PlayStation Mobile documentation, you may notice there is no functionality in the SDK for lighting. How then do you add lights to your scene? Well, shaders of course! In this recipe we are going to do exactly that.
Load PlayStation Mobile Studio and create a new project. Once again, we will use the prior recipe as a base for this recipe. The complete project is available as Ch7_Example6
.
Using
AppMain.cs
fromExample5
, editMain
to match the following (the new code is highlighted):Vector3 lightPosition = new Vector3(0.0f,10.0f,-3.0f); textureShader.SetUniformValue(textureShader.FindUniform("vecLightPos"),ref lightPosition); Vector4 ambientLightColor = new Vector4(0.05f,0.05f,0.05f,1.0f); bool done = false; while(!done) {
Then further down, edit the
event
loop to match the following code snippet:while(!done) { graphics.Clear (); var viewWorldProjection = camera.GetMatrix(); textureShader.SetUniformValue...