Presentation is loading. Please wait.

Presentation is loading. Please wait.

Environment mapping Szécsi László. copy-paste-rename gg007-Texture folder vcxproj, filters átnevezés solution/add existing project rename project working.

Similar presentations


Presentation on theme: "Environment mapping Szécsi László. copy-paste-rename gg007-Texture folder vcxproj, filters átnevezés solution/add existing project rename project working."— Presentation transcript:

1 Environment mapping Szécsi László

2 copy-paste-rename gg007-Texture 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

3 #include float3 eyePos; TextureCube envTexture; float4 psEnvMapped(VsosTrafo input) : SV_Target { float3 viewDir = normalize(input.worldPos - eyePos); float3 reflectionDir = reflect(viewDir, input.normal); return 0.5 * envTexture.Sample(linearSampler, reflectionDir) * kdTexture.Sample(linearSampler, input.tex); } technique11 envmapped { pass envmapped { SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) ); SetPixelShader( CompileShader( ps_5_0, psEnvMapped() ) ); } #9.0

4 #include #9.0

5 class Game { ID3D11ShaderResourceView* envTextureSrv; #10.0

6 // createResources D3DX11CreateShaderResourceViewFromFileA( device, systemEnvironment.resolveMediaPath( "cloudyNoon.dds" ).c_str(), NULL, NULL, &envSrv, NULL); effect->GetVariableByName("envTexture")- >AsShaderResource()- >SetResource(envSrv); // releaseResources envSrv->Release(); #10.1

7 ID3DX11EffectPass* basicPass = effect- >GetTechniqueByName("envmapped")- >GetPassByName("envmapped"); Egg::Mesh::Material::P envmappedMaterial = Egg::Mesh::Material::create(basicP ass, 0); shadedMesh = binder- >bindMaterial(envmappedMaterial, indexedMesh);

8 //render effect- >GetVariableByName("eyePos")- >AsVector()->SetFloatVector( (float*)&firstPersonCam- >getEyePosition());

9

10 full-viewport quad – új mesh – Mesh::Indexed::createQuad() minden pixel olyan színű amilyen irányban látszik – vsQuad – psBackground – envmapped|background pass

11 struct IaosQuad { float4 pos: POSITION; float2 tex: TEXCOORD0; }; struct VsosQuad { float4 pos: SV_POSITION; float2 tex: TEXCOORD0; float3 viewDir: TEXCOORD1; }; #11.0

12 float4x4 viewDirMatrix; VsosQuad vsQuad(IaosQuad input) { VsosQuad output = (VsosQuad)0; output.pos = input.pos; float4 hWorldPosMinusEye = mul(input.pos, viewDirMatrix); hWorldPosMinusEye /= hWorldPosMinusEye.w; output.viewDir = hWorldPosMinusEye.xyz; output.tex = input.tex; return output; } #11.1

13 float4 psBackground(VsosQuad input) : SV_Target { return envTexture.Sample(linearSampler, input.viewDir); } #11.1

14 technique11 envmapped { pass envmapped { SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) ); SetPixelShader( CompileShader( ps_5_0, psEnvMapped() ) ); } pass background { SetVertexShader ( CompileShader( vs_5_0, vsQuad() ) ); SetPixelShader( CompileShader( ps_5_0, psBackground() ) ); } #11.1

15 class Game { Egg::Mesh::Shaded::P backgroundQuad; #12.3

16 //createResources Egg::Mesh::Indexed::P indexedQuad = Egg::Mesh::Indexed::createQuad( device); ID3DX11EffectPass* backgroundPass = effect->GetTechniqueByName("envmapped")- >GetPassByName("background"); Egg::Mesh::Material::P backgroundMaterial = Egg::Mesh::Material::create( backgroundPass, 0); backgroundQuad = binder-> bindMaterial(backgroundMaterial, indexedQuad); #12.4

17 //releaseResources backgroundQuad.reset(); #12.5

18 // render effect->GetVariableByName("viewDirMatrix")->AsMatrix() ->SetMatrix( (float*)&firstPersonCam ->getViewDirMatrix() ); shadedMesh->draw(context); backgroundQuad->draw(context); #12.6

19


Download ppt "Environment mapping Szécsi László. copy-paste-rename gg007-Texture folder vcxproj, filters átnevezés solution/add existing project rename project working."

Similar presentations


Ads by Google