• Create Account

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1cool dude  Members

131
Like
0Likes
Like

Posted 02 June 2012 - 01:23 PM

float4x4 World;
float4x4 View;float4x4 Projection;

float4 AmbientColor = float4(1, 1, 1, 1);
float AmbientIntensity = 0.1;

{
float4 Position : POSITION0;
};

{
float4 Position : POSITION0;
};

{

float4 worldPosition = mul(input.Position, World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);

return output;
}

{
return AmbientColor * AmbientIntensity;
}

technique Ambient
{
pass Pass1
{
}
}

i am trying to learn how to use shaders with directx and i found this code over d net

icould not understand the following thingsin above code

float4 Position : (POSITION0)?;

Also how these function works
technique Ambient
{
pass Pass1(wt is this)
{
}
}

Also, let me know if there is any video tutorial on shaders with directx.

### #2Fredericvo  Members

1571
Like
0Likes
Like

Posted 02 June 2012 - 01:31 PM

What about those 2 lines do you not understand? They map vertex data to variables inside the shader. In this case position and a diffuse colour I guess.
As for the technique thingy it's a d3dx utility to use and manage shaders at a higher level.

### #3cool dude  Members

131
Like
0Likes
Like

Posted 04 June 2012 - 03:01 PM

float4 Position : (POSITION0)?;

so the above functions are used to

map vertex data to variables inside the shader but what is the vertex data in the above two lines of code. (can you elaborate)

Also suggest me a site or a tutorial where i can start learning to program shaders

### #4yckx  Prime Members

1298
Like
0Likes
Like

Posted 04 June 2012 - 04:09 PM

The first line you ask about is not a function. It is part of a struct definition. I think what is confusing you are the semantics at the end of the line. They serve to describe the intended use of a variable or a function's return value. I'm not familiar of a site from which to learn other MSDN.

Oh, and vertex data is mapped to the vertex shader's input. The way the vertex data is structured and sent is defined in the application using the DirectX API. The vertex shader needs to be written to expect it's input the same format the app is written to send it.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.