omg??BlindSide wrote:(Although the way you are doing it is very odd, why don't you just use the 2nd and 3rd texcoord's that Irrlicht has already set up with tangents and binormals for you? Yes I am talking about gl_MultiTexCoord1 and gl_MultiTexCoord2)
Well thats quite a bit of helpful info right there ty Blindside! It's strange that in all my searching I never found that anywhere...
Anyways it solved all my problems and now everything is looking great.
( extra shiny to show it off! )
![Image](http://www.cafes.net/ladyb/spec/leftcorner.jpg)
![Image](http://www.cafes.net/ladyb/spec/rightcorner.jpg)
In trying to solve this problem, I opted to scrap the Rendermonkey code for now and write my own little shader. While a smooth hook-up between Irr and RM would be great for the community, its not the topic of this thread.
Following is my code that I wrote to solve MY original problem. I am in no way adept enough in programming to think that I should/could change the engine itself to make it better. I just made my own material using glsl.
Here is the shader code.
Code: Select all
// BUMP vertex shader
varying vec3 LightDirection;
varying vec3 ViewDirection;
void main()
{
gl_Position = ftransform();
vec3 Position = vec3(gl_ModelViewMatrix * gl_Vertex);
gl_TexCoord[0] = gl_MultiTexCoord0;
vec3 Normal = gl_NormalMatrix * gl_Normal;
vec3 Tangent= gl_NormalMatrix * gl_MultiTexCoord1.xyz;
vec3 Binormal = gl_NormalMatrix * gl_MultiTexCoord2.xyz;
vec3 fvViewDirection = -Position;
vec3 fvLightDirection = vec3(gl_LightSource[0].position.xyz -Position);
ViewDirection.x = dot( Tangent, fvViewDirection );
ViewDirection.y = dot( Binormal,fvViewDirection );
ViewDirection.z = dot( Normal, fvViewDirection );
LightDirection.x = dot( Tangent, fvLightDirection );
LightDirection.y = dot( Binormal,fvLightDirection );
LightDirection.z = dot( Normal, fvLightDirection );
}
Code: Select all
// BUMP pixel shader
varying vec3 LightDirection;
varying vec3 ViewDirection;
uniform sampler2D colorMap;
uniform sampler2D bumpMap;
void main()
{
vec3 N = normalize( ( texture2D( bumpMap, gl_TexCoord[0]).xyz * 2.0 ) - 1.0 );
vec3 L = normalize(LightDirection);
vec3 E = normalize(ViewDirection);
vec3 R = reflect(-L, N);
vec4 Color = texture2D( colorMap, gl_TexCoord[0].st);
vec4 Ambient = Color * .1;
vec4 Diffuse = Color * max(dot(N,L),0.0);
vec4 Specular = Color * pow(max(dot(R,E),0.0),20.0);
gl_FragColor = Ambient + Diffuse + Specular;
}
Code: Select all
class MyShaderCallBack : public irr::video::IShaderConstantSetCallBack
{
public:
virtual void OnSetConstants(irr::video::IMaterialRendererServices* services, irr::s32 userData)
{
irr::s32 colorMap=0;
irr::s32 bumpMap=1;
services->setPixelShaderConstant("colorMap",reinterpret_cast<irr::f32*>(&colorMap), 1);
services->setPixelShaderConstant("bumpMap",reinterpret_cast<irr::f32*>(&bumpMap), 1);
}
};
Code: Select all
irr::s32 TexturedBump = Graphics:: gpu-> addHighLevelShaderMaterialFromFiles
("C:/Shaders/TexturedBump/VERT.vert", "main", irr::video::EVST_VS_2_0, "C:/Shaders/TexturedBump/FRAG.frag", "main", irr::video::EPST_PS_2_0, callback, irr::video::EMT_SOLID, 1 );
node->setMaterialType((irr::video::E_MATERIAL_TYPE)TexturedBump);