Archived

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

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

Recommended Posts

I''m trying to modify the position of a vertex, but when I try performing any operation to the vertex, I just get a blank screen. Here is the code that im using, this is supposed to just take the x component of every vertex and multiply it by two - just a simple piece of code that i''m trying to do just so that I can learn how to manipulate vertices. Without the muliplication bit, the code works perfectly - it displays a vertex transformed into projection space, with the multiplication bit, I get a blank screen. Am I going about this the right way, or is there a different method that actually works? I''m extremely new to shaders, so sorry if this is a stupid question, there is just very little info on how to actually use shaders on the web. Thanks a bunch.

vs.1.0

def c4, 2.0f, 1.0f, 1.0f, 1.0f
//move input vert to temp register

mov r0, v0

//multiply vert''s x location by 2(if I comment this out, the code works)

mul r0.x, r0.x, c4.x

//multiply vert by world/view/projection matrix

dp4 r1.x, r0, c[0]
dp4 r1.y, r0, c[1]
dp4 r1.z, r0, c[2]
dp4 r1.w, r0, c[3]

//set output vert

mov oPos, r1

//color dependant on verts location

mov oD0, v0


Share on other sites
All right I have been messing around with vertex shaders the past few days and here's the code I used to do what you want to do (double each vertex's x-coord)

  vs.1.0def c4, 2.0f, 1.0f, 1.0f, 1.0f;multiply all elements (x,y,z,w) by c4;since all other elements but x are 1.0f;nothing will happenmul r0, v0, c4; set the position outputdp4 oPos.x, r0.x, c0dp4 oPos.y, r0.y, c1dp4 oPos.z, r0.z, c2dp4 oPos.w, r0.w, c3

that should double the x-coord of each vertex (as I assume you wanted to)
Set any other properties after

-SnakeHunta

[edited by - SnakeHunta on January 30, 2003 10:22:38 PM]

[edited by - SnakeHunta on January 30, 2003 10:56:08 PM]

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631768
• Total Posts
3002244
×