Hey i've just started learning to write hlsl on last thursday and i've made this shader:
It's got two light sources, diffuse, specular, glow, and normal texture maps. However i think it needs optimization however being a beginner in hlsl i'm not sure what can be done to this to really speed it up. Could i be getting these low frame rates because of my gpu? I'm on an Intel g31/g33 express chipset with shader model 2.0 and the latest directx 9. I'll post the shader to see if you guys can help me out with it, and here is what you need to set to use it (with gdk syntax, but it will still help):
dbSetVector4 (1, 0.0, 0.0, 0.0, 1 );
dbSetEffectConstantVector ( 1, "materialEmissive", 1 );
dbSetVector4 (1, 0.20, 0.20, 0.20, 1 );
dbSetEffectConstantVector ( 1, "materialAmbient", 1 );
dbSetVector4 (1, 1.0, 1.0, 1.0, 1.0 );
dbSetEffectConstantVector ( 1, "materialDiffuse", 1 );
dbSetVector4 (1, 01.0, 01.0, 01.0, 1 );
dbSetEffectConstantVector ( 1, "materialSpecular", 1 );
dbSetEffectConstantFloat ( 1, "materialGlowPower", 1 );
dbSetEffectConstantFloat ( 1, "materialPower", 40 );
dbSetVector4 (1, dbObjectPositionX(2), dbObjectPositionY(2), dbObjectPositionZ(2), 1 );
dbSetEffectConstantVector ( 1, "Light1Pos", 1 );
dbSetVector4 (1, 01.0, 0.90, 0.70, 1 );
dbSetEffectConstantVector ( 1, "Light1Color", 1 );
dbSetEffectConstantFloat ( 1, "Light1Range", 75 );
dbSetEffectConstantFloat ( 1, "Light1Intense", 1.5 );
dbSetVector4 (1, dbObjectPositionX(4), dbObjectPositionY(4), dbObjectPositionZ(4), 1 );
dbSetEffectConstantVector ( 1, "Light2Pos", 1 );
dbSetVector4 (1, 0.10, 0.40, 01.0, 1 );
dbSetEffectConstantVector ( 1, "Light2Color", 1 );
dbSetEffectConstantFloat ( 1, "Light2Range", 100 );
dbSetEffectConstantFloat ( 1, "Light2Intense",10 );
and here is how the textures are applied to the model:
[Texture name, texture stage]
("diff.png", 0)
("spec.png", 1)
("glow.png", 2)
("norm.png", 3)
I'd post the media i'm using but the files are fairly large and i'm sure if youre working with shaders you have your own media to use. The model i'm currently using is called Imrod, and he can be found at
parkparkin.com/