About Store Forum Documentation Contact



Post Reply 
Pixel shading noob question
Author Message
mystara Offline
Member

Post: #1
Pixel shading noob question
Hi,

I'm trying to modify the flow shader so that the alpha value of each pixel depends on the x coordinate of the pixel. I had thought I could do something like this:

Code:
Vec4 PS
(
   Vec2 inTex:TEXCOORD0,
   Vec2 inPos:POSITION
):COLOR
{
   Flt mask=Tex(Col      , inTex          ).a  ; // mask is stored in Bump channel (which is Base Tex #0, Alpha Channel)
   Vec flow=Tex(FlowImage, inTex+TexOffset).rgb; // get flow texture from tex coordinates with tex offset

   return Vec4(flow*Vec(0.2, 0.6, 1.0), mask*inPos.x);
}

But when I do so, I get the error 'Empty PS in tech "Main"'
I translate this error as "Your pixel shader is badly written" smile

I've probably done something immensely stupid. But I can't seem to find any kind of documentation on how to write these things, so I'm really just guessing :/

Can I please have a clue? smile
08-20-2011 03:17 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: Pixel shading noob question
Mac uses CG/glsl for shader compilation (on Win DirectX is used, which will provide better messages on shader compilation fail)

if you want screen position accessible in Pixel Shader from 3D model, you need to do:

Code:
void VS
(
   VtxInput vtx,

   out Vec4 outVtx  :POSITION ,
   out Vec4 outPos4:TEXCOORD..,
)
{
   outVtx=outPos4=Project(..)
}

Vec4 PS
(
   IF_IS_PIXEL
   Vec4 inPos4:TEXCOORD..,
):COLOR
{
   Vec2 screen=PixelOrPosToScreen(pixel, inPos4);
}
08-24-2011 01:58 PM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #3
RE: Pixel shading noob question
Ah, brilliant.

Thanks!
08-24-2011 08:19 PM
Find all posts by this user Quote this message in a reply
Post Reply