Toon.shader 未找到 _light 变量
Toon.shader not finding _light var
所以我在 Apple 的 SceneKit 中加载我的自定义着色器。
- (NSDictionary *)celShading {
NSMutableDictionary *shaders = [NSMutableDictionary new];
shaders[SCNShaderModifierEntryPointFragment] =
[NSString stringWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"toon" withExtension:@"shader"]
encoding:NSUTF8StringEncoding
error:NULL];
return shaders;
}
我的自定义着色器是 toon.shader
vec3 lDir = normalize(vec3(0.1,1.0,1.0));
float dotProduct = dot(_surface.normal,lDir);
_lightingContribution.diffuse += (dotProduct * dotProduct * _light.intensity.rgb);
_lightingContribution.diffuse = floor(_lightingContribution.diffuse * 4.0) / 3.0;
vec3 halfVector = normalize(lDir + _surface.view);
dotProduct = max(0.0, pow(max(0.0, dot(_surface.normal, halfVector)), _surface.shininess));
dotProduct = floor(dotProduct * 3.0) / 3.0;
//_lightingContribution.specular += (dotProduct * _light.intensity.rgb);
_lightingContribution.specular = vec3(0,0,0);
这就是我遇到的错误。
2015-02-27 12:52:48.164 ShadeTest[4729:499612] SceneKit: error, failed to link program: ERROR: 0:64: Use of undeclared identifier '_light'
_light
结构仅在 SCNShaderModifierEntryPointLightingModel
入口点可用。
你可以看一下头文件,比SCNShadable protocol documentation详细一点。
所以我在 Apple 的 SceneKit 中加载我的自定义着色器。
- (NSDictionary *)celShading {
NSMutableDictionary *shaders = [NSMutableDictionary new];
shaders[SCNShaderModifierEntryPointFragment] =
[NSString stringWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"toon" withExtension:@"shader"]
encoding:NSUTF8StringEncoding
error:NULL];
return shaders;
}
我的自定义着色器是 toon.shader
vec3 lDir = normalize(vec3(0.1,1.0,1.0));
float dotProduct = dot(_surface.normal,lDir);
_lightingContribution.diffuse += (dotProduct * dotProduct * _light.intensity.rgb);
_lightingContribution.diffuse = floor(_lightingContribution.diffuse * 4.0) / 3.0;
vec3 halfVector = normalize(lDir + _surface.view);
dotProduct = max(0.0, pow(max(0.0, dot(_surface.normal, halfVector)), _surface.shininess));
dotProduct = floor(dotProduct * 3.0) / 3.0;
//_lightingContribution.specular += (dotProduct * _light.intensity.rgb);
_lightingContribution.specular = vec3(0,0,0);
这就是我遇到的错误。
2015-02-27 12:52:48.164 ShadeTest[4729:499612] SceneKit: error, failed to link program: ERROR: 0:64: Use of undeclared identifier '_light'
_light
结构仅在 SCNShaderModifierEntryPointLightingModel
入口点可用。
你可以看一下头文件,比SCNShadable protocol documentation详细一点。