textúrázás Szécsi László
giraffe.jpg letöltése SolutionDir/Media folderbe
copy-paste-rename gg006-Shade 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
class Game { ID3D11ShaderResourceView* kdSrv;
createResources() { loadEffect(); D3DX11CreateShaderResourceViewFromFileA( device, systemEnvironment.resolveMediaPath( "giraffe.jpg" ).c_str(), NULL, NULL, &kdSrv, NULL); // 1. opció: egyszer beállítás manuálisan effect->GetVariableByName("kdTexture")- >AsShaderResource()->SetResource(kdSrv);
ID3DX11EffectPass* basicPass = effect- >GetTechniqueByName("idletextured")- >GetPassByName("idletextured"); Egg::Mesh::Material::P idletexturedMaterial = Egg::Mesh::Material::create(basicPas s, 0); shadedMesh = binder- >bindMaterial(idletexturedMaterial, indexedMesh); #8.0
// 2. opció: material-beállításként texturedMaterial->set( effect ->GetVariableByName("kdTexture")) ->AsShaderResource() ->SetResource(kdSrv);
releaseResources(){ kdSrv->Release();
solution fx folderbe textured.fx
#include Texture2D kdTexture; SamplerState linearSampler { Filter = MIN_MAG_MIP_LINEAR; AddressU = Wrap; AddressV = Wrap; }; #7.0
float4 psTextured(VsosTrafo input) : SV_Target { return abs(saturate(input.normal).y) * kdTexture.Sample(linearSampler, input.tex); } technique11 textured { pass textured { SetVertexShader ( CompileShader( vs_5_0, vsTrafo() ) ); SetPixelShader( CompileShader( ps_5_0, psTextured() ) ); } #7.1
#include // and nothing else #7.1
textúrázott és árnyalt modell a textúrából jön a kd érték az árnyaláshoz