SlideShare a Scribd company logo
Mohammad Shaker
mohammadshaker.com
@ZGTRShaker
2011, 2012, 2013, 2014
XNA Game Development
L10 – Shaders Part 1
Working with Shaders in XNA
What is a shader?!
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
What a shader is?!
• Fixed Function Pipeline (FFP)
– limits what game developers can do, but ease things off for them
• Programmable graphics pipelines
– You get to decide exactly how things should be performed
HLSL
High Level Shader Language
HLSL
• HLSL is used not to improve the gameplay, but to enhance the quality of the final
image.
HLSL
• Every vertex that is drawn will pass through your vertex shader, and even every
pixel drawn will have passed through your pixel shader
HLSL
The effect file
• One of the main differences between DirectX 9 and XNA is that we need an effect
for everything we draw!
The effect file
• So, what exactly is an “effect”?
The effect file
• In 3D programming, all objects are represented using triangles. Even spheres!
The effect file
• An effect is…!
The effect file
• An effect is some code that instructs your hardware (the graphics card) how it
should display these triangles
• An effect file contains one or more “techniques”
• For example technique A and technique B. Drawing triangles using technique A
will for example draw them semi-transparent, while drawing them using technique
B will for example draw all objects using only blue-gray colors as seen in some
horror movies.
The effect file
• Declaring an effect
Effect effect;
The effect file
• .FX Files
The effect file
• Declaring an effect
• Loading the effect file
Effect effect;
effect = Content.Load<Effect> ("effects");
The effect file
• Declaring an effect
• Loading the effect file
Effect effect;
effect = Content.Load<Effect> ("effects");
The effect file
• Declaring an effect
• Loading the effect file
Effect effect;
effect = Content.Load<Effect> ("effects");
The effect file
• Declaring an effect
• Loading the effect file
• Draw() method
Effect effect;
effect = Content.Load<Effect> ("effects");
device.Clear(Color.DarkSlateBlue);
The effect file
• Using a “User-Defined Technique”!
effect.CurrentTechnique = effect.Techniques["Pretransformed"];
The effect file
• Using a “User-Defined Technique”!
effect.CurrentTechnique = effect.Techniques["Pretransformed"];
The effect file
• Using a “User-Defined Technique”!
effect.CurrentTechnique = effect.Techniques["Pretransformed"];
• A technique can be made up of multiple passes, so we need to iterate
through them. Add this code below the code you just entered:
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
}
The effect file
• Using a “User-Defined Technique”!
effect.CurrentTechnique = effect.Techniques["Pretransformed"];
• A technique can be made up of multiple passes, so we need to iterate
through them. Add this code below the code you just entered:
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
// Drawing code that this technique applies its effect to!
}
The effect file
• Using a “User-Defined Technique”!
effect.CurrentTechnique = effect.Techniques["Pretransformed"];
• A technique can be made up of multiple passes, so we need to iterate
through them. Add this code below the code you just entered:
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
// Drawing code that this technique applies its effect to!
}
The effect file
• Quite simple!
HLSL – Vertex Format
HLSL
Let’s play with shaders a bit!
HLSL
• Let’s play with shaders a bit!
– Mo l3beh ha! :D
HLSL – Vertex Format
• Remember VertexPositionColor?
HLSL – Vertex Format
• We’ll just design our own
• “VertexPositionColor”!
HLSL – Vertex Format
• We’ll just design our own
• “VertexPositionColor”!
HLSL – Vertex Format
• Let’s name it
• “MyOwnVertexFormat”
HLSL – Vertex Format
• What we need is
– A structure that can hold the necessary data for each vertex and
• What we need is
– A structure that can hold the necessary data for each vertex and
– A definition of the data, so the vertex shader knows which data is included with every vertex.
• A simple colored triangle through using our format “MyOwnVertexFormat”
• What should our vertex shader hold?!
• Just holding a position and a color!
HLSL – Vertex Format
struct MyOwnVertexFormat
{
private Vector3 position;
private Color color;
public MyOwnVertexFormat (Vector3 position, Color color)
{
this.position = position;
this.color = color;
}
}
struct MyOwnVertexFormat
{
private Vector3 position;
private Color color;
public MyOwnVertexFormat (Vector3 position, Color color)
{
this.position = position;
this.color = color;
}
}
HLSL – Vertex Format
HLSL – Vertex Format
• Now, since we are dealing with the graphics card ,
• the graphics card needs to be told explicitly which data it will receive.
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(
0,
VertexElementFormat.Vector3,
VertexElementUsage.Position,
0),
new VertexElement(
sizeof(float) * 3,
VertexElementFormat.Color,
VertexElementUsage.Color,
0)
);
HLSL – Vertex Format
• Adding the following code to our struct
HLSL – Vertex Format
• Now, Implementing it in our XNA code!
private void SetUpVertices()
{
MyOwnVertexFormat[] vertices = new MyOwnVertexFormat[3];
vertices[0] = new MyOwnVertexFormat(new Vector3(-2, 2, 0), Color.Red);
vertices[1] = new MyOwnVertexFormat(new Vector3(2, -2, -2), Color.Green);
vertices[2] = new MyOwnVertexFormat(new Vector3(0, 0, 2), Color.Yellow);
vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration,
vertices.Length, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices);
}
HLSL – Vertex Format
• Now, Implementing it in our XNA code!
private void SetUpVertices()
{
MyOwnVertexFormat[] vertices = new MyOwnVertexFormat[3];
vertices[0] = new MyOwnVertexFormat(new Vector3(-2, 2, 0), Color.Red);
vertices[1] = new MyOwnVertexFormat(new Vector3(2, -2, -2), Color.Green);
vertices[2] = new MyOwnVertexFormat(new Vector3(0, 0, 2), Color.Yellow);
vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration,
vertices.Length, BufferUsage.WriteOnly);
vertexBuffer.SetData(vertices);
}
HLSL – Vertex Format
• “App1-VertexFormat”
HLSL – Vertex Shader
• Create a new empty effect file, name it(OurHLSLfile.fx)
HLSL – Vertex Shader
• Create a new empty effect file, name it(OurHLSLfile.fx)
• Delete everything in it!
HLSL – Vertex Shader
• Create a new empty effect file, name it(OurHLSLfile.fx)
• Delete everything in it!
HLSL – Vertex Shader
• Create a new empty effect file, name it(OurHLSLfile.fx)
• Delete everything in it!
HLSL – Vertex Shader
• Create a new empty effect file, name it(OurHLSLfile.fx)
• Delete everything in it!
HLSL – Vertex Shader
• Put this as your first HLSL code in your.fx file
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• Put this as your first HLSL code in your.fx file
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• Put this as your first HLSL code in your.fx file
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• Put this as your first HLSL code in your.fx file
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• Put this as your first HLSL code in your.fx file
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
HLSL – Vertex Shader
• So put this code at the top of your.fx file:
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
HLSL – Vertex Shader
• So put this code at the top of your.fx file:
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
HLSL – Vertex Shader
• So put this code at the top of your.fx file:
• Now, Place this method between the structure definition and our technique
definition:
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
Output.Color.rba = 1.0f;
Output.Color.g = 0.0f;
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• The hole code for now will be
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{ pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• FINALLY!
HLSL – Vertex Shader
• float4x4 xViewProjection;
HLSL – Vertex Shader
• float4x4 xViewProjection;
HLSL – Vertex Shader
float4x4 xViewProjection;
struct VertexToPixel
{ float4 Position : POSITION;
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = NULL;
}
}
HLSL – Vertex Shader
• NICE!
• “App3-CompleteFirstShader(White)”
• For more info
– http://www.riemers.net/eng/Tutorials/XNA/Csharp/series3.php
Pixel Format and Pixel Shader
Pixel Shader
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Pixel_shader.php
For more info visit,
Pixel Shader
• We have the our last lesson Vertex Shader up and running, we just need a Pixel
Shader now to get the job done and draw using our own custom way of
rendering!
• The pixel shader receives its input (position and color, in our case) from our vertex
shader, and needs to output only color
Pixel Shader
• So let’s define its output structure at the top of our.fx file “Pixel Format”
struct PixelToFrame
{
float4 Color : COLOR0;
};
Pixel Shader
• So let’s define its output structure at the top of our.fx file “Pixel Format”
• Our first pixel shader will be a very simple method, here it is “Pixel Shader”
struct PixelToFrame
{
float4 Color : COLOR0;
};
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
Pixel Shader
• So let’s define its output structure at the top of our.fx file “Pixel Format”
• Our first pixel shader will be a very simple method, here it is “Pixel Shader”
struct PixelToFrame
{
float4 Color : COLOR0;
};
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
Pixel Shader
• Now we still need to set this method as pixel shader for our technique, at the
bottom of the file:
PixelShader = compile ps_2_0 OurFirstPixelShader();
Pixel Shader
• Now we still need to set this method as pixel shader for our technique, at the
bottom of the file:
PixelShader = compile ps_2_0 OurFirstPixelShader();
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = compile ps_2_0 OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
The hole
code in HLSL
file
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
Pixel Shader
• Now, let’s use our own HLSL code in our XNA code!
Pixel Shader
• Loading our own effect file “OurHLSLfile”
effect = Content.Load<Effect> ("OurHLSLfile");
Pixel Shader
• Draw() method
protected override void Draw(GameTime gameTime)
{
device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
Color.DarkSlateBlue, 1.0f, 0);
effect.CurrentTechnique = effect.Techniques["Simplest"];
effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix);
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.SetVertexBuffer(vertexBuffer);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
}
base.Draw(gameTime);
}
Pixel Shader
• Draw() methodprotected override void Draw(GameTime gameTime)
{
device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
Color.DarkSlateBlue, 1.0f, 0);
effect.CurrentTechnique = effect.Techniques["Simplest"];
effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix);
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.SetVertexBuffer(vertexBuffer);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
}
base.Draw(gameTime);
}
Pixel Shader
• Draw() methodprotected override void Draw(GameTime gameTime)
{
device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
Color.DarkSlateBlue, 1.0f, 0);
effect.CurrentTechnique = effect.Techniques["Simplest"];
effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix);
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.SetVertexBuffer(vertexBuffer);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
}
base.Draw(gameTime);
}
Pixel Shader
• We did it out own!
• We told the GPU how to work!
• “App2-CompleteFirstShader(Colored)”
Pixel Shader
Remember the following?!
Pixel Shader
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
VertexToPixel SimplestVertexShader( float4 inPos :
POSITION, float4 inColor : COLOR0)
{
VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0
SimplestVertexShader();
PixelShader = compile ps_2_0
OurFirstPixelShader();
}
}
VertexToPixel SimplestVertexShader(float4 inPos : POSITION)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = 1.0f;
return Output;
}
Pixel Shader
• NICE!
• “App3-CompleteFirstShader(White)”

More Related Content

What's hot

Pythonic Graphics
Pythonic GraphicsPythonic Graphics
Pythonic Graphics
Kirby Urner
 
AutoDesk
AutoDeskAutoDesk
AutoDesk
SE3D
 
Python: The Iterator Pattern (Comprehensions)
Python: The Iterator Pattern (Comprehensions)Python: The Iterator Pattern (Comprehensions)
Python: The Iterator Pattern (Comprehensions)
Damian T. Gordon
 
Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014
Cyrille Martraire
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Aysylu Greenberg
 
Loom at Clojure/West
Loom at Clojure/WestLoom at Clojure/West
Loom at Clojure/West
Aysylu Greenberg
 
Loom and Graphs in Clojure
Loom and Graphs in ClojureLoom and Graphs in Clojure
Loom and Graphs in Clojure
Aysylu Greenberg
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
LearningTech
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 Introduction
Till Nagel
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
LearningTech
 
Functional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic ProgrammerFunctional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic Programmer
Raúl Raja Martínez
 
Sync considered unethical
Sync considered unethicalSync considered unethical
Sync considered unethical
💡 Tomasz Kogut
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And Monad
Oliver Daff
 
Monad Transformers In The Wild
Monad Transformers In The WildMonad Transformers In The Wild
Monad Transformers In The Wild
StackMob Inc
 
C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1
Mohammad Shaker
 
Project Fortress
Project FortressProject Fortress
Project Fortress
Alex Miller
 

What's hot (16)

Pythonic Graphics
Pythonic GraphicsPythonic Graphics
Pythonic Graphics
 
AutoDesk
AutoDeskAutoDesk
AutoDesk
 
Python: The Iterator Pattern (Comprehensions)
Python: The Iterator Pattern (Comprehensions)Python: The Iterator Pattern (Comprehensions)
Python: The Iterator Pattern (Comprehensions)
 
Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014Ur Domain Haz Monoids DDDx NYC 2014
Ur Domain Haz Monoids DDDx NYC 2014
 
Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015Loom & Functional Graphs in Clojure @ LambdaConf 2015
Loom & Functional Graphs in Clojure @ LambdaConf 2015
 
Loom at Clojure/West
Loom at Clojure/WestLoom at Clojure/West
Loom at Clojure/West
 
Loom and Graphs in Clojure
Loom and Graphs in ClojureLoom and Graphs in Clojure
Loom and Graphs in Clojure
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 Introduction
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Functional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic ProgrammerFunctional Programming Patterns for the Pragmatic Programmer
Functional Programming Patterns for the Pragmatic Programmer
 
Sync considered unethical
Sync considered unethicalSync considered unethical
Sync considered unethical
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And Monad
 
Monad Transformers In The Wild
Monad Transformers In The WildMonad Transformers In The Wild
Monad Transformers In The Wild
 
C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1
 
Project Fortress
Project FortressProject Fortress
Project Fortress
 

Viewers also liked

Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
Mohammad Shaker
 
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D EnvironmentUtilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
Mohammad Shaker
 
C# Starter L07-Objects Cloning
C# Starter L07-Objects CloningC# Starter L07-Objects Cloning
C# Starter L07-Objects Cloning
Mohammad Shaker
 
Delphi L02 Controls P1
Delphi L02 Controls P1Delphi L02 Controls P1
Delphi L02 Controls P1
Mohammad Shaker
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
Mohammad Shaker
 
WPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D AnimationWPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D Animation
Mohammad Shaker
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
Mohammad Shaker
 
C# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationC# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow Foundation
Mohammad Shaker
 
WPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and TemplatesWPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and Templates
Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
Mohammad Shaker
 
C# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFC# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCF
Mohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
Mohammad Shaker
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
Mohammad Shaker
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
Mohammad Shaker
 
Car Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS SystemsCar Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS Systems
Mohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Mohammad Shaker
 

Viewers also liked (16)

Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an Indie
 
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D EnvironmentUtilizing Kinect Control for a More Immersive Interaction with 3D Environment
Utilizing Kinect Control for a More Immersive Interaction with 3D Environment
 
C# Starter L07-Objects Cloning
C# Starter L07-Objects CloningC# Starter L07-Objects Cloning
C# Starter L07-Objects Cloning
 
Delphi L02 Controls P1
Delphi L02 Controls P1Delphi L02 Controls P1
Delphi L02 Controls P1
 
C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASP
 
WPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D AnimationWPF L03-3D Rendering and 3D Animation
WPF L03-3D Rendering and 3D Animation
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
C# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationC# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow Foundation
 
WPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and TemplatesWPF L01-Layouts, Controls, Styles and Templates
WPF L01-Layouts, Controls, Styles and Templates
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
C# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFC# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCF
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
Car Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS SystemsCar Dynamics with ABS, ESP and GPS Systems
Car Dynamics with ABS, ESP and GPS Systems
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 

Similar to XNA L10–Shaders Part 1

Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 Overview
RJ Owen
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problems
Holger Schill
 
COMP 4026 Lecture 5 OpenFrameworks and Soli
COMP 4026 Lecture 5 OpenFrameworks and SoliCOMP 4026 Lecture 5 OpenFrameworks and Soli
COMP 4026 Lecture 5 OpenFrameworks and Soli
Mark Billinghurst
 
Migrating fx3tofx4
Migrating fx3tofx4Migrating fx3tofx4
Migrating fx3tofx4
Jonathan Campos
 
ElixirでFPGAを設計する
ElixirでFPGAを設計するElixirでFPGAを設計する
ElixirでFPGAを設計する
Hideki Takase
 
A Brief Intro to Adobe Flex
A Brief Intro to Adobe FlexA Brief Intro to Adobe Flex
A Brief Intro to Adobe Flex
Chad Udell
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
AboutYouGmbH
 
Vhdl design flow
Vhdl design flowVhdl design flow
Vhdl design flow
Rohit Chintu
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to Processing
Cate Huston
 
Managing and Using Assets in Rich Flash Experiences
Managing and Using Assets in Rich Flash ExperiencesManaging and Using Assets in Rich Flash Experiences
Managing and Using Assets in Rich Flash Experiences
David Ortinau
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
lennartkats
 
Introduction to TensorFlow Lite
Introduction to TensorFlow Lite Introduction to TensorFlow Lite
Introduction to TensorFlow Lite
Koan-Sin Tan
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspective
kfrdbs
 
HFM, Workspace, and FDM – Voiding your warranty
HFM, Workspace, and FDM – Voiding your warrantyHFM, Workspace, and FDM – Voiding your warranty
HFM, Workspace, and FDM – Voiding your warranty
Charles Beyer
 
Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016
Chris Fregly
 
DelveNYC: Flash Catalyst
DelveNYC: Flash CatalystDelveNYC: Flash Catalyst
DelveNYC: Flash Catalyst
Ryan Stewart
 
Python_for_Visual_Effects_and_Animation_Pipelines
Python_for_Visual_Effects_and_Animation_PipelinesPython_for_Visual_Effects_and_Animation_Pipelines
Python_for_Visual_Effects_and_Animation_Pipelines
Russell Darling
 
[CCP Games] Versioning Everything with Perforce
[CCP Games] Versioning Everything with Perforce[CCP Games] Versioning Everything with Perforce
[CCP Games] Versioning Everything with Perforce
Perforce
 
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
antopensource
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
Thinkful
 

Similar to XNA L10–Shaders Part 1 (20)

Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 Overview
 
Xtext beyond the defaults - how to tackle performance problems
Xtext beyond the defaults -  how to tackle performance problemsXtext beyond the defaults -  how to tackle performance problems
Xtext beyond the defaults - how to tackle performance problems
 
COMP 4026 Lecture 5 OpenFrameworks and Soli
COMP 4026 Lecture 5 OpenFrameworks and SoliCOMP 4026 Lecture 5 OpenFrameworks and Soli
COMP 4026 Lecture 5 OpenFrameworks and Soli
 
Migrating fx3tofx4
Migrating fx3tofx4Migrating fx3tofx4
Migrating fx3tofx4
 
ElixirでFPGAを設計する
ElixirでFPGAを設計するElixirでFPGAを設計する
ElixirでFPGAを設計する
 
A Brief Intro to Adobe Flex
A Brief Intro to Adobe FlexA Brief Intro to Adobe Flex
A Brief Intro to Adobe Flex
 
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
Stefan Richter - Writing simple, readable and robust code: Examples in Java, ...
 
Vhdl design flow
Vhdl design flowVhdl design flow
Vhdl design flow
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to Processing
 
Managing and Using Assets in Rich Flash Experiences
Managing and Using Assets in Rich Flash ExperiencesManaging and Using Assets in Rich Flash Experiences
Managing and Using Assets in Rich Flash Experiences
 
Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)Remix Your Language Tooling (JSConf.eu 2012)
Remix Your Language Tooling (JSConf.eu 2012)
 
Introduction to TensorFlow Lite
Introduction to TensorFlow Lite Introduction to TensorFlow Lite
Introduction to TensorFlow Lite
 
The Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's PerspectiveThe Next Mainstream Programming Language: A Game Developer's Perspective
The Next Mainstream Programming Language: A Game Developer's Perspective
 
HFM, Workspace, and FDM – Voiding your warranty
HFM, Workspace, and FDM – Voiding your warrantyHFM, Workspace, and FDM – Voiding your warranty
HFM, Workspace, and FDM – Voiding your warranty
 
Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016Advanced Spark and TensorFlow Meetup May 26, 2016
Advanced Spark and TensorFlow Meetup May 26, 2016
 
DelveNYC: Flash Catalyst
DelveNYC: Flash CatalystDelveNYC: Flash Catalyst
DelveNYC: Flash Catalyst
 
Python_for_Visual_Effects_and_Animation_Pipelines
Python_for_Visual_Effects_and_Animation_PipelinesPython_for_Visual_Effects_and_Animation_Pipelines
Python_for_Visual_Effects_and_Animation_Pipelines
 
[CCP Games] Versioning Everything with Perforce
[CCP Games] Versioning Everything with Perforce[CCP Games] Versioning Everything with Perforce
[CCP Games] Versioning Everything with Perforce
 
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
Wwx2014 - Todd Kulick "Shipping One Million Lines of Haxe to (Over) One Milli...
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 

More from Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
Mohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
Mohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
Mohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
Mohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
Mohammad Shaker
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
Mohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
Mohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
Mohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
Mohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
Mohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
Mohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
Mohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
Mohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
Mohammad Shaker
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to Games
Mohammad Shaker
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSeven
Mohammad Shaker
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in Games
Mohammad Shaker
 
Roboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringRoboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software Engineering
Mohammad Shaker
 

More from Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to Games
 
Indie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSevenIndie Series 04: The Making of SyncSeven
Indie Series 04: The Making of SyncSeven
 
Indie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in GamesIndie Series 02: AI and Recent Advances in Games
Indie Series 02: AI and Recent Advances in Games
 
Roboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringRoboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software Engineering
 

Recently uploaded

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 

Recently uploaded (20)

Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 

XNA L10–Shaders Part 1

  • 1. Mohammad Shaker mohammadshaker.com @ZGTRShaker 2011, 2012, 2013, 2014 XNA Game Development L10 – Shaders Part 1
  • 3. What is a shader?!
  • 4. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 5. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 6. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 7. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 8. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 9. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 10. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 11. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 12. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 13. What a shader is?! • Fixed Function Pipeline (FFP) – limits what game developers can do, but ease things off for them • Programmable graphics pipelines – You get to decide exactly how things should be performed
  • 15. HLSL • HLSL is used not to improve the gameplay, but to enhance the quality of the final image.
  • 16. HLSL • Every vertex that is drawn will pass through your vertex shader, and even every pixel drawn will have passed through your pixel shader
  • 17. HLSL
  • 18. The effect file • One of the main differences between DirectX 9 and XNA is that we need an effect for everything we draw!
  • 19. The effect file • So, what exactly is an “effect”?
  • 20. The effect file • In 3D programming, all objects are represented using triangles. Even spheres!
  • 21. The effect file • An effect is…!
  • 22. The effect file • An effect is some code that instructs your hardware (the graphics card) how it should display these triangles • An effect file contains one or more “techniques” • For example technique A and technique B. Drawing triangles using technique A will for example draw them semi-transparent, while drawing them using technique B will for example draw all objects using only blue-gray colors as seen in some horror movies.
  • 23. The effect file • Declaring an effect Effect effect;
  • 24. The effect file • .FX Files
  • 25. The effect file • Declaring an effect • Loading the effect file Effect effect; effect = Content.Load<Effect> ("effects");
  • 26. The effect file • Declaring an effect • Loading the effect file Effect effect; effect = Content.Load<Effect> ("effects");
  • 27. The effect file • Declaring an effect • Loading the effect file Effect effect; effect = Content.Load<Effect> ("effects");
  • 28. The effect file • Declaring an effect • Loading the effect file • Draw() method Effect effect; effect = Content.Load<Effect> ("effects"); device.Clear(Color.DarkSlateBlue);
  • 29. The effect file • Using a “User-Defined Technique”! effect.CurrentTechnique = effect.Techniques["Pretransformed"];
  • 30. The effect file • Using a “User-Defined Technique”! effect.CurrentTechnique = effect.Techniques["Pretransformed"];
  • 31. The effect file • Using a “User-Defined Technique”! effect.CurrentTechnique = effect.Techniques["Pretransformed"]; • A technique can be made up of multiple passes, so we need to iterate through them. Add this code below the code you just entered: foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); }
  • 32. The effect file • Using a “User-Defined Technique”! effect.CurrentTechnique = effect.Techniques["Pretransformed"]; • A technique can be made up of multiple passes, so we need to iterate through them. Add this code below the code you just entered: foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); // Drawing code that this technique applies its effect to! }
  • 33. The effect file • Using a “User-Defined Technique”! effect.CurrentTechnique = effect.Techniques["Pretransformed"]; • A technique can be made up of multiple passes, so we need to iterate through them. Add this code below the code you just entered: foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); // Drawing code that this technique applies its effect to! }
  • 34. The effect file • Quite simple!
  • 35. HLSL – Vertex Format
  • 36. HLSL Let’s play with shaders a bit!
  • 37. HLSL • Let’s play with shaders a bit! – Mo l3beh ha! :D
  • 38. HLSL – Vertex Format • Remember VertexPositionColor?
  • 39. HLSL – Vertex Format • We’ll just design our own • “VertexPositionColor”!
  • 40. HLSL – Vertex Format • We’ll just design our own • “VertexPositionColor”!
  • 41. HLSL – Vertex Format • Let’s name it • “MyOwnVertexFormat”
  • 42. HLSL – Vertex Format • What we need is – A structure that can hold the necessary data for each vertex and • What we need is – A structure that can hold the necessary data for each vertex and – A definition of the data, so the vertex shader knows which data is included with every vertex. • A simple colored triangle through using our format “MyOwnVertexFormat” • What should our vertex shader hold?! • Just holding a position and a color!
  • 43. HLSL – Vertex Format struct MyOwnVertexFormat { private Vector3 position; private Color color; public MyOwnVertexFormat (Vector3 position, Color color) { this.position = position; this.color = color; } }
  • 44. struct MyOwnVertexFormat { private Vector3 position; private Color color; public MyOwnVertexFormat (Vector3 position, Color color) { this.position = position; this.color = color; } } HLSL – Vertex Format
  • 45. HLSL – Vertex Format • Now, since we are dealing with the graphics card , • the graphics card needs to be told explicitly which data it will receive.
  • 46. HLSL – Vertex Format • Adding the following code to our struct public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) );
  • 47. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 48. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 49. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 50. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 51. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 52. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 53. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 54. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 55. public readonly static VertexDeclaration VertexDeclaration = new VertexDeclaration ( new VertexElement( 0, VertexElementFormat.Vector3, VertexElementUsage.Position, 0), new VertexElement( sizeof(float) * 3, VertexElementFormat.Color, VertexElementUsage.Color, 0) ); HLSL – Vertex Format • Adding the following code to our struct
  • 56. HLSL – Vertex Format • Now, Implementing it in our XNA code! private void SetUpVertices() { MyOwnVertexFormat[] vertices = new MyOwnVertexFormat[3]; vertices[0] = new MyOwnVertexFormat(new Vector3(-2, 2, 0), Color.Red); vertices[1] = new MyOwnVertexFormat(new Vector3(2, -2, -2), Color.Green); vertices[2] = new MyOwnVertexFormat(new Vector3(0, 0, 2), Color.Yellow); vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); }
  • 57. HLSL – Vertex Format • Now, Implementing it in our XNA code! private void SetUpVertices() { MyOwnVertexFormat[] vertices = new MyOwnVertexFormat[3]; vertices[0] = new MyOwnVertexFormat(new Vector3(-2, 2, 0), Color.Red); vertices[1] = new MyOwnVertexFormat(new Vector3(2, -2, -2), Color.Green); vertices[2] = new MyOwnVertexFormat(new Vector3(0, 0, 2), Color.Yellow); vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); }
  • 58. HLSL – Vertex Format • “App1-VertexFormat”
  • 59. HLSL – Vertex Shader • Create a new empty effect file, name it(OurHLSLfile.fx)
  • 60. HLSL – Vertex Shader • Create a new empty effect file, name it(OurHLSLfile.fx) • Delete everything in it!
  • 61. HLSL – Vertex Shader • Create a new empty effect file, name it(OurHLSLfile.fx) • Delete everything in it!
  • 62. HLSL – Vertex Shader • Create a new empty effect file, name it(OurHLSLfile.fx) • Delete everything in it!
  • 63. HLSL – Vertex Shader • Create a new empty effect file, name it(OurHLSLfile.fx) • Delete everything in it!
  • 64. HLSL – Vertex Shader • Put this as your first HLSL code in your.fx file technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 65. HLSL – Vertex Shader • Put this as your first HLSL code in your.fx file technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 66. HLSL – Vertex Shader • Put this as your first HLSL code in your.fx file technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 67. HLSL – Vertex Shader • Put this as your first HLSL code in your.fx file technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 68. HLSL – Vertex Shader • Put this as your first HLSL code in your.fx file technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 69. HLSL – Vertex Shader
  • 70. HLSL – Vertex Shader • So put this code at the top of your.fx file: struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; };
  • 71. HLSL – Vertex Shader • So put this code at the top of your.fx file: struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; };
  • 72. HLSL – Vertex Shader • So put this code at the top of your.fx file: • Now, Place this method between the structure definition and our technique definition: struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; }
  • 73. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 74. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 75. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 76. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 77. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 78. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 79. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 80. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 81. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 82. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 83. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 84. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 85. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 86. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } } Output.Color.rba = 1.0f; Output.Color.g = 0.0f;
  • 87. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 88. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 89. HLSL – Vertex Shader • The hole code for now will be struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 90. HLSL – Vertex Shader • FINALLY!
  • 91. HLSL – Vertex Shader • float4x4 xViewProjection;
  • 92. HLSL – Vertex Shader • float4x4 xViewProjection;
  • 93. HLSL – Vertex Shader
  • 94. float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = NULL; } }
  • 95. HLSL – Vertex Shader • NICE! • “App3-CompleteFirstShader(White)” • For more info – http://www.riemers.net/eng/Tutorials/XNA/Csharp/series3.php
  • 96. Pixel Format and Pixel Shader
  • 99. Pixel Shader • We have the our last lesson Vertex Shader up and running, we just need a Pixel Shader now to get the job done and draw using our own custom way of rendering! • The pixel shader receives its input (position and color, in our case) from our vertex shader, and needs to output only color
  • 100. Pixel Shader • So let’s define its output structure at the top of our.fx file “Pixel Format” struct PixelToFrame { float4 Color : COLOR0; };
  • 101. Pixel Shader • So let’s define its output structure at the top of our.fx file “Pixel Format” • Our first pixel shader will be a very simple method, here it is “Pixel Shader” struct PixelToFrame { float4 Color : COLOR0; }; PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; }
  • 102. Pixel Shader • So let’s define its output structure at the top of our.fx file “Pixel Format” • Our first pixel shader will be a very simple method, here it is “Pixel Shader” struct PixelToFrame { float4 Color : COLOR0; }; PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; }
  • 103. Pixel Shader • Now we still need to set this method as pixel shader for our technique, at the bottom of the file: PixelShader = compile ps_2_0 OurFirstPixelShader();
  • 104. Pixel Shader • Now we still need to set this method as pixel shader for our technique, at the bottom of the file: PixelShader = compile ps_2_0 OurFirstPixelShader(); technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 105. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } The hole code in HLSL file
  • 106. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 107. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 108. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 109. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 110. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 111. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 112. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 113. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 114. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 115. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 116. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; }
  • 117. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; }
  • 118. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } }
  • 119. Pixel Shader • Now, let’s use our own HLSL code in our XNA code!
  • 120. Pixel Shader • Loading our own effect file “OurHLSLfile” effect = Content.Load<Effect> ("OurHLSLfile");
  • 121. Pixel Shader • Draw() method protected override void Draw(GameTime gameTime) { device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.DarkSlateBlue, 1.0f, 0); effect.CurrentTechnique = effect.Techniques["Simplest"]; effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(vertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); } base.Draw(gameTime); }
  • 122. Pixel Shader • Draw() methodprotected override void Draw(GameTime gameTime) { device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.DarkSlateBlue, 1.0f, 0); effect.CurrentTechnique = effect.Techniques["Simplest"]; effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(vertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); } base.Draw(gameTime); }
  • 123. Pixel Shader • Draw() methodprotected override void Draw(GameTime gameTime) { device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.DarkSlateBlue, 1.0f, 0); effect.CurrentTechnique = effect.Techniques["Simplest"]; effect.Parameters["xViewProjection"].SetValue(viewMatrix * projectionMatrix); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(vertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleList, 0, 1); } base.Draw(gameTime); }
  • 124. Pixel Shader • We did it out own! • We told the GPU how to work! • “App2-CompleteFirstShader(Colored)”
  • 126. Pixel Shader float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; }; VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } VertexToPixel SimplestVertexShader(float4 inPos : POSITION) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = 1.0f; return Output; }
  • 127. Pixel Shader • NICE! • “App3-CompleteFirstShader(White)”