Jump to content
  • Advertisement
Sign in to follow this  
prux

stupid pixel shader

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

hey! Im (would) use DX 8.1 and vertex shader... heres the example:
sampler2D g_samSrcColor;

float4 main( float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color;
    
    Color = tex2D( g_samSrcColor, Tex.xy)*4;
    return Color;
}

technique PostProcess
{
    pass p1
    {
        VertexShader = null;
        PixelShader = compile ps_1_4 main();
    }

}
the samples is "converted" to assembly, because 8.1 doesnt know HLSL language: fxc.exe /nologo /Tps_1_2 /Emain shader.ps > shader.asm
//
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.08.299.0000
//
//   fxc /nologo /Tps_1_2 /Emain shader.ps
//
//
// Parameters:
//
//   sampler2D g_samSrcColor;
//
//
// Registers:
//
//   Name          Reg   Size
//   ------------- ----- ----
//   g_samSrcColor s0       1
//

    ps.1.2
    def c0, 4, 4, 4, 4
    tex t0
    mul r0, t0, c0

// approximately 2 instruction slots used (1 texture, 1 arithmetic)

this currently does nothing... although theres another example: ps.1.0 def c0, 1.0f, 1.0f,1.0f, 1.0f tex t0 sub r0,c0,t0 this works (at least has got effect). Only this example works, this wastebasket doesnt want to work for me!! Any idea why?

Share this post


Link to post
Share on other sites
Advertisement
This may happend due to many reasons, most probably your card is an ATI card and you are trying to run a PS1.2.

Due to lack of standarization on the first PS cards, nVidia video cards are able to handle PS 1.1, 1.2, 1.3 and 2.0 or higher. ATI video cards are able to handle PS 1.4 and 2.0 or higher. So if you try to run a 1.2 shader in an ATI card it may fail

In the other hand, there is no support for PS1.0 in any card. 1.0 was something like the first PS concept by nVidia and was never released in any video card so trying to make a 1.0 shader will probably fail.

That said, I agree with EmptyVoid (a really empty name I must say) and suggest you to move to PS2.0 or higher unless you have a really compelling reason to stay with 1.x shaders.

Luck!
Guimo

Share this post


Link to post
Share on other sites
luckily I found some correction, I can still use it but there are more questions tough.

So, heres an example:

sampler2D g_samSrcColor;
float4 main( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;

Tex.x = Tex.x * 0.5;
Color = tex2D( g_samSrcColor, Tex.xy);
return Color;
}

technique PostProcess
{
pass p1
{
VertexShader = null;
PixelShader = compile ps_1_4 main();
}
}

it works. Theres a color sample:

Quote:
Color = tex2D( input , Tex.xy)*3;


this also works,

Quote:
Color.r = Color.r / 2;


this too, but WHEN I want to

Quote:
Color.r = Color.r * 2;


the FXC says:

Quote:
shader.ps(18): warning X4704: literal values outside range -1 to 1 are clamped on all ps_1_x shading models


and it dont work :S

Thx the replies! I think I tried to "hard" examples first.

Share this post


Link to post
Share on other sites
Mint látod, a szineket -1 és 1 közé "szorítja", mivel osztásnál egyre inkább a 0 felé halad az érték, ellenben szorzásnál könnyen áteshet ezeken.

Szineket többnyire 0..1 tartományban határozunk meg.

So, understand? :)

Share this post


Link to post
Share on other sites
Minden grafikus API (OpenGL, DX) a szineket float-ként tárolja, 0..1 tartományban, a nagyobb precizitás miatt. Persze te megadhatod 0..255 között (opengl-ben pl. glColor3ub, DX-ben nem tudom), de "belül" úgy is float-ban tárolódik, és ebben a formában is dolgozik vele.

Lehet, nem örülnek itt, hogy magyarul irunk. :D

Share this post


Link to post
Share on other sites
its clear now, but I dont know then how to avoid this... when I mul the whole color (Color = tex2D( input , Tex.xy)*3;) it works, and when just a part of it (Color = tex2D( input , Tex.xy).R*3;) it doesnt?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!