Archived

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

pixel shader pixel position

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

Guest Anonymous Poster
AFAIK you can''t directly. In your vertex shader, you can calculate screen space positions and put them in some texture coordinate, which you can then access from the pixel shader. I think this is easiest.

Share this post


Link to post
Share on other sites
this is the per pixel spotlight vertex shader (which will be followed with a pixel shader)
it''s for version 1.1 to 1.4 think also 2.0 with maybe small modifications

vs.1.1

;Do the final transformation and emit it in oPos.
dp4 oPos.x, v0, c0
dp4 oPos.y, v0, c1
dp4 oPos.z, v0, c2
dp4 oPos.w, v0, c3

;Get the distance from the light to the vertex.
sub r0, v0, c8

;Divide each component by the range value
mul r0, r0, c9.x

;Divide by 2 and add 0.5
mad r0, r0, c9.yyyy, c9.yyyy

;Map the x and y components into the first texture
mov oT0.xy, r0.xy

;Map the z component into the second texture
mov oT1.x, r0.z

;Move the diffuse color out
mov oD0, v5

pixelshader also supported by more version..:

ps.1.1

;This is the light texture
tex t0

;This is the same texture, but this shader only uses the
;alpha channel
tex t1

mul r0, t0, t1.a
mul r0, r0, v0


good luck?



Share this post


Link to post
Share on other sites
if don''t know if it helps, but if you have Nvidia''s efffects browser I need sometg. like in the ''Pencil Sketch'' demo. But much more accurate. It looks a little stupid if the shadowmap moved even with one pixel.

Share this post


Link to post
Share on other sites
quote:
Original post by prgrmmr
Poster: this works great until the vertex keeps inside the view frustrum. But when one of the triangle vertices leaves the viewing rectangle, it doesn''t work.

Any other ideas?


This should not be a problem as long as you set those vertices to a point outside the viewport (i.e. negative coordinates).

Share this post


Link to post
Share on other sites