Jump to content
  • Advertisement
Sign in to follow this  
huaner

Various HLSL Compiler Errors

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

I write a shder .But it can't run.And the wrong that is hint by complier is it can't find "out". Also,I can't find where is wrong.The code id below: matrix matWorldViewProj; matrix matWorld; vector vecLightDir; struct VS_OUT { float4 position : POSITION; float3 light : TEXCOORD0; float3 normal : TEXCOORD1; }; VS_OUT VS(float4 pos : POSITION, float3 norm : NORMAL) { VS_OUT out = (VS_OUT)0; out.position = mul(pos, matWorldViewProj); out.normal = normalize(mul(norm, matWorld)); out.light = normalize(vecLightDir); return out; } float4 PS(float3 light : TEXCOORD0, float3 normal : TEXCOORD1) : COLOR { float4 diffuse = {1.0f, 0.0f, 0.0f, 1.0f}; float4 ambient = {0.1f, 0.0f, 0.0f, 1.0f}; return ambient + diffuse * saturate(dot(light, normal)); } thanks [Edited by - jollyjeffers on November 16, 2006 8:43:31 AM]

Share this post


Link to post
Share on other sites
Advertisement
It fails because 'out' is a reserved word in HLSL. Change it to any other name, and it will magically work.

HLSL uses 'in', 'out', and 'inout' to specify how function parameters are passed. Parameters marked 'in' (default) and 'inout' are passed by value when the function starts. Parameters marked 'out' and 'inout' are returned by value when the function exits.

xyzzy

Share this post


Link to post
Share on other sites
First, thank for your reply!
You are right!But It doesn't run also. The wrong is : Read of uninitialized
component(*)in r1: r/0 g/1 b/2 * a/3.Why?the shader is also the same before
matrix matWorldViewProj;
matrix matWorld;
vector vecLightDir;

struct VS_OUT
{
float4 position : POSITION;
float3 light : TEXCOORD0;
float3 normal : TEXCOORD1;
};

VS_OUT VS(float4 pos : POSITION, float3 norm : NORMAL)
{
VS_OUT outVS = (VS_OUT)0;
outVS.position = mul(pos, matWorldViewProj);
outVS.normal = normalize(mul(norm, matWorld));
outVS.light = normalize(vecLightDir);

return outVS;
}

float4 PS(float3 light : TEXCOORD0, float3 normal : TEXCOORD1) : COLOR
{
float4 diffuse = {1.0f, 0.0f, 0.0f, 1.0f};
float4 ambient = {0.1f, 0.0f, 0.0f, 1.0f};

return ambient + diffuse * saturate(dot(light, normal));
}
3Q!

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!