on 19-06-2012 08:49 PM
Hello all, I'm starting to play around with the SDK and I'm trying to implement a light manager system, specially after following this nice tutorial http://www.gamefromscratch.com/post/2012/04/30/Exp
I found that the BasicProgram has in its BasicParameters support for directional lights via the SetLightDirection property, but I see no support for either types of lights or light position.
So is there any way to add point and eventually spot lights to a scene through the BasicProgram? Or should I create a custom shader and then load it as a BasicProgram? (in which case I would really appreciate any example of a basic shader loaded through the BasicProgram constructor)
Solved! Go to Solution.
on 21-06-2012 02:45 PM
Hi:
Well you can add it easly. Use this http://http.developer.nvidia.com/CgTutorial/cg_tut
Cheers,
on 22-06-2012 01:34 AM
Alright this is not a complete solution but here it goes, also keep in mind that I might have a lot of mistakes in my interpretation so please correct me if I'm wrong.
So if you want to load a model using the BasicModel class, you will have to use a BasicProgram to render it. The thing is that BasicProgram only support directional lights in its properties (BasicProperties), if you use the default version of the BasicProgram. Now the constructor is able to create a new BasicProgram from a cgx, with the condition that the cgx has the parameters that any BasicProgram uses in the correct index.
This means that you need to create a vertex shader with all the properties that the BasicProgram shader uses, and then you can add your own properties to the shader and access them through the SetUniformValue method (as BasicProgram inherits from ShaderProgram).
In my opinion it would be nice if Sony added the framework for the shader in their documentation, but it might be just me not knowing how to work with the SDK.
After you have all these parameters set, you can apply the shader structure to which Alex kindly pointed to.
on 22-06-2012 03:21 PM
Hi:
Yes. It's not a complete soultion, but you now are in the correct path. You just need to add the extra needed data extending BasicModel and adding the needed SetUniformParam to get the cgx working.
Give me some time and I will probably post the code.
Cheers,
on 22-06-2012 06:47 PM
Hi Alex,
I think I was able to fill in the BasicProgram parameters in the shader yesterday, although I have been struggling with the way they handle multiple world matrixes, also, it seem as we need to define an array of lights (light parameters) in the shader, but it puzzles me the actual size that has to be used (for now I have it at 4).
Currently this is my parameter list for a really basic vertex shader:
void main(uniform bool EnableLighting, //0
uniform bool EnableFog, //1
uniform int WorldCount, //2
uniform int LightCount, //3
uniform float4x4 ViewProjection, //4
uniform float3 EyePosition, //5
uniform float4 FogVector, //6
uniform float3 FogColor, //7
uniform float4x4 WorldMatrix[4], //8
uniform float3 LightDirection[4], //9
uniform float3 LightDiffuse[4], //10
uniform float3 LightSpecular[4], //11
uniform float3 LightAmbient, //12
uniform float3 MaterialDiffuse, //13
uniform float3 MaterialSpecular, //14
uniform float3 MaterialAmbient, //15
uniform float3 MaterialEmission, //16
uniform float3 MaterialFactor, //17
float4 in a_Position : POSITION, //18
float2 in a_TexCoord : TEXCOORD0, //19
float4 in a_VertexColor : COLOR0, //20
float4 in a_Normal : NORMAL, //21
float in a_Weight : BLENDWEIGHT,//22
float4 out v_Position : POSITION, //23
float2 out v_TexCoord : TEXCOORD0, //24
float4 out v_Color : COLOR0) //25
{
...
}It seems as the multiple world matrixes are related to the animation of the object (I'm using the BasicModelSample from the SDK provided samples), I can't figure out how to actuallty use them.
Once I figure that out it will be just a matter of adding the extra light parameters to the shader in order for it to process point and spot lights (which should not be a problem)
on 22-06-2012 08:56 PM
Hi:
Fast question :Are you planning to use more than one light afecting the model?
Cheers,
on 22-06-2012 09:12 PM
Not for now, but eventually; however, the thing is that the way the BasicProgram instantiates its parameters requires you to have an array of lights in the shader, which means that they process their lights array inside the shader rather than outside.
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870