Shader fixes
This commit is contained in:
parent
961283dbb2
commit
52d5e04026
|
@ -196,6 +196,16 @@ void main() {
|
|||
else {
|
||||
#endif
|
||||
|
||||
#ifdef _Hair // Aniso
|
||||
if (floor(g1.a) == 2) {
|
||||
const float shinyParallel = metrough.y;
|
||||
const float shinyPerpendicular = 0.1;
|
||||
const vec3 v = vec3(0.99146, 0.11664, 0.05832);
|
||||
vec3 T = abs(dot(n, v)) > 0.99999 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, v);
|
||||
fragColor.rgb = orenNayarDiffuseBRDF(albedo, metrough.y, dotNV, dotNL, dotVH) + wardSpecular(n, h, dotNL, dotNV, dotNH, T, shinyParallel, shinyPerpendicular);
|
||||
}
|
||||
else fragColor.rgb = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, metrough.y, dotNL, dotNH, dotNV, dotVH);
|
||||
#else
|
||||
#ifdef _OrenNayar
|
||||
// Diff/glossy
|
||||
float rough = pow(metrough.y, 0.5);
|
||||
|
@ -205,18 +215,15 @@ void main() {
|
|||
#else
|
||||
fragColor.rgb = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, metrough.y, dotNL, dotNH, dotNV, dotVH);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _PolyLight
|
||||
}
|
||||
#endif
|
||||
|
||||
// Aniso spec
|
||||
// #ifdef _Aniso
|
||||
// float shinyParallel = metrough.y;
|
||||
// float shinyPerpendicular = 0.08;
|
||||
// vec3 fiberDirection = vec3(0.0, 1.0, 8.0);
|
||||
// fragColor.rgb = diffuseBRDF(albedo, metrough.y, dotNV, dotNL, dotVH, dotLV) + wardSpecular(n, h, dotNL, dotNV, dotNH, fiberDirection, shinyParallel, shinyPerpendicular);
|
||||
// #endif
|
||||
#ifdef _Hair // Aniso
|
||||
|
||||
#endif
|
||||
|
||||
fragColor.rgb *= lightColor;
|
||||
|
||||
|
|
|
@ -118,6 +118,16 @@ void main() {
|
|||
float dotNH = dot(n, h);
|
||||
float dotVH = dot(v, h);
|
||||
|
||||
#ifdef _Hair // Aniso
|
||||
if (floor(g1.a) == 2) {
|
||||
const float shinyParallel = metrough.y;
|
||||
const float shinyPerpendicular = 0.1;
|
||||
const vec3 v = vec3(0.99146, 0.11664, 0.05832);
|
||||
vec3 T = abs(dot(n, v)) > 0.99999 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, v);
|
||||
fragColor.rgb = orenNayarDiffuseBRDF(albedo, metrough.y, dotNV, dotNL, dotVH) + wardSpecular(n, h, dotNL, dotNV, dotNH, T, shinyParallel, shinyPerpendicular);
|
||||
}
|
||||
else fragColor.rgb = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, metrough.y, dotNL, dotNH, dotNV, dotVH);
|
||||
#else
|
||||
#ifdef _OrenNayar
|
||||
float facdif = min((1.0 - metrough.x) * 3.0, 1.0);
|
||||
float facspec = min(metrough.x * 3.0, 1.0);
|
||||
|
@ -125,14 +135,7 @@ void main() {
|
|||
#else
|
||||
fragColor.rgb = lambertDiffuseBRDF(albedo, dotNL) + specularBRDF(f0, metrough.y, dotNL, dotNH, dotNV, dotVH);
|
||||
#endif
|
||||
|
||||
// Aniso spec
|
||||
// #ifdef _Aniso
|
||||
// float shinyParallel = metrough.y;
|
||||
// float shinyPerpendicular = 0.08;
|
||||
// vec3 fiberDirection = vec3(0.0, 1.0, 8.0);
|
||||
// fragColor.rgb = diffuseBRDF(albedo, metrough.y, dotNV, dotNL, dotVH, dotLV) + wardSpecular(n, h, dotNL, dotNV, dotNH, fiberDirection, shinyParallel, shinyPerpendicular);
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
fragColor.rgb *= lightColor;
|
||||
|
||||
|
|
|
@ -72,26 +72,6 @@ void main() {
|
|||
const vec2 kernel9 = vec2(0.0, -1.0);
|
||||
const vec2 kernel10 = vec2(0.4999999, -0.8660254);
|
||||
const vec2 kernel11 = vec2(0.8660254, -0.5);
|
||||
// const vec2 kernel0 = vec2(1.0,0.0);
|
||||
// const vec2 kernel1 = vec2(0.9510565,0.3090169);
|
||||
// const vec2 kernel2 = vec2(0.8090169,0.5877852);
|
||||
// const vec2 kernel3 = vec2(0.5877852,0.8090169);
|
||||
// const vec2 kernel4 = vec2(0.3090169,0.9510565);
|
||||
// const vec2 kernel5 = vec2(0.0,1.0);
|
||||
// const vec2 kernel6 = vec2(-0.3090169,0.9510565);
|
||||
// const vec2 kernel7 = vec2(-0.5877852,0.8090169);
|
||||
// const vec2 kernel8 = vec2(-0.8090169,0.5877852);
|
||||
// const vec2 kernel9 = vec2(-0.9510565,0.3090169);
|
||||
// const vec2 kernel10 = vec2(-1,0);
|
||||
// const vec2 kernel11 = vec2(-0.9510565,-0.3090169);
|
||||
// const vec2 kernel12 = vec2(-0.8090169,-0.5877852);
|
||||
// const vec2 kernel13 = vec2(-0.5877852,-0.8090169);
|
||||
// const vec2 kernel14 = vec2(-0.3090169,-0.9510565);
|
||||
// const vec2 kernel15 = vec2(0.0,-1.0);
|
||||
// const vec2 kernel16 = vec2(0.3090169,-0.9510565);
|
||||
// const vec2 kernel17 = vec2(0.5877852,-0.8090169);
|
||||
// const vec2 kernel18 = vec2(0.8090169,-0.5877852);
|
||||
// const vec2 kernel19 = vec2(0.9510565,-0.3090169);
|
||||
|
||||
vec2 enc = texture(gbuffer0, texCoord).rg;
|
||||
vec3 n;
|
||||
|
@ -107,28 +87,18 @@ void main() {
|
|||
mat2 rotMat = mat2(vec2(cos(randomVec.x * PI), -sin(randomVec.x * PI)),
|
||||
vec2(sin(randomVec.x * PI), cos(randomVec.x * PI)));
|
||||
|
||||
// for (int i = 0; i < kernelSize; i++) {
|
||||
fragColor.r = doAO(kernel0, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel1, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel2, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel3, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel4, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel5, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel6, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel7, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel8, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel9, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel10, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel11, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel12, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel13, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel14, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel15, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel16, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel17, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel18, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// fragColor.r += doAO(kernel19, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
// }
|
||||
fragColor.r = doAO(kernel0, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel1, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel2, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel3, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel4, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel5, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel6, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel7, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel8, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel9, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel10, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
fragColor.r += doAO(kernel11, randomVec, rotMat, currentPos, n, currentDistance);
|
||||
|
||||
fragColor.r *= ssaoStrength / kernelSize;
|
||||
fragColor.r = max(0.0, 1.0 - fragColor.r);
|
||||
|
|
|
@ -24,7 +24,6 @@ uniform vec2 cameraProj;
|
|||
// const int ssgiMaxSteps = 16;
|
||||
// const int ssgiBinarySteps = 4;
|
||||
// const float ssgiRayStep = 0.005;
|
||||
const float searchDist = 5.0;
|
||||
const float angleMix = 0.5f;
|
||||
#ifdef _SSGICone9
|
||||
const float strength = 2.0 * (1.0 / ssgiStrength);
|
||||
|
@ -73,11 +72,18 @@ float getDeltaDepth(vec3 hitCoord) {
|
|||
void rayCast(vec3 dir) {
|
||||
hitCoord = vpos;
|
||||
dir *= ssgiRayStep;
|
||||
#ifdef _SSGICone9
|
||||
float dist = 1.0 / 9.0;
|
||||
#else
|
||||
float dist = 1.0 / 5.0;
|
||||
#endif
|
||||
for (int i = 0; i < ssgiMaxSteps; i++) {
|
||||
hitCoord += dir;
|
||||
if (getDeltaDepth(hitCoord) > 0.0) { /* binarySearch(dir); */ break; }
|
||||
if (getDeltaDepth(hitCoord) > 0.0) {
|
||||
dist = distance(vpos, hitCoord);
|
||||
/* binarySearch(dir); */ break;
|
||||
}
|
||||
}
|
||||
float dist = distance(vpos, hitCoord);
|
||||
occ += dist;
|
||||
#ifdef _RTGI
|
||||
col += texture(gbuffer1, coord).rgb * ((ssgiRayStep * ssgiMaxSteps) - dist);
|
||||
|
|
|
@ -24,5 +24,5 @@ vec3 SSSSTransmittance(mat4 LWVP, vec3 p, vec3 n, vec3 l, float lightFar, sample
|
|||
|
||||
vec3 SSSSTransmittanceCube(float translucency, vec4 shadowPos, vec3 n, vec3 l, float lightFar) {
|
||||
// TODO
|
||||
return vec3(0.2);
|
||||
return vec3(0.0);
|
||||
}
|
||||
|
|
|
@ -2002,7 +2002,7 @@ class ArmoryExporter:
|
|||
self.output['camera_ref'] = self.scene.camera.name
|
||||
else:
|
||||
if self.scene.name == arm.utils.get_project_scene_name():
|
||||
log.warn('Armory Warning: No camera found in active scene')
|
||||
log.warn('No camera found in active scene')
|
||||
|
||||
self.output['material_datas'] = []
|
||||
self.export_materials()
|
||||
|
|
|
@ -66,7 +66,14 @@ def parse(material, mat_data, mat_users, mat_armusers):
|
|||
const['bool'] = material.arm_receive_shadow
|
||||
c['bind_constants'].append(const)
|
||||
|
||||
if rpdat.rp_sss_state == 'On':
|
||||
if material.arm_material_id != 0:
|
||||
const = {}
|
||||
const['name'] = 'materialID'
|
||||
const['int'] = material.arm_material_id
|
||||
c['bind_constants'].append(const)
|
||||
if material.arm_material_id == 2:
|
||||
wrd.world_defs += '_Hair'
|
||||
elif rpdat.rp_sss_state == 'On':
|
||||
sss = False
|
||||
sss_node = arm.node_utils.get_node_by_type(material.node_tree, 'SUBSURFACE_SCATTERING')
|
||||
if sss_node != None and sss_node.outputs[0].is_linked: # Check linked node
|
||||
|
|
|
@ -315,7 +315,7 @@ def make_deferred(con_mesh):
|
|||
frag.write('fragColor[0] = vec4(n.xy, packFloat(metallic, roughness), 1.0 - ((wvpposition.z / wvpposition.w) * 0.5 + 0.5));')
|
||||
else:
|
||||
frag.write('fragColor[0] = vec4(n.xy, packFloat(metallic, roughness), 1.0 - gl_FragCoord.z);')
|
||||
if '_SSS' in wrd.world_defs:
|
||||
if '_SSS' in wrd.world_defs or '_Hair' in wrd.world_defs:
|
||||
frag.add_uniform('int materialID')
|
||||
frag.write('fragColor[1] = vec4(basecol.rgb, materialID + clamp(occlusion, 0.0, 1.0 - 0.001));')
|
||||
elif rpdat.arm_voxelgi_refraction:
|
||||
|
|
|
@ -392,6 +392,7 @@ def init_properties():
|
|||
bpy.types.Material.export_tangents = bpy.props.BoolProperty(name="Export Tangents", default=False)
|
||||
bpy.types.Material.vertex_structure = bpy.props.StringProperty(name="Vertex Structure", default='')
|
||||
bpy.types.Material.arm_skip_context = bpy.props.StringProperty(name="Skip Context", default='')
|
||||
bpy.types.Material.arm_material_id = bpy.props.IntProperty(name="ID", default=0)
|
||||
bpy.types.NodeSocket.is_uniform = bpy.props.BoolProperty(name="Is Uniform", description="Mark node sockets to be processed as material uniforms", default=False)
|
||||
bpy.types.NodeTree.is_cached = bpy.props.BoolProperty(name="Node Tree Cached", description="No need to reexport node tree", default=False)
|
||||
bpy.types.Material.signature = bpy.props.StringProperty(name="Signature", description="Unique string generated from material nodes", default="")
|
||||
|
|
|
@ -280,6 +280,7 @@ class MaterialPropsPanel(bpy.types.Panel):
|
|||
|
||||
layout.prop(mat, 'arm_custom_material')
|
||||
layout.prop(mat, 'arm_skip_context')
|
||||
layout.prop(mat, 'arm_material_id')
|
||||
layout.prop(mat, 'arm_billboard')
|
||||
layout.prop(mat, 'arm_particle')
|
||||
if mat.arm_particle == 'gpu':
|
||||
|
|
Loading…
Reference in a new issue