Upload
jayden-fake
View
215
Download
1
Embed Size (px)
Citation preview
GraphGamegg006-Shade
árnyalás
Szécsi László
Textúrafile
• giraffe.jpg letöltése• SolutionDir/Media folderbe
gg006-Shade project
• copy-paste-rename gg005-Cam folder• vcxproj, filters átnevezés• solution/add existing project• rename project• working dir: $(SolutionDir)• Project Properties/Configuration
Properties/Debugging/Command Arguments--solutionPath:"$(SolutionDir)" --projectPath:"$(ProjectDir)"
• build, run
Új fx file
• solution fx folderbe• shaded.fx
fx/shaded.fx#include <basic.fx>
float3 lightPos = float3(1, 1, 1);float3 lightPower =
float3(50, 50, 50);float3 kd = float3(1, 0, 1); //lila
#7.0
fx/shaded.fxfloat4 psDiffuse(VsosTrafo input) : SV_Target {
float3 normal = normalize(input.normal);float3 toLight = lightPos -
input.worldPos.xyz;float3 lightDist2 = dot(toLight, toLight);float3 lightDir = normalize(toLight);return float4(
kd * saturate(dot(lightDir, normal))* lightPower / (4 * 3.14 * lightDist2), 1);
}
#7.1
fx/shaded.fx
technique11 shaded{pass diffuse{
SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) );
SetPixelShader( CompileShader( ps_5_0, psDiffuse() ) );}
}
#7.1
fx/main.fx#include <shaded.fx>// and nothing else
#7.1
Game.cppID3DX11EffectPass* basicPass = effect->GetTechniqueByName("idleshaded")->GetPassByName("idlediffuse");
Egg::Mesh::Material::P idleshadedMaterial = Egg::Mesh::Material::create(basicPass, 0);
shadedMesh = binder->bindMaterial(idleshadedMaterial, indexedMesh);
#8.0
Diffúzan árnyalt mesh
fx/shaded.fxfloat3 eyePos;
float3 ks = float3(10, 10, 10);float n = 10;
#7.1
Game::rendereffect->GetVariableByName("eyePos")->AsMatrix()->SetMatrix( (float*)&firstPersonCam->getEyePosition()
);
#8.0
fx/shaded.fxfloat4 psSpecular(VsosTrafo input) : SV_Target {
float3 normal = normalize(input.normal);float3 toLight = lightPos - input.worldPos.xyz;float3 lightDist2 = dot(toLight, toLight);float3 lightDir = normalize(toLight);float3 toEye = eyePos - input.worldPos.xyz;float3 viewDir = normalize(toEye);return float4(
(kd * saturate(dot(lightDir, normal))+ ks * pow(
saturate(dot(reflect(-viewDir, normal),lightDir)), n) )
* lightPower / (4 * 3.14 * lightDist2), 1);
}
#7.1
fx/shaded.fxtechnique11 shaded { pass diffuse { SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) );
SetPixelShader( CompileShader( ps_5_0, psDiffuse() ) );
} pass specular { SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) );
SetPixelShader( CompileShader( ps_5_0, psSpecular() ) );
}}
#7.1
Game.cppID3DX11EffectPass* basicPass = effect->GetTechniqueByName("shaded")->GetPassByName("diffusespecular");
Egg::Mesh::Material::P shadedMaterial = Egg::Mesh::Material::create(basicPass, 0);
shadedMesh = binder->bindMaterial(shadedMaterial, indexedMesh);
#8.0
Műanyagzsiráf
FELADAT
• keringő fényforrás– animate metódusban a fénypozíció újrabeállítása