Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jimfing

DOT3 bump mapping vertex shader

This topic is 5214 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, i''m trying to write a vertex shader to take the light vector of a direction light, transform it into texture space, then put the resulting vector into the diffuse component of each vertex so the texture blender can do it''s magic with the DOT3 colour operation. My problem i think is the vertex shader (i''m a shader n00b), and I can''t for the life of me get it to work. Probably something really obvious but here goes:
vs.1.1

dcl_position v0 
dcl_normal v3 
dcl_texcoord0 v5 
dcl_texcoord1 v6 
dcl_tangent   v7
dcl_binormal  v8

// Transform position by world*view*projection

m4x4 oPos, v0, c0

// Copy base texture coords

mov oT0, v5
mov oT1, v5

// transform texture space vectors into world space

m3x3 r0, v3, c4
m3x3 r1, v7, c4
m3x3 r2, v8, c4

// transform light vector into texture space

// putting the resulting vector into the diffuse colour component

dp3 oD0.x, r0, c9
dp3 oD0.y, r1, c9
dp3 oD0.z, r2, c9
c0-c3 is the world*view*projection c4-c7 is the world matrix c9 is the light vector Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
Just do:


vs.1.1

dcl_position v0
dcl_normal v3
dcl_texcoord0 v5
dcl_texcoord1 v6
dcl_tangent v7
dcl_binormal v8

// Transform position by world*view*projection

m4x4 oPos, v0, c0

// Copy base texture coords

mov oT0, v5
mov oT1, v5

// transform light vector into texture space

// putting the resulting vector into the diffuse colour component

dp3 oD0.x, v7, c9
dp3 oD0.y, v8, c9
dp3 oD0.z, v3, c9


Whatch out because putting things in the color clamps it to [0,1]

Share this post


Link to post
Share on other sites

  • 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!