You are not making much sense! Are you talking about how to write your shader HLSL code or your C++ code? Or do you not know the difference?
Sorry SamiHuutoniemi,
My english ir very poor
I'll put an example, I have a scene with several 3D models (OBJ format for example), and would create five point lights to the scene using HLSL, but I would like to create 5 lights in 5 objects of a class.
In this example:
http://www.dhpoware.com/demos/d3d9MultiplePointLights.html
The author has created one .fx (HLSL) where it creates a shader to be within the desired number of lights
//-----------------------------------------------------------------------------
// Pixel Shaders.
//-----------------------------------------------------------------------------
float4 PS_SinglePassPointLighting(VS_OUTPUT IN) : COLOR
{
float4 color = float4(0.0f, 0.0f, 0.0f, 0.0f);
float3 n = normalize(IN.normal);
float3 v = normalize(IN.viewDir);
float3 l = float3(0.0f, 0.0f, 0.0f);
float3 h = float3(0.0f, 0.0f, 0.0f);
float atten = 0.0f;
float nDotL = 0.0f;
float nDotH = 0.0f;
float power = 0.0f;
for (int i = 0; i < MAX_POINT_LIGHTS; ++i)
{
l = (lights.pos - IN.worldPos) / lights.radius;
atten = saturate(1.0f - dot(l, l));
l = normalize(l);
h = normalize(l + v);
nDotL = saturate(dot(n, l));
nDotH = saturate(dot(n, h));
power = (nDotL == 0.0f) ? 0.0f : pow(nDotH, material.shininess);
color += (material.ambient * (globalAmbient + (atten * lights.ambient))) +
(material.diffuse * lights.diffuse * nDotL * atten) +
(material.specular * lights.specular * power * atten);
}
return color * tex2D(colorMap, IN.texCoord);
}
But I like to do instead, create a desired number of lights in my C++ code using a class made ??for light eg.
How should my shader (HLSL)? This is possible? and because the example he made the desired number of lights in the fx file?