Archived

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

prgrmmr

pixel shader pixel position

Recommended Posts

Guest Anonymous Poster   
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
prgrmmr    122
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?

Share this post


Link to post
Share on other sites
prgrmmr    122
Drilian: For the shadow texture. (Soft Stencil Shadows). When using multiple lights, the best I think is that way to get per-pixel correct lighting.

Share this post


Link to post
Share on other sites
Fluid FX    122
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
prgrmmr    122
sorry, Fluid, but that is not what I need. I need to map a screen-space ( viewing rect plane ) lightmap to a 3d object.

Share this post


Link to post
Share on other sites
prgrmmr    122
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
EvilDecl81    360
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