Archived

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

CoolTomK

Vertex Shader Troubles

Recommended Posts

CoolTomK    122
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 this post


Link to post
Share on other sites
SnakeHunta    148
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.0
def 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 happen
mul r0, v0, c4
; set the position output
dp4 oPos.x, r0.x, c0
dp4 oPos.y, r0.y, c1
dp4 oPos.z, r0.z, c2
dp4 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]

Share this post


Link to post
Share on other sites