Properly support light shaders in GLES2, fixes #21651
This commit is contained in:
parent
a06f8ca6b9
commit
aa819a8538
2 changed files with 17 additions and 14 deletions
|
@ -364,14 +364,14 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() {
|
||||||
strings.push_back(fragment_code1.get_data());
|
strings.push_back(fragment_code1.get_data());
|
||||||
|
|
||||||
if (cc) {
|
if (cc) {
|
||||||
code_string = cc->fragment.ascii();
|
code_string = cc->light.ascii();
|
||||||
strings.push_back(code_string.get_data());
|
strings.push_back(code_string.get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
strings.push_back(fragment_code2.get_data());
|
strings.push_back(fragment_code2.get_data());
|
||||||
|
|
||||||
if (cc) {
|
if (cc) {
|
||||||
code_string2 = cc->light.ascii();
|
code_string2 = cc->fragment.ascii();
|
||||||
strings.push_back(code_string2.get_data());
|
strings.push_back(code_string2.get_data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,22 +588,24 @@ void ShaderGLES2::setup(
|
||||||
fragment_code0 = code.substr(0, cpos).ascii();
|
fragment_code0 = code.substr(0, cpos).ascii();
|
||||||
code = code.substr(cpos + globals_tag.length(), code.length());
|
code = code.substr(cpos + globals_tag.length(), code.length());
|
||||||
|
|
||||||
cpos = code.find(code_tag);
|
cpos = code.find(light_code_tag);
|
||||||
|
|
||||||
if (cpos == -1) {
|
String code2;
|
||||||
fragment_code1 = code.ascii();
|
|
||||||
} else {
|
if (cpos != -1) {
|
||||||
|
|
||||||
fragment_code1 = code.substr(0, cpos).ascii();
|
fragment_code1 = code.substr(0, cpos).ascii();
|
||||||
String code2 = code.substr(cpos + code_tag.length(), code.length());
|
code2 = code.substr(cpos + light_code_tag.length(), code.length());
|
||||||
|
} else {
|
||||||
|
code2 = code;
|
||||||
|
}
|
||||||
|
|
||||||
cpos = code2.find(light_code_tag);
|
cpos = code2.find(code_tag);
|
||||||
if (cpos == -1) {
|
if (cpos == -1) {
|
||||||
fragment_code2 = code2.ascii();
|
fragment_code2 = code2.ascii();
|
||||||
} else {
|
} else {
|
||||||
fragment_code2 = code2.substr(0, cpos).ascii();
|
fragment_code2 = code2.substr(0, cpos).ascii();
|
||||||
fragment_code3 = code2.substr(cpos + light_code_tag.length(), code2.length()).ascii();
|
fragment_code3 = code2.substr(cpos + code_tag.length(), code2.length()).ascii();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1091,6 +1091,7 @@ void light_compute(
|
||||||
inout vec3 diffuse_light,
|
inout vec3 diffuse_light,
|
||||||
inout vec3 specular_light) {
|
inout vec3 specular_light) {
|
||||||
|
|
||||||
|
|
||||||
//this makes lights behave closer to linear, but then addition of lights looks bad
|
//this makes lights behave closer to linear, but then addition of lights looks bad
|
||||||
//better left disabled
|
//better left disabled
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue