float4x4 worldMatrix;float4x4 worldViewProjection;texture sceneTexture;sampler g_samScene =sampler_state { Texture = <sceneTexture>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; };
void VertScene( float4 Pos : POSITION, float2 Tex : TEXCOORD0, out float4 oPos : POSITION, out float2 oTex : TEXCOORD0 ){ oPos = mul( Pos, worldViewProjection );oTex = Tex; }
float4 PixScene( float2 Tex : TEXCOORD0 ) : COLOR0{ return tex2D( g_samScene, Tex );} technique RenderSceneNoPixelShader{ pass P0{ VertexShader = compile vs_1_1 VertScene();PixelShader = NULL; MaterialAmbient = {1.0, 1.0, 1.0, 1.0}; MaterialDiffuse = {1.0, 1.0, 1.0, 1.0}; MaterialSpecular = {1.0, 1.0, 1.0, 1.0}; MaterialPower = 40.0f; Texture[0] = <sceneTexture>; ColorOp[0] = Modulate; ColorArg1[0] = Texture; ColorArg2[0] = Diffuse; AlphaOp[0] = Modulate; AlphaArg1[0] = Texture; AlphaArg2[0] = Diffuse; MinFilter[0] = Linear; MagFilter[0] = Linear; MipFilter[0] = Linear; ColorOp[1] = Disable; AlphaOp[1] = Disable; } } |
any Ideas why this could be happening
thanks a ton

mesh texture color
icelock
nhlpens66
ZeyadRajabi
thanks
Jon Asbury
So, you're using a greyscale texture and then getting the vertex diffuse colour to modify it
An example being that if you have a red team and a blue team in your game, they both use the same greyscale texture but you change the mesh colour so that they appear shades of red or blue (respectively)
If I'm right about that, you'd need to introduce a value for COLOR into your vertex shader that can then be used by your pixel shader to modulate the results of the tex2D()...
I'm still fairly new to effect files myself, so I don't know if you can do that with the fixed function params you seemed to be setting... but it should be possible if you specify either a COLOR property for the input/output semantics of the vertex shader (and add the relevent data into your mesh) or just pass in the colour as a constant to the vertex shader (and switch it around as appropriate when rendering from your application)...
hth
Jack
Charlemagne
When you say "from the .x file" do you mean from the vertex stream or as a material value associated with a particular mesh subset
bataras
You don't say what you expect, but I took your effect, added Sas bindings and viewed it in DxViewer and saw a texture. There is a bit of odd stuff in your effect file that might be causing you problems. For example, you set up Material* effect states but you are using a vertex shader so all of the material and diffuse values will be the result of your vertex shader. This means that using ColorOp=Modulate and ColorArg2[0]=Diffuse isn't all that meaningful unless you output a vertex color from your vertex shader. As it is, the color will be white, modulated against the texture, resulting in the texture (which is what I see). The net result is actually exactly what your PixScene pixel shader does, sample the texture and output that as the pixel color.
For the record, here is the effect I used which is equivelant to your original effect:
int GlobalParameter : SasGlobal
<
int3 SasVersion = {1, 1, 0};
bool SasUiVisible = false;
>;
float4x4 worldMatrix <string SasBindAddress = "Sas.Skeleton.MeshToJointToWorld[0]"; >;
float4x4 View <string SasBindAddress = "Sas.Camera.WorldToView"; >;
float4x4 Projection <string SasBindAddress = "Sas.Camera.Projection"; >;
float4x4 worldViewProjection;
texture sceneTexture <string SasResourceAddress = "tiger.bmp"; >;
void VertScene( float4 Pos : POSITION, float2 Tex : TEXCOORD0, out float4 oPos : POSITION, out float2 oTex : TEXCOORD0 )
{
float4x4 worldViewProjection = mul(worldMatrix, mul(View, Projection));
oPos = mul( Pos, worldViewProjection );
oTex = Tex;
}
technique RenderSceneNoPixelShader
{
pass P0
{
VertexShader = compile vs_1_1 VertScene();
PixelShader = NULL;
Texture[0] = <sceneTexture>;
ColorOp[0] = SelectArg1;
ColorArg1[0] = Texture;
AlphaOp[0] = SelectArg1;
AlphaArg1[0] = Texture;
ColorOp[1] = Disable;
AlphaOp[1] = Disable;
}
}