SlideShare a Scribd company logo
1 of 85
Download to read offline
Mohammad Shaker
mohammadshaker.com
@ZGTRShaker
2011, 2012, 2013, 2014
XNA Game Development
L11 – Shaders Part 2
Experimenting With Shaders
Experimenting With Shaders
Notice the rasterizer
between the vertex and
the pixel shader
This rasterizer determines
which pixels on the screen are
occupied by our triangle, and
makes sure these pixels are
also sent to the pixel shader.
Without this rasterizer,
only the 3 points
corresponding to the
vertices would be sent to
the pixel shader!!
The interpolator next to
the rasterizer calculates
this value, by interpolating
the color value of the
corner points.
This means that a pixel
exactly in the middle
between a blue and a red
corner point, will get the
color that is exactly in the
middle of these colors.
It will look like?!
This!
Nice!
With HLSL,
you could change the
position or color of each
vertex by all means!
You could also do this
in your XNA app, but
then your CPU would
have to perform those
calculations, which
would lower your
framerate!
Now you can have these
calculations done by the
GPU, which is A LOT faster
at it, leaving your CPU free
to perform more important
calculations
As you have seen,
Using the vertex shader,
you could also adjust
the color, which we’ve
done before (we made
our whole triangle
white)
So for this example, we will throw away
the color information provided to us by the
vertex stream, and define our own colors.
Say, we want our vertex shader make the
red color component indicate the X
coordinate of each vertex, the green
component the Y coordinate, and the blue
color component indicate the z coordinate.
Which is this output!
Let’s go!
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
Output.Color = inColor;
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
– With this one
Output.Color = inColor;
Output.Color.rgb = inPos.xyz;
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
– With this one
Output.Color = inColor;
Output.Color.rgb = inPos.xyz;
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
– With this one
Output.Color = inColor;
Output.Color.rgb = inPos.xyz;
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
– With this one
Output.Color = inColor;
Output.Color.rgb = inPos.xyz;
Experimenting With Shaders
• Go to our last HLSL file “.fx”
– Replace the following line
– With this one
Output.Color = inColor;
Output.Color.rgb = inPos.xyz;
Experimenting With Shaders
• Now, Compile and run to see the following
• “App4-NotGoodInterpolation”
Experimenting With Shaders
• Now, Compile and run to see the following
Experimenting With Shaders
• Now, Compile and run to see the following
Experimenting With Shaders
• Now, Compile and run to see the following
Experimenting With Shaders
• So what is happening?
• Before the colors are passed to the interpolator, the
3 color values of the 3 vertices are being clipped to
the [0,1] region. For example, the (-2,-2,2) vertex
should have -2, -2 and 2 as rgb color values, but it
gets 0, 0 and 1 as color values
Experimenting With Shaders
• So what is happening?
• The (0,0,0) point gets a color value that is an
interpolation of color values between the [0,1]
region, and thus will never be completely 0,0,0
(=black).
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color.rgb = inPos.xyz;
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();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color.rgb = inPos.xyz;
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();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
Experimenting With Shaders
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color.rgb = inPos.xyz;
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();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
Output.Position3D = inPos;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
Output.Color.rgb = PSIn.Position3D.xyz;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = compile ps_2_0 OurFirstPixelShader();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
float3 Position3D : TEXCOORD0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
Output.Position3D = inPos;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
Output.Color.rgb = PSIn.Position3D.xyz;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = compile ps_2_0 OurFirstPixelShader();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
float3 Position3D : TEXCOORD0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
Output.Position3D = inPos;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
Output.Color.rgb = PSIn.Position3D.xyz;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = compile ps_2_0 OurFirstPixelShader();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
float3 Position3D : TEXCOORD0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
VertexToPixel SimplestVertexShader( float4 inPos : POSITION,
float4 inColor : COLOR0)
{ VertexToPixel Output = (VertexToPixel)0;
Output.Position = mul(inPos, xViewProjection);
Output.Color = inColor;
Output.Position3D = inPos;
return Output;
}
PixelToFrame OurFirstPixelShader(VertexToPixel PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
Output.Color = PSIn.Color;
Output.Color.rgb = PSIn.Position3D.xyz;
return Output;
}
technique Simplest
{
pass Pass0
{
VertexShader = compile vs_2_0 SimplestVertexShader();
PixelShader = compile ps_2_0 OurFirstPixelShader();
}
}
float4x4 xViewProjection;
struct VertexToPixel
{
float4 Position : POSITION;
float4 Color : COLOR0;
float3 Position3D : TEXCOORD0;
};
struct PixelToFrame
{
float4 Color : COLOR0;
};
Experimenting With Shaders
• “App5-GoodInterpolation”
Shaders - Samples
Shaders - Samples
• Texturing our triangle using the Pixel Shader
• Read more
– http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Textured_triangle.php
Shaders - Samples
• A logical next step would be to load a texture from within our XNA app, and have our
pixel shader sample the correct color for each pixel.
Shaders - Samples
• In Game1 class
struct MyOwnVertexFormat
{
private Vector3 position;
private Vector2 texCoord;
public MyOwnVertexFormat(Vector3 position, Vector2 texCoord)
{
this.position = position;
this.texCoord = texCoord;
}
}
Shaders - Samples
• At the top of our effects - HLSL file
sampler TextureSampler = sampler_state
{
texture = <xTexture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter=LINEAR;
AddressU = mirror;
AddressV = mirror;
};
Shaders - Samples
• Higher performance by using Triangle Strips
• Read more
– http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Triangle_strip.php
Shaders - Samples
• Acting consciously and sneaky :D
Shaders - Samples
• Acting consciously and sneaky :D
Shaders - Samples
Shaders - Samples
• CLEVER!
Shaders - Samples
• CLEVER!
Shaders - Samples
• CLEVER!
Only 12 vertices are needed to
define 10 triangles!
Shaders - Samples
Shaders - Samples
• Creating your first light
• Read more
– http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Per-pixel_lighting.php
Shaders - Samples
• Every object is lit by an amount of light, which depends on the angle between the normal
and the direction of the light.
Shaders - Samples
• Every object is lit by an amount of light, which depends on the angle between the normal
and the direction of the light.
• This is found by taking the dot product between that object’s normal and the direction of
the incoming light.
Shaders - Samples
float DotProduct(float3 lightPos, float3 pos3D, float3 normal)
{
float3 lightDir = normalize(pos3D - lightPos);
return dot(-lightDir, normal);
}
Shaders - Samples
struct VertexToPixel
{
float4 Position : POSITION;
float2 TexCoords : TEXCOORD0;
float3 Normal : TEXCOORD1;
float3 Position3D : TEXCOORD2;
};
Shaders - Samples
Output.Normal = normalize(mul(inNormal, (float3x3)xWorld));
Output.Position3D = mul(inPos, xWorld);
Shaders - Samples
Shaders - Samples
• Shadow Mapping
Shaders - Samples
• Shadow Mapping algorithm
• Read more:
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shadow_map.php
Shaders - Samples
• Shadow Mapping algorithm
Shaders - Samples
private void DrawScene(string technique)
{
effect.CurrentTechnique = effect.Techniques[technique];
effect.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity * viewMatrix * projectionMatrix);
effect.Parameters["xTexture"].SetValue(streetTexture);
effect.Parameters["xWorld"].SetValue(Matrix.Identity);
effect.Parameters["xLightPos"].SetValue(lightPos);
effect.Parameters["xLightPower"].SetValue(lightPower);
effect.Parameters["xAmbient"].SetValue(ambientPower);
effect.Parameters["xLightsWorldViewProjection"].SetValue(Matrix.Identity *
lightsViewProjectionMatrix);
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
device.SetVertexBuffer(vertexBuffer);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 16);
}
Shaders - Samples
• Transforming vertices to texture space using Projective Texturing
• Reading more
– http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Projective_texturing.php
Shaders - Samples
Shaders - Samples
• Changing the shape of our light
• Reading more
http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shaping_the_light.php
Shaders - Samples
Shaders - Samples
• Post-Processing Shaders
• Read more
– http://rbwhitaker.wikidot.com/post-processing-effects
Shaders - Samples
• Post-Processing Shaders
float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0
{
float4 color = tex2D(TextureSampler, TextureCoordinate);
float value = (color.r + color.g + color.b) / 3;
color.r = value;
color.g = value;
color.b = value;
return color;
}
Shaders - Samples
Shaders - Samples
• Post-Processing Shaders
float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0
{
float4 color = tex2D(TextureSampler, TextureCoordinate);
float4 outputColor = color;
outputColor.r = (color.r * 0.393) + (color.g * 0.769) + (color.b * 0.189);
outputColor.g = (color.r * 0.349) + (color.g * 0.686) + (color.b * 0.168);
outputColor.b = (color.r * 0.272) + (color.g * 0.534) + (color.b * 0.131);
return outputColor;
}
Shaders - Samples
Shaders - Samples
• Transparency
• Read more
– http://rbwhitaker.wikidot.com/transparency-shader
Shaders - Samples
technique Technique1
{
pass Pass1
{
AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;
VertexShader = compile vs_1_1 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
Shaders - Samples
VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(input.Position, World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);
float4 normal = normalize(mul(input.Normal, WorldInverseTranspose));
float lightIntensity = dot(normal, DiffuseLightDirection);
output.Color = saturate(DiffuseColor * DiffuseIntensity * lightIntensity);
output.Normal = normal;
output.TextureCoordinate = input.TextureCoordinate;
return output;
}
Shaders - Samples
• Creating a Toon Shader
• Read more
– http://rbwhitaker.wikidot.com/toon-shader
Shaders - Samples
• Intensity
• Light
• Normals
Shaders - Samples
• Intensity
• Light
• Normals
• Then, SHADING!
Shaders - Samples
• Reflection Shader
• Read more
– http://rbwhitaker.wikidot.com/reflection-shader
Shaders - Samples
• Creating a Diffuse Lighting Shader
• Read more
– http://rbwhitaker.wikidot.com/diffuse-lighting-shader
We Are Done For Today!
End of Course!
Take a Look on my other courses
@ http://www.slideshare.net/ZGTRZGTR
Available courses to the date of this slide:
http://www.mohammadshaker.com
mohammadshakergtr@gmail.com
https://twitter.com/ZGTRShaker @ZGTRShaker
https://de.linkedin.com/pub/mohammad-shaker/30/122/128/
http://www.slideshare.net/ZGTRZGTR
https://www.goodreads.com/user/show/11193121-mohammad-shaker
https://plus.google.com/u/0/+MohammadShaker/
https://www.youtube.com/channel/UCvJUfadMoEaZNWdagdMyCRA
http://mohammadshakergtr.wordpress.com/
XNA L11–Shaders Part 2

More Related Content

What's hot

Pythonic Graphics
Pythonic GraphicsPythonic Graphics
Pythonic GraphicsKirby Urner
 
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 2014Cyrille Martraire
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionTill Nagel
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Jay Coskey
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadOliver Daff
 
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...Philip Schwarz
 
Monad Transformers In The Wild
Monad Transformers In The WildMonad Transformers In The Wild
Monad Transformers In The WildStackMob Inc
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class PatternsJohn De Goes
 
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsQuark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsJohn De Goes
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocamlpramode_ce
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better JavaGarth Gilmour
 
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
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_applicationNaoki Aoyama
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFDror Bereznitsky
 

What's hot (17)

Pythonic Graphics
Pythonic GraphicsPythonic Graphics
Pythonic Graphics
 
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
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 Introduction
 
Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2Intro to Python (High School) Unit #2
Intro to Python (High School) Unit #2
 
Functor, Apply, Applicative And Monad
Functor, Apply, Applicative And MonadFunctor, Apply, Applicative And Monad
Functor, Apply, Applicative And Monad
 
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
Game of Life - Polyglot FP - Haskell, Scala, Unison - Part 2 - with minor cor...
 
Monad Transformers In The Wild
Monad Transformers In The WildMonad Transformers In The Wild
Monad Transformers In The Wild
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
 
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & AnalyticsQuark: A Purely-Functional Scala DSL for Data Processing & Analytics
Quark: A Purely-Functional Scala DSL for Data Processing & Analytics
 
Introduction to functional programming using Ocaml
Introduction to functional programming using OcamlIntroduction to functional programming using Ocaml
Introduction to functional programming using Ocaml
 
Kotlin as a Better Java
Kotlin as a Better JavaKotlin as a Better Java
Kotlin as a Better Java
 
C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1 C++ Windows Forms L08 - GDI P1
C++ Windows Forms L08 - GDI P1
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_application
 
Fantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOFFantom on the JVM Devoxx09 BOF
Fantom on the JVM Devoxx09 BOF
 

Viewers also liked

C# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPC# Advanced L09-HTML5+ASP
C# Advanced L09-HTML5+ASPMohammad Shaker
 
Indie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieIndie Series 03: Becoming an Indie
Indie Series 03: Becoming an IndieMohammad 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 EnvironmentMohammad Shaker
 
C# Starter L07-Objects Cloning
C# Starter L07-Objects CloningC# Starter L07-Objects Cloning
C# Starter L07-Objects CloningMohammad 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 AnimationMohammad Shaker
 
C# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationC# Advanced L10-Workflow Foundation
C# Advanced L10-Workflow FoundationMohammad 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 TemplatesMohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
C# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFC# Advanced L08-Networking+WCF
C# Advanced L08-Networking+WCFMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad 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 MethodsMohammad 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 SystemsMohammad 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)

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
 
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
 
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
 
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
 
OpenGL Starter L02
OpenGL Starter L02OpenGL Starter L02
OpenGL Starter L02
 
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 L11–Shaders Part 2

Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksJinTaek Seo
 
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!Unity Technologies Japan K.K.
 
Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko3D
 
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)Igalia
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLDouglass Turner
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenBenjamin Glatzel
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingSteven Tovey
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Ki Hyunwoo
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfShaiAlmog1
 
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksJinTaek Seo
 
Write a Java program that creates a drawing area of appropriate size.pdf
Write a Java program that creates a drawing area of appropriate size.pdfWrite a Java program that creates a drawing area of appropriate size.pdf
Write a Java program that creates a drawing area of appropriate size.pdfboothlynntur11512
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonAMD Developer Central
 
GSP 215 Enhance teaching/tutorialrank.com
 GSP 215 Enhance teaching/tutorialrank.com GSP 215 Enhance teaching/tutorialrank.com
GSP 215 Enhance teaching/tutorialrank.comjonhson300
 
GSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.comGSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.comjonhson129
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi andKellyn Pot'Vin-Gorman
 
Rendering basics
Rendering basicsRendering basics
Rendering basicsicedmaster
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.comHarrisGeorg21
 
C# v8 new features - raimundas banevicius
C# v8 new features - raimundas baneviciusC# v8 new features - raimundas banevicius
C# v8 new features - raimundas baneviciusRaimundas Banevičius
 

Similar to XNA L11–Shaders Part 2 (20)

Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
【Unite 2017 Tokyo】シェーダープログラミング入門!カスタムシェーダー、作るで!
 
Minko stage3d workshop_20130525
Minko stage3d workshop_20130525Minko stage3d workshop_20130525
Minko stage3d workshop_20130525
 
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)VkRunner: a Vulkan shader test tool (FOSDEM 2019)
VkRunner: a Vulkan shader test tool (FOSDEM 2019)
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSL
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 
Volumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the FallenVolumetric Lighting for Many Lights in Lords of the Fallen
Volumetric Lighting for Many Lights in Lords of the Fallen
 
A Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time LightingA Bizarre Way to do Real-Time Lighting
A Bizarre Way to do Real-Time Lighting
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
 
Creating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdfCreating an Uber Clone - Part IV - Transcript.pdf
Creating an Uber Clone - Part IV - Transcript.pdf
 
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
 
Write a Java program that creates a drawing area of appropriate size.pdf
Write a Java program that creates a drawing area of appropriate size.pdfWrite a Java program that creates a drawing area of appropriate size.pdf
Write a Java program that creates a drawing area of appropriate size.pdf
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
GSP 215 Enhance teaching/tutorialrank.com
 GSP 215 Enhance teaching/tutorialrank.com GSP 215 Enhance teaching/tutorialrank.com
GSP 215 Enhance teaching/tutorialrank.com
 
GSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.comGSP 215 Inspiring Innovation/tutorialrank.com
GSP 215 Inspiring Innovation/tutorialrank.com
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
Rendering basics
Rendering basicsRendering basics
Rendering basics
 
Sdl Basic
Sdl BasicSdl Basic
Sdl Basic
 
Gsp 215 Effective Communication / snaptutorial.com
Gsp 215  Effective Communication / snaptutorial.comGsp 215  Effective Communication / snaptutorial.com
Gsp 215 Effective Communication / snaptutorial.com
 
C# v8 new features - raimundas banevicius
C# v8 new features - raimundas baneviciusC# v8 new features - raimundas banevicius
C# v8 new features - raimundas banevicius
 

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 GraduateMohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad 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 AdaptersMohammad Shaker
 
Indie Series 01: Intro to Games
Indie Series 01: Intro to GamesIndie Series 01: Intro to Games
Indie Series 01: Intro to GamesMohammad 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 SyncSevenMohammad 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 GamesMohammad Shaker
 
Roboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringRoboconf DSL Advanced Software Engineering
Roboconf DSL Advanced Software EngineeringMohammad 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

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

XNA L11–Shaders Part 2

  • 1. Mohammad Shaker mohammadshaker.com @ZGTRShaker 2011, 2012, 2013, 2014 XNA Game Development L11 – Shaders Part 2
  • 4. Notice the rasterizer between the vertex and the pixel shader
  • 5. This rasterizer determines which pixels on the screen are occupied by our triangle, and makes sure these pixels are also sent to the pixel shader.
  • 6. Without this rasterizer, only the 3 points corresponding to the vertices would be sent to the pixel shader!!
  • 7. The interpolator next to the rasterizer calculates this value, by interpolating the color value of the corner points.
  • 8. This means that a pixel exactly in the middle between a blue and a red corner point, will get the color that is exactly in the middle of these colors.
  • 9. It will look like?!
  • 10. This!
  • 11. Nice!
  • 12. With HLSL, you could change the position or color of each vertex by all means!
  • 13. You could also do this in your XNA app, but then your CPU would have to perform those calculations, which would lower your framerate!
  • 14. Now you can have these calculations done by the GPU, which is A LOT faster at it, leaving your CPU free to perform more important calculations
  • 15. As you have seen, Using the vertex shader, you could also adjust the color, which we’ve done before (we made our whole triangle white)
  • 16. So for this example, we will throw away the color information provided to us by the vertex stream, and define our own colors. Say, we want our vertex shader make the red color component indicate the X coordinate of each vertex, the green component the Y coordinate, and the blue color component indicate the z coordinate.
  • 17. Which is this output!
  • 19. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line Output.Color = inColor;
  • 20. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line – With this one Output.Color = inColor; Output.Color.rgb = inPos.xyz;
  • 21. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line – With this one Output.Color = inColor; Output.Color.rgb = inPos.xyz;
  • 22. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line – With this one Output.Color = inColor; Output.Color.rgb = inPos.xyz;
  • 23. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line – With this one Output.Color = inColor; Output.Color.rgb = inPos.xyz;
  • 24. Experimenting With Shaders • Go to our last HLSL file “.fx” – Replace the following line – With this one Output.Color = inColor; Output.Color.rgb = inPos.xyz;
  • 25. Experimenting With Shaders • Now, Compile and run to see the following • “App4-NotGoodInterpolation”
  • 26. Experimenting With Shaders • Now, Compile and run to see the following
  • 27. Experimenting With Shaders • Now, Compile and run to see the following
  • 28. Experimenting With Shaders • Now, Compile and run to see the following
  • 29. Experimenting With Shaders • So what is happening? • Before the colors are passed to the interpolator, the 3 color values of the 3 vertices are being clipped to the [0,1] region. For example, the (-2,-2,2) vertex should have -2, -2 and 2 as rgb color values, but it gets 0, 0 and 1 as color values
  • 30. Experimenting With Shaders • So what is happening? • The (0,0,0) point gets a color value that is an interpolation of color values between the [0,1] region, and thus will never be completely 0,0,0 (=black).
  • 31. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color.rgb = inPos.xyz; 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(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 32. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color.rgb = inPos.xyz; 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(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 35. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color.rgb = inPos.xyz; 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(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 36. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; Output.Position3D = inPos; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; Output.Color.rgb = PSIn.Position3D.xyz; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; float3 Position3D : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 37. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; Output.Position3D = inPos; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; Output.Color.rgb = PSIn.Position3D.xyz; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; float3 Position3D : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 38. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; Output.Position3D = inPos; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; Output.Color.rgb = PSIn.Position3D.xyz; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; float3 Position3D : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 39. Experimenting With Shaders VertexToPixel SimplestVertexShader( float4 inPos : POSITION, float4 inColor : COLOR0) { VertexToPixel Output = (VertexToPixel)0; Output.Position = mul(inPos, xViewProjection); Output.Color = inColor; Output.Position3D = inPos; return Output; } PixelToFrame OurFirstPixelShader(VertexToPixel PSIn) { PixelToFrame Output = (PixelToFrame)0; Output.Color = PSIn.Color; Output.Color.rgb = PSIn.Position3D.xyz; return Output; } technique Simplest { pass Pass0 { VertexShader = compile vs_2_0 SimplestVertexShader(); PixelShader = compile ps_2_0 OurFirstPixelShader(); } } float4x4 xViewProjection; struct VertexToPixel { float4 Position : POSITION; float4 Color : COLOR0; float3 Position3D : TEXCOORD0; }; struct PixelToFrame { float4 Color : COLOR0; };
  • 40. Experimenting With Shaders • “App5-GoodInterpolation”
  • 42. Shaders - Samples • Texturing our triangle using the Pixel Shader • Read more – http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Textured_triangle.php
  • 43. Shaders - Samples • A logical next step would be to load a texture from within our XNA app, and have our pixel shader sample the correct color for each pixel.
  • 44. Shaders - Samples • In Game1 class struct MyOwnVertexFormat { private Vector3 position; private Vector2 texCoord; public MyOwnVertexFormat(Vector3 position, Vector2 texCoord) { this.position = position; this.texCoord = texCoord; } }
  • 45. Shaders - Samples • At the top of our effects - HLSL file sampler TextureSampler = sampler_state { texture = <xTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror; };
  • 46. Shaders - Samples • Higher performance by using Triangle Strips • Read more – http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Triangle_strip.php
  • 47. Shaders - Samples • Acting consciously and sneaky :D
  • 48. Shaders - Samples • Acting consciously and sneaky :D
  • 52. Shaders - Samples • CLEVER! Only 12 vertices are needed to define 10 triangles!
  • 54. Shaders - Samples • Creating your first light • Read more – http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Per-pixel_lighting.php
  • 55. Shaders - Samples • Every object is lit by an amount of light, which depends on the angle between the normal and the direction of the light.
  • 56. Shaders - Samples • Every object is lit by an amount of light, which depends on the angle between the normal and the direction of the light. • This is found by taking the dot product between that object’s normal and the direction of the incoming light.
  • 57. Shaders - Samples float DotProduct(float3 lightPos, float3 pos3D, float3 normal) { float3 lightDir = normalize(pos3D - lightPos); return dot(-lightDir, normal); }
  • 58. Shaders - Samples struct VertexToPixel { float4 Position : POSITION; float2 TexCoords : TEXCOORD0; float3 Normal : TEXCOORD1; float3 Position3D : TEXCOORD2; };
  • 59. Shaders - Samples Output.Normal = normalize(mul(inNormal, (float3x3)xWorld)); Output.Position3D = mul(inPos, xWorld);
  • 61. Shaders - Samples • Shadow Mapping
  • 62. Shaders - Samples • Shadow Mapping algorithm • Read more: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shadow_map.php
  • 63. Shaders - Samples • Shadow Mapping algorithm
  • 64. Shaders - Samples private void DrawScene(string technique) { effect.CurrentTechnique = effect.Techniques[technique]; effect.Parameters["xWorldViewProjection"].SetValue(Matrix.Identity * viewMatrix * projectionMatrix); effect.Parameters["xTexture"].SetValue(streetTexture); effect.Parameters["xWorld"].SetValue(Matrix.Identity); effect.Parameters["xLightPos"].SetValue(lightPos); effect.Parameters["xLightPower"].SetValue(lightPower); effect.Parameters["xAmbient"].SetValue(ambientPower); effect.Parameters["xLightsWorldViewProjection"].SetValue(Matrix.Identity * lightsViewProjectionMatrix); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(vertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 16); }
  • 65. Shaders - Samples • Transforming vertices to texture space using Projective Texturing • Reading more – http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Projective_texturing.php
  • 67. Shaders - Samples • Changing the shape of our light • Reading more http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Shaping_the_light.php
  • 69. Shaders - Samples • Post-Processing Shaders • Read more – http://rbwhitaker.wikidot.com/post-processing-effects
  • 70. Shaders - Samples • Post-Processing Shaders float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float value = (color.r + color.g + color.b) / 3; color.r = value; color.g = value; color.b = value; return color; }
  • 72. Shaders - Samples • Post-Processing Shaders float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); float4 outputColor = color; outputColor.r = (color.r * 0.393) + (color.g * 0.769) + (color.b * 0.189); outputColor.g = (color.r * 0.349) + (color.g * 0.686) + (color.b * 0.168); outputColor.b = (color.r * 0.272) + (color.g * 0.534) + (color.b * 0.131); return outputColor; }
  • 74. Shaders - Samples • Transparency • Read more – http://rbwhitaker.wikidot.com/transparency-shader
  • 75. Shaders - Samples technique Technique1 { pass Pass1 { AlphaBlendEnable = TRUE; DestBlend = INVSRCALPHA; SrcBlend = SRCALPHA; VertexShader = compile vs_1_1 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }
  • 76. Shaders - Samples VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; float4 worldPosition = mul(input.Position, World); float4 viewPosition = mul(worldPosition, View); output.Position = mul(viewPosition, Projection); float4 normal = normalize(mul(input.Normal, WorldInverseTranspose)); float lightIntensity = dot(normal, DiffuseLightDirection); output.Color = saturate(DiffuseColor * DiffuseIntensity * lightIntensity); output.Normal = normal; output.TextureCoordinate = input.TextureCoordinate; return output; }
  • 77. Shaders - Samples • Creating a Toon Shader • Read more – http://rbwhitaker.wikidot.com/toon-shader
  • 78. Shaders - Samples • Intensity • Light • Normals
  • 79. Shaders - Samples • Intensity • Light • Normals • Then, SHADING!
  • 80. Shaders - Samples • Reflection Shader • Read more – http://rbwhitaker.wikidot.com/reflection-shader
  • 81. Shaders - Samples • Creating a Diffuse Lighting Shader • Read more – http://rbwhitaker.wikidot.com/diffuse-lighting-shader
  • 82. We Are Done For Today! End of Course!
  • 83. Take a Look on my other courses @ http://www.slideshare.net/ZGTRZGTR Available courses to the date of this slide: