Created
June 4, 2018 11:44
-
-
Save peted70/1c02c88fbba39c4d1d5b1a0159d024de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MeshNode::CompileAndLoadPixelShader() | |
{ | |
// Create a shader descriptor which we can use to either find the shader in the | |
// shader cache or create and add it. | |
// The hash used for lookup is generated from the shader name and defines passed | |
// when it is compiled | |
ShaderDescriptor descriptor("pbrpixel.hlsl", DevResources()); | |
auto textures = _material->Textures(); | |
// Allocate the defines map... | |
int count = textures.size(); | |
// Iterate through all textures and set them as shader resources... | |
int idx = 0; | |
for (auto txItr = textures.begin(); txItr != textures.end(); ++txItr) | |
{ | |
auto textureWrapper = txItr->second; | |
auto type = textureWrapper->Type(); | |
const char *define = defineLookup[type]; | |
descriptor.AddDefine(define); | |
idx++; | |
} | |
// Lookup and return or create the shader if necessary | |
m_pixelShaderWrapper = ShaderCache<PixelShaderWrapper>::Instance().FindOrCreateShader(descriptor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment