Improve bfres shaders
This commit is contained in:
parent
e1fd664112
commit
60a8cca957
@ -367,6 +367,12 @@ namespace FirstPlugin
|
||||
sphereMatrix = invertedCamera;
|
||||
sphereMatrix.Transpose();
|
||||
|
||||
invertedCamera = mvpMat.Inverted();
|
||||
Vector3 lightDirection = new Vector3(0f, 0f, -1f);
|
||||
|
||||
shader.SetVector3("specLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
|
||||
shader.SetVector3("difLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
|
||||
|
||||
shader.SetMatrix4x4("sphereMatrix", ref sphereMatrix);
|
||||
|
||||
shader.SetMatrix4x4("mtxCam", ref computedCamMtx);
|
||||
@ -380,9 +386,6 @@ namespace FirstPlugin
|
||||
shader.SetVector3("difLightColor", new Vector3(1));
|
||||
shader.SetVector3("ambLightColor", new Vector3(1));
|
||||
|
||||
|
||||
Vector3 lightDirection = new Vector3(0f, 0f, -1f);
|
||||
|
||||
GL.Enable(EnableCap.AlphaTest);
|
||||
GL.AlphaFunc(AlphaFunction.Gequal, 0.1f);
|
||||
|
||||
|
@ -38,6 +38,7 @@ uniform mat4 mtxMdl;
|
||||
uniform vec3 cameraPosition;
|
||||
|
||||
// Viewport Settings
|
||||
uniform vec3 difLightDirection;
|
||||
uniform int uvChannel;
|
||||
uniform int renderType;
|
||||
uniform int useNormalMap;
|
||||
@ -187,8 +188,7 @@ void main()
|
||||
vec3 I = vec3(0,0,-1) * mat3(mtxCam);
|
||||
vec3 V = normalize(I); // view
|
||||
vec3 R = reflect(-I, N); // reflection
|
||||
|
||||
float light = max(dot(N, V), 0.0);
|
||||
float halfLambert = dot(difLightDirection, N) * 0.5 + 0.5;
|
||||
|
||||
// Light Map
|
||||
vec4 LightMapColor = texture(BakeLightMap, f_texcoord2);
|
||||
@ -220,7 +220,7 @@ void main()
|
||||
alpha *= 0.5;
|
||||
}
|
||||
|
||||
albedo *= light;
|
||||
albedo *= halfLambert;
|
||||
|
||||
vec3 LightingDiffuse = vec3(0);
|
||||
if (HasLightMap == 1)
|
||||
|
@ -35,6 +35,8 @@ uniform vec3 light1Pos;
|
||||
const float levels = 3.0;
|
||||
|
||||
// Viewport Settings
|
||||
uniform vec3 specLightDirection;
|
||||
|
||||
uniform int uvChannel;
|
||||
uniform int renderType;
|
||||
uniform int useNormalMap;
|
||||
@ -306,17 +308,14 @@ void main()
|
||||
N = CalcBumpedNormal(normal, NormalMap, vert, 0);
|
||||
|
||||
vec3 V = normalize(I); // view
|
||||
vec3 L = normalize(objectPosition - I); // Light
|
||||
vec3 H = normalize(objectPosition + I); // half angle
|
||||
vec3 R = reflect(-I, N); // reflection
|
||||
vec3 L = normalize(specLightDirection ); // Light
|
||||
vec3 H = normalize(specLightDirection + I); // half angle
|
||||
vec3 R = reflect(I, N); // reflection
|
||||
|
||||
vec3 f0 = mix(vec3(0.04), albedo, metallic); // dialectric
|
||||
vec3 kS = FresnelSchlickRoughness(max(dot(N, V), 0.0), f0, roughness);
|
||||
vec3 kS = FresnelSchlickRoughness(max(dot(N, H), 0.0), f0, roughness);
|
||||
|
||||
|
||||
vec3 kD = 1.0 - kS;
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
BakedData ShadowBake = ShadowMapBaked(BakeShadowMap,BakeLightMap, f_texcoord1, f_texcoord2, int(bake_shadow_type),int(bake_light_type), int(bake_calc_type), N );
|
||||
|
||||
vec3 LightingDiffuse = vec3(0);
|
||||
@ -332,7 +331,6 @@ void main()
|
||||
// Diffuse pass
|
||||
vec3 diffuseIblColor = texture(irradianceMap, N).rgb;
|
||||
vec3 diffuseTerm = diffuseIblColor * albedo;
|
||||
diffuseTerm *= kD;
|
||||
diffuseTerm *= cavity;
|
||||
diffuseTerm *= ao;
|
||||
diffuseTerm *= shadow;
|
||||
@ -350,7 +348,8 @@ void main()
|
||||
vec2 envBRDF = texture(brdfLUT, vec2(max(dot(N, V), 0.0), roughness)).rg;
|
||||
vec3 brdfTerm = (kS * envBRDF.x + envBRDF.y);
|
||||
// vec3 specularTerm = specularIblColor * (kS * brdfTerm.x + brdfTerm.y) * specIntensity;
|
||||
vec3 specularTerm = specularIblColor * brdfTerm * specIntensity;
|
||||
// vec3 specularTerm = specularIblColor * brdfTerm * specIntensity;
|
||||
vec3 specularTerm = specularIblColor * kS;
|
||||
|
||||
|
||||
// Add render passes.
|
||||
@ -386,7 +385,6 @@ void main()
|
||||
{
|
||||
diffuseIblColor = texture(irradianceMap, N).rgb;
|
||||
diffuseTerm = diffuseIblColor * vec3(0.5);
|
||||
diffuseTerm *= kD;
|
||||
diffuseTerm *= cavity;
|
||||
diffuseTerm *= ao;
|
||||
diffuseTerm *= shadow;
|
||||
|
Loading…
Reference in New Issue
Block a user