Jump to content
  • Advertisement
Sign in to follow this  
greg2fs

Strange thing with Shaders: mul() make all black

This topic is 3269 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

Hello, I have a strange bug with vertex/pixel shaders. (I use 2.0) I already had some issues with my shaders (for parallax) when I saw my tangent and binormal was null, then I decided to use D3DXComputeTangentFrameEx with witch some options was not compatible with the old dxsdk I used, then I decided to update to the latest SDK. After some compiling problem (subject of another topic) and with correct normals, binormals and tangents, my shaders doesn't seems to work. First I have many warning, one is: warning x3206: 'mul': implicit truncation of vector type I removed everything in my shader to try to understand:
Quote:
//the vertex shader struct Vertex{ float4 pos: POSITION; float3 n: NORMAL; float2 uv: TEXCOORD0; float2 uvl: TEXCOORD1; float3 t: TANGENT; float3 b: BINORMAL; }; struct Connect{ float4 pos: POSITION; float2 uv: TEXCOORD0 ; float3 lightVec: TEXCOORD1; float3 eyeVec: TEXCOORD2; }; Connect main(Vertex vertex, uniform row_major float4x4 wvpMatrix: register(C0), uniform row_major float4x4 worldMatrix: register(C4), uniform float3 lightPos: register(C8), uniform float3 eyePos: register(C9)){ Connect result; result.pos = mul(vertex.pos, wvpMatrix); result.uv = vertex.uv; float4 worldPos = mul(vertex.pos, worldMatrix); float3 n = mul(vertex.n, worldMatrix); result.lightVec = float3(1,0,0); result.eyeVec = float3(1,1,0); return result; } //the pixel shader struct Fragment{ float4 color: COLOR; }; Fragment main(Connect data, uniform sampler2D diffuseMap: register(S0), uniform sampler2D normalMap: register(S1), uniform float specularPower: register(C0), uniform float parallaxDepth: register(C1), uniform float2 texelSize: register(C2)){ Fragment result; result.color = float4(data.eyeVec.x,data.eyeVec.y,data.eyeVec.z, 1.0); return result; }
Then the very strange thing is than when I remove the line "float3 n = mul(vertex.n, worldMatrix);" the render color is yelow but is I let this line it become black ! If someone has any idea of the problem, thanks to explain to me. Thanks again.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by greg2fs
I corrected all the warning and it works, why it worked before and I had no warning ?


They probably added that warning in one of the many revisions they've made to the shader compiler.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!