Skip to content

Commit

Permalink
#48 Fix shader lightmap
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Jun 29, 2023
1 parent 0cec19a commit fe18e40
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ void main(void)
float visibility = shadowSimple(shadowCoord);

float NdotL = max(dot(varWorldNormal, uLightDirection.xyz), 0.0);
vec4 directionalLightColor = NdotL * uLightColor;
vec4 directionalLightColor = NdotL * uLightColor / 3.0;
FragColor = vec4(directionalLightColor.rgb * visibility, 1.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ void main(void)
vec4 shadowCoord = uShadowMatrix * vec4(varWorldPosition, 1.0);
float visibility = shadowSimple(shadowCoord);
float NdotL = max(dot(varWorldNormal, uLightDirection.xyz), 0.0);
vec4 directionalLightColor = NdotL * uLightColor;
vec4 directionalLightColor = NdotL * uLightColor / 3.0;
FragColor = vec4(directionalLightColor.rgb * visibility, 1.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ float4 main(PS_INPUT input) : SV_TARGET
float visibility = shadowSimple(shadowCoord);

float NdotL = max(dot(input.worldNormal, uLightDirection.xyz), 0.0);
float4 directionalLightColor = NdotL * uLightColor;
float4 directionalLightColor = NdotL * uLightColor / 3.0;
return float4(directionalLightColor.rgb * visibility, 1.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ float4 main(PS_INPUT input) : SV_TARGET
float4 shadowCoord = mul(float4(input.worldPosition, 1.0), uShadowMatrix);
float visibility = shadowSimple(shadowCoord);
float NdotL = max(dot(input.worldNormal, uLightDirection.xyz), 0.0);
float4 directionalLightColor = NdotL * uLightColor;
float4 directionalLightColor = NdotL * uLightColor / 3.0;
return float4(directionalLightColor.rgb * visibility, 1.0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ vec3 SGLM(
vec3 H = normalize(worldLightDir + worldViewDir);
float NdotE = max(0.0, dot(worldNormal, H));
float specular = pow(NdotE, 100.0f * glossiness) * spec;

vec3 envSpecColor = vec3(1.0, 1.0, 1.0);

// Direction lighting
vec3 color = (directionColor * lightMultiplier) * diffuseColor;

// Direction specular
vec3 envSpecColor = vec3(1.0, 1.0, 1.0);
color += specular * specularColor * envSpecColor;

// IBL Ambient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ vec3 SGLM(
vec3 H = normalize(worldLightDir + worldViewDir);
float NdotE = max(0.0, dot(worldNormal, H));
float specular = pow(NdotE, 100.0f * glossiness) * spec;
vec3 envSpecColor = vec3(1.0, 1.0, 1.0);
vec3 color = (directionColor * lightMultiplier) * diffuseColor;
vec3 envSpecColor = vec3(1.0, 1.0, 1.0);
color += specular * specularColor * envSpecColor;
color += indirectColor * diffuseColor * indirectMultiplier / PI;
return color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ float3 SGLM(

// Direction specular
float3 envSpecColor = float3(1.0, 1.0, 1.0);
color = color + specular * specularColor * envSpecColor;
color += specular * specularColor * envSpecColor;

// IBL Ambient
color += indirectColor * diffuseColor * indirectMultiplier / PI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ float3 SGLM(
float specular = pow(NdotE, 100.0f * glossiness) * spec;
float3 color = (directionColor * lightMultiplier) * diffuseColor;
float3 envSpecColor = float3(1.0, 1.0, 1.0);
color = color + specular * specularColor * envSpecColor;
color += specular * specularColor * envSpecColor;
color += indirectColor * diffuseColor * indirectMultiplier / PI;
return color;
}
Expand Down
Binary file modified Assets/SampleModels/Gazebo/LightMapDirectional_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fe18e40

Please sign in to comment.