Jump to content
  • Advertisement
Sign in to follow this  
lythm

Shader problem, so weird...

This topic is 3808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys: My vertex shader did not pass the texcoord to my pixel shader correctly, all the texcoord passed to pixel shader become 1.0 . I've change the shader to a very simple version. I just transform the vertex pos and pass on the texcoord to the pixelshader in vs. And sample a texture with the texcoord in pixel shader. The problem still exists. I'm sure there is no problem with the stream data and the stream decl, because the scene can be rendered correctly through fixed pipeline.And the shader is no problem,too. Because when I turned on vs or ps seperately(ie, vs on ps off or vs off ps on), the result is correct. So it seems each shader is ok, but they just dont work well together.This is so weird. Any idea or information about that is appreciated. btw : Because I'm currently working on an old system, so I wonder if there is any renderstate that can affect.

Share this post


Link to post
Share on other sites
Advertisement
Run your code with the debug runtimes enabled, there are more restrictions to trip up with when dealing with shaders. Errors with your inter-stage linkage tend to result in the debug runtimes screaming and shouting at you with quite detailed information on what elements don't work/match.

As Gage64 says, we need to see your shader code - especially your input/output declarations, for all of the IA, VS and PS stages.

hth
Jack

Share this post


Link to post
Share on other sites
Hi:

Here is my shader code:


struct VS_INPUT
{
float3 pos : POSITION;
float2 tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 pos : POSITION;
float2 tex0 : TEXCOORD0;
};

VS_OUTPUT vsMain(VS_INPUT vsIn)
{
VS_OUTPUT vsOut = (VS_OUTPUT)0;

float3 posWorld = mul(float4(vsIn.pos, 1), worldMat);
float4 posView = mul(float4(posWorld, 1), viewMat);
vsOut.pos = mul(float4(posView, 1), projMat);
vsOut.tex0 = vsIn.tex0;
return vsOut;
}

float4 psMain(VS_OUTPUT psIn):COLOR0
{
float4 clr = tex2D(diffuseSampler, psIn.tex0);
return clr;
}

technique T0
{
pass P0
{
VertexShader = compile vs_2_0 vsMain();
PixelShader = compile ps_2_0 psMain();
}
}



jollyjeffers :
I've already turned on dx debug mode. And there is only those "ignoring redundant setrenderstate" warnings.

I've spent a week on this werid bug, it is driving me crazy.

Share this post


Link to post
Share on other sites
I've made a simpler scene, and it is rendered correctly!!!
This is so werid. I am trying to figure out what is different between the two scenes.

Both of them can be rendered correctly through fixed pipeline. So the data should not cause any problem, right?
I am so confused.

Share this post


Link to post
Share on other sites
Does it ALWAYS work in fixed function, and NEVER work with shaders? If so, the first thing that jumps out at me is your Vertex Declaration code; make sure you have the semantic/offset/vertex striding information correct.

Share this post


Link to post
Share on other sites
Maybe just the texture addressing mode set to CLAMP? I don't know what default settings a sample is set to when declaring it inside an effect file. Oh, btw, you don't define any sampler in that sample code. I wonder why it even compiles.

Share this post


Link to post
Share on other sites
Quote:
Original post by emeyex
Does it ALWAYS work in fixed function, and NEVER work with shaders? If so, the first thing that jumps out at me is your Vertex Declaration code; make sure you have the semantic/offset/vertex striding information correct.
I concur with this. Your HLSL/FX fragment looks reasonable enough so the problem is likely to be your pipeline configuration.

How are the constants configured? The vertex declaration (you're not using FVF's are you??) and so on...

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!