Skip to content

Commit

Permalink
Update material_flat_Tcolor.frag
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-baccega authored and Robadob committed May 22, 2024
1 parent 5de60dc commit 5fe5abf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions resources/material_flat_Tcolor.frag
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const uint B_DISPLACEMENT = 1<<9;
const uint B_LIGHT = 1<<10;
const uint B_REFLECTION = 1<<11;
const uint B_UNKNOWN = 1<<12;
bool has(uint check, uint bitmask) { return (bitmask&check)!=0;}
struct MaterialProperties {
vec3 ambient; //Ambient color
float opacity;
Expand All @@ -23,7 +24,6 @@ struct MaterialProperties {
float refractionIndex;
vec3 transparent; //Transparent color, multiplied with translucent light to construct final color
uint bitmask;
bool has(uint check) { return (bitmask&check)!=0;}
};
struct LightProperties {
vec3 ambient; // Aclarri
Expand Down Expand Up @@ -65,17 +65,17 @@ out vec4 fragColor;
vec3 getAmbient() {
if (bool(shaderColor)) // _materialID >= MAX_MATERIALS
return colorOverride.rgb * 0.2f;
return material[_materialID].has(B_AMBIENT) ? texture(t_ambient, texCoords).rgb : material[_materialID].ambient;
return has(B_AMBIENT, material[_materialID].bitmask) ? texture(t_ambient, texCoords).rgb : material[_materialID].ambient;
}
vec4 getDiffuse() {
if (bool(shaderColor)) // _materialID >= MAX_MATERIALS
return colorOverride;
return material[_materialID].has(B_DIFFUSE) ? texture(t_diffuse, texCoords) : vec4(material[_materialID].diffuse, 1.0f);
return has(B_DIFFUSE, material[_materialID].bitmask) ? texture(t_diffuse, texCoords) : vec4(material[_materialID].diffuse, 1.0f);
}
vec3 getSpecular() {
if (bool(shaderColor)) // _materialID >= MAX_MATERIALS
return vec3(0.5f);
return material[_materialID].has(B_SPECULAR) ? texture(t_specular, texCoords).rgb : material[_materialID].specular;
return has(B_SPECULAR, material[_materialID].bitmask) ? texture(t_specular, texCoords).rgb : material[_materialID].specular;
}
void main() {
//Calculate face normal
Expand Down Expand Up @@ -172,4 +172,4 @@ void main() {
// Discard full alpha fragments (partially removes requirement of back to front render/glblend)
if(fragColor.a<=0.0f)
discard;
}
}

0 comments on commit 5fe5abf

Please sign in to comment.