Hi Guys
am learning GLSL at the moment, I am using irrlicht3D and am trying to compile a fur shader that was written for pixelshader1.3, however my card has ps2.0 so i am trying to convert it.
fur.vert (added as vs1.1)
uniform float fFurLength;
uniform float fUVScale;
uniform float fLayer; // 0 to 1 for the level
uniform vec3 vGravity;
uniform vec4 vLightDir;
//textures
uniform sampler2D FurTexture;
uniform sampler2D ColourTexture;
varying vec3 normal;
mat4 mWorldViewProj= gl_ModelViewProjectionMatrix;
mat4 mWorld = gl_ModelViewMatrix;
vec3 vNormal = gl_Normal;
vec4 vVertex = gl_Vertex;
void main()
{
vec3 P = vVertex.xyz + (vNormal * ((fFurLength)*10));
vNormal = normalize( vNormal * mat3(mWorld ));
// Additional Gravit/Force Code
vec3 vGravity2 = vGravity *mat3(mWorld );
//float pp = 3.14 * 0.5 * Layer; // depth paramete
//float A = dot(normal, vGravity); //A is the angle between surface normal and gravity vector
float k = pow(fLayer, 3.0); // We use the pow function, so that only the tips of the hairs bend
// As layer goes from 0 to 1, so by using pow(..) function is still
// goes form 0 to 1, but it increases faster! exponentially
P = P + vGravity2 * k;
// End Gravity Force Addit Code
gl_TexCoord[0] = gl_MultiTexCoord0 * fUVScale;
gl_TexCoord[1] = gl_MultiTexCoord0;
// UVScale?? Well we scale the fur texture alpha coords so this effects the fur thickness
// thinness, we don't change our T1 value as this is our actual texture!
//OUT.HPOS = P;
gl_Position = mWorldViewProj* vec4(P,1.0);
normal = vNormal;
}
fur.frag (added as ps2.0)
uniform float fFurLength;
uniform float fMaxLength;
uniform float fUVScale;
uniform float fForce;
uniform vec3 vGravity;
uniform vec4 vAmbient;
uniform float fLayer; // 0 to 1 for the level
uniform vec3 vLightDir;
//textures
uniform sampler2D FurTexture;
uniform sampler2D ColourTexture;
varying vec3 normal;
void main()
{
vec4 diffuseTexture = texture2D( FurTexture, vec2(gl_TexCoord[0]) ); // Fur Texture - alpha is VERY IMPORTANT!
vec4 ColourTexture = texture2D( ColourTexture, vec2(gl_TexCoord[1]) ); // Colour Texture for patterns
//return diffuseTexture; // Return just the fur colour (red in this demo)
//return (ColourTexture * (1,1,1,diffuseTexture.a));//Return texture colour looking like fur!
vec4 FinalColour = ColourTexture;
FinalColour.a = diffuseTexture;
//--------------------------
//Basic Directional Lighting
vec4 ambient = vAmbient * FinalColour;
vec4 diffuse = FinalColour;
//FinalColour = ambient + diffuse * (dot(vLightDir, normal) * 0.5);
FinalColour = ambient + diffuse;
//End Basic Lighting Code
//--------------------------
if(fFurLength==0)
{
FinalColour.a = 1;
}
else
{
FinalColour.a = diffuseTexture * ( (fMaxLength-fFurLength));
}
//return diffuseTexture; // fur colour only!
gl_FragColor = FinalColour; // Use texture colour
}
compile returns the following problems
OpenGL driver version is 1.2 or better.
GLSL version: 1.1
GLSL shader failed to compile
(26) : warning C7011: implicit cast from “float4” to “float”
(37) : warning C7011: implicit cast from “int” to “float”
(39) : warning C7011: implicit cast from “int” to “float”
(43) : warning C7011: implicit cast from “float4” to “float”
(20) : error C1102: incompatible type for parameter #1 (“s”)
(20) : error C1102: incompatible type for parameter #1 (“s”)
i have got rid of the warnings in the fragment shader by altering it to the following
fur.frag
uniform float fFurLength;
uniform float fMaxLength;
uniform float fUVScale;
uniform float fForce;
uniform vec3 vGravity;
uniform vec4 vAmbient;
uniform float fLayer; // 0 to 1 for the level
uniform vec3 vLightDir;
//textures
uniform sampler2D FurTexture;
uniform sampler2D ColourTexture;
varying vec3 normal;
void main()
{
vec4 diffuseTexture = texture2D( FurTexture, vec2(gl_TexCoord[0]) ); // Fur Texture - alpha is VERY IMPORTANT!
vec4 ColourTexture = texture2D( ColourTexture, vec2(gl_TexCoord[1]) ); // Colour Texture for patterns
//return diffuseTexture; // Return just the fur colour (red in this demo)
//return (ColourTexture * (1,1,1,diffuseTexture.a));//Return texture colour looking like fur!
vec4 FinalColour = ColourTexture;
FinalColour.a = diffuseTexture.a;
//--------------------------
//Basic Directional Lighting
vec4 ambient = vAmbient * FinalColour;
vec4 diffuse = FinalColour;
//FinalColour = ambient + diffuse * (dot(vLightDir, normal) * 0.5);
FinalColour = ambient + diffuse;
//End Basic Lighting Code
//--------------------------
if(fFurLength==float(0))
{
FinalColour.a = float(1);
}
else
{
FinalColour.a = diffuseTexture.a * ( (fMaxLength-fFurLength));
}
//return diffuseTexture; // fur colour only!
gl_FragColor = FinalColour; // Use texture colour
}
could anyone provide a hint as to how i get rid of the two errors remaining
(20) : error C1102: incompatible type for parameter #1 (“s”)
(20) : error C1102: incompatible type for parameter #1 (“s”)
thanks in advance
robbbbbbbbbbbbbbbb