Home » Community » Forums » Graphics Programming and Theory » HLSL: Shader doing diff things on diff computers
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 HLSL: Shader doing diff things on diff computers
Post New Topic  Post Reply 
Hey Guys,

I have a shader below that works just fine for me, but for another guy, there is a green tint on everything.

Can anyone see anything weird with this?

Thank you!

//////////////////////////////////////////////////////////////////////
//                         STRUCTURES
//////////////////////////////////////////////////////////////////////

// Vertex shader output structure
struct VS_OUTPUT
{
    float4 Position   : POSITION;
    float2 Texture    : TEXCOORD0;
    float4 Color      : COLOR0;
    float3 Light      : TEXCOORD1;
    float3 Norm       : TEXCOORD2;
};

//////////////////////////////////////////////////////////////////////
//                         GLOBALS
//////////////////////////////////////////////////////////////////////

// vertex globals
float4x4 WorldViewProj;
float4x4 World;
float4 Diffuse;

// pixel variables
sampler2D Tex0;

//////////////////////////////////////////////////////////////////////
//                         VERTEX
//////////////////////////////////////////////////////////////////////

VS_OUTPUT vs_main( float4 Position : POSITION, float2 Texture : TEXCOORD0, float3 Normal : NORMAL, float4 InColor : Color0 )
{
    VS_OUTPUT Out;                      //create an output vertex

    Out.Position = mul(Position,WorldViewProj);  //apply vertex transformation
    Out.Texture  = Texture;          //copy original texcoords
    Out.Color    = Diffuse * InColor;
 
    Out.Light    = normalize(float3(3,2,1));
    Out.Norm     = -normalize(mul(Normal,World));

    return Out;                         //return output vertex
}

//////////////////////////////////////////////////////////////////////
//                         PIXEL
//////////////////////////////////////////////////////////////////////

float4 ps_main( float2 Texture : TEXCOORD0, float4 Color : COLOR0, float3 Light : TEXCOORD1, float3 Norm : TEXCOORD2) : COLOR
{
    float4 Out;
    float4 Tx;

    Tx = tex2D(Tex0, Texture);

    //look up texture and multiply by color tint and ambient light
    Out = Tx;
    Out *= Color;
    Out *= float4(0.2,0.2,0.2,1.0);

    //add the diffuse light
    Out += saturate(dot(Light,Norm))* float4(1.0,1.0,1.0,0.0) * Tx;

    Out = saturate(Out);

    return Out;
}


 User Rating: 1080   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

That another guy should update his graphics card drivers.

 User Rating: 536   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Thanks for the response

Hrm well he said he updated em and it didnt fix it.

Is that generally what this kind of thing boils down to?

If it really is his drivers it makes me wonder how he can play other games and they don't have this problem though.

The shader itself looks ok?

::sigh:: :P

 User Rating: 1080   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Try running your app with the reference rasterizer. If it produces the intended results, then you probably hit a bug in the driver. If it produces the "bad" results, then you have a bug in your code.


Matt Pettineo | DirectX/XNA MVP

Ride into The Danger Zone

PIX With XNA Tutorial

 User Rating: 1868   |  Rate This User  Send Private MessageView ProfileView Journal Report this Post to a Moderator | Link

Drivers are really complicated. So usually only some "special" shaders fail to work correctly. That means you can also try to refactor some parts of your shader, it might work.

P.S. Other games are tested on many graphics cards. When the developers see a bug like that, they usually fix or report it.

 User Rating: 536   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

Ok i figured out what the problem is.

The vertex shader takes Color0 as an input, but my FVF doesn't include a color.

so, i guess for most people who tried this app out, their drivers/cards were using white for the unsent color.

for my buddy who was having the weird green tint, his driver/card was using some uninitialized value.

Thanks for the help guys! (:

 User Rating: 1080   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: