texture lookups problem

Posted By: zefor

texture lookups problem - 01/20/06 14:20

what does this mean when converting shaders?

vs1_1 target does not support texture lookups

And is there a work around for it?
Posted By: ello

Re: texture lookups problem - 01/20/06 14:25

you mean ps1_1?? well using ps1_4 is a workaround;)
Posted By: zefor

Re: texture lookups problem - 01/20/06 14:48

This is what I have at the bottom, ps is 2.0

VertexShader = compile vs_1_1 main();
PixelShader = compile ps_2_0 main();

it doesnt like the vertexshader compile line for some reason
Posted By: ello

Re: texture lookups problem - 01/20/06 14:49

well, then dont try a texture lookup in the vertexshader. i think this requires shadermodel3.0
Posted By: zefor

Re: texture lookups problem - 01/20/06 15:22

Would the texture lookup be in the lines that say
Code:

Out.texCoord.x = Pos.x * 0.0065 + 0.46;
Out.texCoord.y = Pos.z * 0.0065 + 0.46;



In this code

Code:

//float4x4 matWorldViewProj;
//float4x4 matWorld;

float4x4 view_proj_matrix: register(c0);
float4x4 view_matrix: register(c4);

texture entSkin1;
texture entSkin2;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


sampler BumpMapSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};

struct VS_OUTPUT {
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 lightVec: TEXCOORD1;
};

VS_OUTPUT main(float4 Pos: POSITION, float3 normal: NORMAL, float3 tangent: TANGENT, float3 binormal: BINORMAL) {
VS_OUTPUT Out;

Out.Pos = mul(view_proj_matrix, Pos);
//Out.Pos = mul(matWorldViewProj, Pos);

// Some object-linear texgen, specific for this particular model
Out.texCoord.x = Pos.x * 0.0065 + 0.46;
Out.texCoord.y = Pos.z * 0.0065 + 0.46;

float3 Pview = -mul(view_matrix, Pos);
//float3 Pview = -mul(matworld, Pos);

// Move our tangent-space into eye-space
float3 vtang = mul(view_matrix, tangent);
float3 vbinorm = mul(view_matrix, binormal);
float3 vnorm = mul(view_matrix, normal);


// We use lightVec = viewVec, that is, the camera is also the light.
float3 lightVec = Pview;

// Transform light vector from eye-space to tangent-soace
Out.lightVec.x = dot(lightVec, vtang);
Out.lightVec.y = dot(lightVec, vbinorm);
Out.lightVec.z = dot(lightVec, vnorm);

return Out;
}

/////////////////////Pixel Shader
float4 Gold: register(c0);
sampler BaseMap: register(s0);
sampler BumpMap: register(s1);
float4 main(float2 texCoord: TEXCOORD0, float3 lightVec: TEXCOORD1) : COLOR {
float4 base = tex2D(BaseMap, texCoord);
float3 bump = tex2D(BumpMap, texCoord) * 2.0 - 1.0;

// shine = diffuse and specular
float shine = saturate(dot(normalize(lightVec), normalize(bump)));
return (shine * 0.2) * base + pow(shine, 64) * Gold;
}

technique Gold_shine
{
pass p0
{
VertexShader = compile vs_1_1 main();
PixelShader = compile ps_2_0 main();
}
}





Sorry, I am very, Very much a NOOB trying to learn.
Posted By: ello

Re: texture lookups problem - 01/20/06 15:36

try:

/////////////////////Pixel Shader
float4 Gold: register(c0);
//sampler BaseMap: register(s0);
//sampler BumpMap: register(s1);
float4 main(float2 texCoord: TEXCOORD0, float3 lightVec: TEXCOORD1) : COLOR {
float4 base = tex2D(ColorMapSampler , texCoord);
float3 bump = tex2D(BumpMapSampler , texCoord) * 2.0 - 1.0;

// shine = diffuse and specular
float shine = saturate(dot(normalize(lightVec), normalize(bump)));
return (shine * 0.2) * base + pow(shine, 64) * Gold;
}


maybe thats the cause for your error. well i am at work and cant check nothing;)
Posted By: zefor

Re: texture lookups problem - 01/20/06 19:18

Unfortunately, still get the texture lookup error, but thanks for trying.
Posted By: Matt_Aufderheide

Re: texture lookups problem - 01/21/06 04:31

Haha, after stareing at forever I figured out what your problem is...

VertexShader = compile vs_1_1 main();
PixelShader = compile ps_2_0 main();

notice that both your shaders have the same name "main" ..you have to change the names of them to differetn thing like vs_main and ps_main ... you must change them in the technique and also at the actual function decalration like here:
VS_OUTPUT vs_main

this is should solve your problems with compiling.. although i dont think this shader will work right.. you need to change some other things i think..

First, you should go back to the correct matrix names instead of these others.. you need matView, matWorldViewProj etc...
also, i really think A6 doesnt pass in a correct binormal under the BINORMAL coord.. i dont know why, but it doesnt seem to.. in that case you must generate the binormal using a crossproduct.. like cross(tangent,normal)

let me how it works out..
Posted By: zefor

Re: texture lookups problem - 01/21/06 12:44

Thank you mat, and I am glad you didnt post the proper "fixed" code for me as I am trying to learn shaders, like how you said you did. I had already changed the matworlviewproj and such, but I did not know I could not have a double "main" technique. I learned something new I also was staring at that BINORMAL and pondering because I had not seen it in other shaders but I didnt know what to do with it. I will let you know how it goes and ask help if I really need it. I'll post the finished product when I am done. This is the "gold shine" shader from rendermonkey, but without the gold. If somebody has already posted this code, please dont tell me
Many Thanks
Posted By: zefor

Re: texture lookups problem - 01/21/06 13:47

the models dissapear and appear right in front of the camera blocking most of your visibility when you point it where the models should be. They are black, but I guess thats because I have not added light yet??? anyway, the lighting effect on the black models looks cool unless it is just a fluke. I will keep banging away at it. feel free to give a pointer, I'm frustrated already

Here is what I have so far:
Code:
 
float4x4 matWorldViewProj: register(c0);
float4x4 matView: register(c4);



texture entSkin1;
texture entSkin2;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


sampler BumpMapSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};

struct VS_OUTPUT {
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 lightvec: TEXCOORD1;
};

//VS_OUTPUT VS1(float4 Pos: POSITION, float3 normal: NORMAL, float3 tangent: TANGENT, float3 binormal: BINORMAL) {
VS_OUTPUT VS1(float4 Pos: POSITION, float3 normal: NORMAL, float3 tangent: TANGENT) {
VS_OUTPUT Out;

//Out.Pos = mul(view_proj_matrix, Pos);
Out.Pos = mul(matWorldViewProj, Pos);



// Some object-linear texgen, specific for this particular model
Out.texCoord.x = Pos.x * 0.0065 + 0.46;
Out.texCoord.y = Pos.z * 0.0065 + 0.46;



//float3 Pview = -mul(view_matrix, Pos);
float3 Pview = -mul(matView, Pos);

// Move our tangent-space into eye-space

float3 vtang = mul(matView, tangent);
float3 vbinorm = mul(matView, cross(tangent, normal));
float3 vnorm = mul(matView, normal);


// We use lightVec = viewVec, that is, the camera is also the light.
float3 lightvec = Pview;

// Transform light vector from eye-space to tangent-soace
Out.lightvec.x = dot(lightvec, vtang);
Out.lightvec.y = dot(lightvec, vbinorm);
Out.lightvec.z = dot(lightvec, vnorm);

return Out;
}

/////////////////////Pixel Shader


float4 Gold: register(c0);
sampler ColorMap: register(s0);
sampler BumpMap: register(s1);

float4 PS1(float2 texCoord: TEXCOORD0, float3 lightvec: TEXCOORD1) : COLOR {
float4 base = tex2D(ColorMapSampler, texCoord);
float3 bump = tex2D(BumpMapSampler, texCoord) * 2.0 - 1.0;

// shine = diffuse and specular
float shine = saturate(dot(normalize(lightvec), normalize(bump)));
return (shine * 0.2) * base + pow(shine, 64) * Gold;
}


technique Gold_shine
{
pass p0
{
VertexShader = compile vs_1_1 VS1();
PixelShader = compile ps_2_0 PS1();
}
}





I think the lines below this comment are whats messing it up as far as the camera.
// Move our tangent-space into eye-space
Posted By: zefor

Re: texture lookups problem - 01/21/06 16:08

Tried to add sunlight, dynamic lights, and fog from wiki. Engine does not like this line " vecSkill41 " and I do not know what to do about it. I commented the line with ///Doesnt like this line?? Here is what I have now.

Code:
 
float4x4 matWorldViewProj: register(c0);
float4x4 matView: register(c4);
float4x4 matWorld;
///////////////////////////////////
float4 vecSunDir;
float4 vecSunDiffuse = float4(200.f/255.f, 200.f/255.f, 200.f/255.f, 1.f);
float4 vecLightPos[8];
float4 vecLightColor[8];
float3 vecFalloff = float3(0.f, 0.f, 2.f);
float4 vecFog;
///////////////////////////////////
texture entSkin1;
texture entSkin2;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


sampler BumpMapSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


/////////////////////////
float4 DoPointLight(float3 P, float3 N, int i)
{
// calculate the light ray pointing from the light to the surface
float3 D = (float3)vecLightPos[i]-P;
// calculate the angle between surface and light ray
float NdotL = dot(N,normalize(D));
// modulate the light by the surface angle
float4 Color = vecLightColor[i] * NdotL;

// calculate the light attenuation factor, DX uses a really strange formula here
float fac = 0.f;
if (NdotL >= 0.f && vecLightPos[i].w > 0.f)
{
// get the distance factor
float LD = length(D)/vecLightPos[i].w;
#ifdef DXLIGHTING
if (LD < 1.3f)
fac = 1.f/(vecFalloff.x + vecFalloff.y*LD + vecFalloff.z*LD*LD);
#else // linear Lighting
if (LD < 1.f)
fac = 1.f - LD;
#endif
}
return Color * fac;
}

float4 DoSunLight(float3 N)
{
// modulate the sunlight by the surface angle
return vecSunDiffuse * dot(N,-vecSunDir);
}
float DoFog(float3 Pos)
{
// convert the vector position to view space to get it's depth (.z)
float3 P = mul(Pos,matWorldViewProj);
// apply the linear fog formula
return saturate((vecFog.y-P.z) * vecFog.z);
}
///////////////////////////////////


struct VS_OUTPUT {
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 lightvec: TEXCOORD1;

float4 Color: COLOR0;
float Fog: FOG;

};



//VS_OUTPUT VS1(float4 Pos: POSITION, float3 normal: NORMAL, float3 tangent: TANGENT, float3 binormal: BINORMAL) {
VS_OUTPUT VS1(float4 inPos: POSITION, float3 inNormal: NORMAL, float3 tangent: TANGENT) {
VS_OUTPUT Out;

//Out.Pos = mul(view_proj_matrix, Pos);
Out.Pos = mul(inPos, matWorldViewProj);

// transform the normal and the position
float3 N = normalize(mul(inNormal,matWorld));
float3 P = mul(inPos,matWorld);
// Add ambient and sun light
Out.Color = vecSkill41.w + DoSunLight(N); //////////////Doesnt like this line???
// Add 6 dynamic lights (maximum for vs 1.1)
for (int i=0; i<6; i++)
Out.Color += DoPointLight(P,N,i);
// Add fog
Out.Fog = DoFog(inPos);

// convert texture coordinates or do other stuff

// Some object-linear texgen, specific for this particular model
Out.texCoord.x = Pos.x * 0.0065 + 0.46;
Out.texCoord.y = Pos.z * 0.0065 + 0.46;



//float3 Pview = -mul(view_matrix, Pos);
float3 Pview = -mul(matView, Pos);

// Move our tangent-space into eye-space

float3 vtang = mul(matView, tangent);
float3 vbinorm = mul(matView, cross(tangent, normal));
float3 vnorm = mul(matView, normal);


// We use lightVec = viewVec, that is, the camera is also the light.
float3 lightvec = Pview;

// Transform light vector from eye-space to tangent-soace
Out.lightvec.x = dot(lightvec, vtang);
Out.lightvec.y = dot(lightvec, vbinorm);
Out.lightvec.z = dot(lightvec, vnorm);

return Out;
}

/////////////////////Pixel Shader


float4 Gold: register(c0);
sampler ColorMap: register(s0);
sampler BumpMap: register(s1);

float4 PS1(float2 texCoord: TEXCOORD0, float3 lightvec: TEXCOORD1) : COLOR {
float4 base = tex2D(ColorMapSampler, texCoord);
float3 bump = tex2D(BumpMapSampler, texCoord) * 2.0 - 1.0;


// shine = diffuse and specular
float shine = saturate(dot(normalize(lightvec), normalize(bump)));
return (shine * 0.2) * base + pow(shine, 64) * Gold;


}


technique Gold_shine
{
pass p0
{
VertexShader = compile vs_1_1 VS1();
PixelShader = compile ps_2_0 PS1();
}
}


Posted By: Matt_Aufderheide

Re: texture lookups problem - 01/22/06 02:48

at the top of your shader you must simply declare it like this:
float4 vecSkill41;
Posted By: zefor

Re: texture lookups problem - 01/23/06 13:04

Compiled shader code uses too many instruction slots (133). Max allowed by the target (vs_1_1) is 128

What does that mean?????
Posted By: ello

Re: texture lookups problem - 01/23/06 13:11

use vs_2_0, because you use ps_2_0 that shouldnt be a problem:)
Posted By: zefor

Re: texture lookups problem - 01/23/06 16:24

Thank you mat and ello! My models are no longer stuck to the camera view. Now I just have to figure out why they are black Shine effect looks good though, even on the black models.
Posted By: ello

Re: texture lookups problem - 01/24/06 07:32

from what i see you dont pass the uv-texture coordinates of the model to the pixelshader :
Code:

VS_OUTPUT VS1(float4 inPos: POSITION, float3 inNormal: NORMAL, float3 tangent: TANGENT, float2 texCoord : TEXCOORD0) {

...

Out.texCoord = texCoord;
...


Posted By: zefor

Re: texture lookups problem - 01/24/06 13:36

Still a no-go. Here is the code with all of the corrections. Do I have the lighting code that I got from the wiki placed in the proper area? I am racking my brain, but i just dont seem to be getting anywhere.

Code:
 
float4x4 matWorldViewProj: register(c0);
float4x4 matView: register(c4);
float4x4 matWorld;

float4 vecSkill41;
float4 vecSunDir;
float4 vecSunDiffuse = float4(200.f/255.f, 200.f/255.f, 200.f/255.f, 1.f);
float4 vecLightPos[8];
float4 vecLightColor[8];
float3 vecFalloff = float3(0.f, 0.f, 2.f);
float4 vecFog;

texture entSkin1;
texture entSkin2;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


sampler BumpMapSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


/////////////////////////LIGHTING FROM WIKI//////////////


float4 DoPointLight(float3 P, float3 N, int i)
{
// calculate the light ray pointing from the light to the surface
float3 D = (float3)vecLightPos[i]-P;
// calculate the angle between surface and light ray
float NdotL = dot(N,normalize(D));
// modulate the light by the surface angle
float4 Color = vecLightColor[i] * NdotL;

// calculate the light attenuation factor, DX uses a really strange formula here
float fac = 0.f;
if (NdotL >= 0.f && vecLightPos[i].w > 0.f)
{
// get the distance factor
float LD = length(D)/vecLightPos[i].w;
#ifdef DXLIGHTING
if (LD < 1.3f)
fac = 1.f/(vecFalloff.x + vecFalloff.y*LD + vecFalloff.z*LD*LD);
#else // linear Lighting
if (LD < 1.f)
fac = 1.f - LD;
#endif
}
return Color * fac;
}

float4 DoSunLight(float3 N)
{
// modulate the sunlight by the surface angle
return vecSunDiffuse * dot(N,-vecSunDir);
}
float DoFog(float3 Pos)
{
// convert the vector position to view space to get it's depth (.z)
float3 P = mul(Pos,matWorldViewProj);
// apply the linear fog formula
return saturate((vecFog.y-P.z) * vecFog.z);
}
///////////////////////////////////


struct VS_OUTPUT {
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
float3 lightvec: TEXCOORD1;

float4 Color: COLOR0;
float Fog: FOG;

};


VS_OUTPUT VS1(float4 inPos: POSITION, float3 normal: normal, float3 tangent: TANGENT, float2 texCoord : TEXCOORD0) {
VS_OUTPUT Out;

//Out.Pos = mul(view_proj_matrix, Pos);
Out.Pos = mul(inPos, matWorldViewProj);

// transform the normal and the position
float3 N = normalize(mul(normal,matWorld));
float3 P = mul(inPos,matWorld);
// Add ambient and sun light
Out.Color = vecSkill41.w + DoSunLight(N);
// Add 6 dynamic lights (maximum for vs 1.1)
for (int i=0; i<6; i++)
Out.Color += DoPointLight(P,N,i);
// Add fog
Out.Fog = DoFog(inPos);

// convert texture coordinates or do other stuff

// Some object-linear texgen, specific for this particular model
Out.texCoord.x = inPos.x * 0.0065 + 0.46;
Out.texCoord.y = inPos.z * 0.0065 + 0.46;
Out.texCoord = texCoord;



float3 Pview = -mul(matView, inPos);

// Move our tangent-space into eye-space

float3 vtang = mul(matView, tangent);
float3 vbinorm = mul(matView, cross(tangent, normal));
float3 vnorm = mul(matView, normal);


// We use lightVec = viewVec, that is, the camera is also the light.
float3 lightvec = Pview;

// Transform light vector from eye-space to tangent-soace
Out.lightvec.x = dot(lightvec, vtang);
Out.lightvec.y = dot(lightvec, vbinorm);
Out.lightvec.z = dot(lightvec, vnorm);

return Out;
}

/////////////////////Pixel Shader


float4 Gold: register(c0);
sampler ColorMap: register(s0);
sampler BumpMap: register(s1);

float4 PS1(float2 texCoord: TEXCOORD0, float3 lightvec: TEXCOORD1) : COLOR {
float4 base = tex2D(ColorMapSampler, texCoord);
float3 bump = tex2D(BumpMapSampler, texCoord) * 2.0 - 1.0;


// shine = diffuse and specular
float shine = saturate(dot(normalize(lightvec), normalize(bump)));
return (shine * 0.2) * base + pow(shine, 64) * Gold;

}


technique Gold_shine
{
pass p0
{
VertexShader = compile vs_2_0 VS1();
PixelShader = compile ps_2_0 PS1();
}
}


Posted By: Matt_Aufderheide

Re: texture lookups problem - 01/24/06 18:33

Well, first of all you dont apply the lighitng in the pixel shader.. you cant just calculate the color in the vertex shader and expect it to do anything if you havea pixel shader. You must multiply the pixel shader result by the lighitng. To do this you have to modify your pixel shader inputs to include the color0 data. Then you multiply the result by it.

However, this is only going to add vertex lighting, and doesnt have anything to do with why the gold shine effect doesnt work. The model ought not to be black in any case. The reason it is black is that you multiply the final result in the pixel shader by a constant called "Gold", when in fact you don't actually define this constant's value anywhere, so of course it has a default value of zero. And you know that you multiply anything by zero you get .. zero. Which is black.

delete this line: float4 Gold: register(c0);
and replace it with something like this:
float4 Gold = float4(220.f/255.f, 200.f/255.f, 0.f/255.f, 1.f); //this is a rgb color for you... change it to suit
Posted By: zefor

Re: texture lookups problem - 01/26/06 13:55

I gave up on the wiki code and tried the sun/fog code from a code you (mat) posted earlier. I can now see models and they react with fog, but no shine effect. I believe the problem is in the "return" line, but nothing I try works. Can anyone spot my mistake?
Code:
 
float4x4 matWorldViewProj;
float4x4 matView;
float4x4 matWorld;

float4 vecSkill41;

float4 vecViewPos;
float4 vecFog;
float4 vecSkill1;
float4 ambientcolor={0.3,0.3,0.3,0.0}; //can also use vecLight here for true ambient color
float4 suncolor={0.8,0.8,0.7,0.0}; //define the suncolor here, could also pass it from the script in a mtl skill


texture entSkin1;
texture entSkin2;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};


sampler BumpMapSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = wrap;
AddressV = wrap;
};





struct VS_OUTPUT {
float4 Pos: POSITION;
float2 texCoord: TEXCOORD0;
// float3 Sun: TEXCOORD1;

float3 View4 : TEXCOORD3;

float3 Sun : TEXCOORD1;
float Fog : FOG;

};


VS_OUTPUT VS1(float4 inPos: POSITION, float3 normal: normal, float3 tangent: TANGENT, float2 texCoord : TEXCOORD0) {
VS_OUTPUT Out;


Out.Pos = mul(inPos, matWorldViewProj);

////////////////////

// Some object-linear texgen, specific for this particular model
Out.texCoord.x = inPos.x * 0.0065 + 0.46;
Out.texCoord.y = inPos.z * 0.0065 + 0.46;
Out.texCoord = texCoord;

//
float3 PosWorld = mul(inPos, matWorld);
float ofog = 1 - (distance(PosWorld, vecViewPos) - vecFog.x) * (vecFog.z);
Out.Fog = ofog;
// Out.Fog = 10000;

float3 Pview = -mul(matView, inPos);

// Move our tangent-space into eye-space

float3 vtang = mul(matView, tangent);
float3 vbinorm = mul(matView, cross(tangent, normal));
float3 vnorm = mul(matView, normal);


// We use lightVec = viewVec, that is, the camera is also the light.
float3 Sun = Pview;

// Transform light vector from eye-space to tangent-soace
Out.Sun.x = dot(Sun, vtang);
Out.Sun.y = dot(Sun, vbinorm);
Out.Sun.z = dot(Sun, vnorm);

//
float3 Viewer4 = PosWorld - vecViewPos;
Out.View4 = mul(Pview, -Viewer4); // V

//sunlight
Out.Sun.xyz = mul(Pview, vecSkill1); // L
//

return Out;
}



/////////////////////Pixel Shader

float4 Gold = float4(0.3,0.3,0.3,0.0);
//float4 Gold: register(c1);

sampler ColorMap: register(s0);
sampler BumpMap: register(s1);

float4 PS1(float2 texCoord: TEXCOORD0, float3 Sun: TEXCOORD1, float3 View4: TEXCOORD3, float Fog: FOG) : COLOR {
float4 color = tex2D(ColorMapSampler, texCoord);
float3 bump = tex2D(BumpMapSampler, texCoord) * 2.0 - 1.0;

//bump=normalize(bump);

float3 ViewDir4 = normalize(View4);
//sunlight
float3 ViewSun = normalize(Sun);
float4 diff7 = saturate(dot(bump, ViewSun)); // diffuse component
float3 Reflect7 = normalize(2 * diff7 * bump - Sun); // R
float4 spec7 = pow(saturate(dot(Reflect7, ViewDir4)), 64);
float shadow7 = saturate(4 * diff7);


// shine = diffuse and specular
// float shine = saturate(dot(normalize(Sun), normalize(bump)));
// return (shine * 0.2) * color + pow(shine, 64) * Gold;

return
(
(ambientcolor * 2.0) * color + ((shadow7* (color * diff7 + (spec7*color.w))) * Gold)
);


/*
return
(
(ambientcolor * color) + //ambient ambientcolor = Sun

((shadow7* (color * diff7 + (spec7*color.w))) * suncolor)
);
*/

}


technique Gold_shine
{
pass p0
{

VertexShader = compile vs_2_0 VS1();
PixelShader = compile ps_2_0 PS1();
}
}


Posted By: Matt_Aufderheide

Re: texture lookups problem - 01/27/06 01:14

Well, the first thing would say is to make sure your texture has an alpha channel, becasue this shader is multiplying the specular value with the alpha to darken it. This would be called a specular map..

just make the areas in the alpha channel where you want specular highlights to be whiter and dark areas to be dull.
Posted By: zefor

Re: texture lookups problem - 01/27/06 15:23

yes it has alpha channel. Skin 1 is colormap with alpha, and skin 2 is normal map.
© 2024 lite-C Forums