Close opened files.
This commit is contained in:
parent
272b735ec0
commit
ccebc307d3
|
@ -75,12 +75,9 @@ float distanceBox(vec3 point, vec3 center, vec3 halfExtents) {
|
|||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef _Tex
|
||||
vec2 newCoord = texCoord;
|
||||
#endif
|
||||
|
||||
#ifdef _NorTex
|
||||
vec3 n = (texture(snormal, newCoord).rgb * 2.0 - 1.0);
|
||||
vec3 n = (texture(snormal, texCoord).rgb * 2.0 - 1.0);
|
||||
n = normalize(TBN * normalize(n));
|
||||
#else
|
||||
vec3 n = normalize(normal);
|
||||
|
@ -91,7 +88,7 @@ void main() {
|
|||
|
||||
vec3 baseColor = matColor.rgb;
|
||||
#ifdef _BaseTex
|
||||
vec4 texel = texture(sbase, newCoord);
|
||||
vec4 texel = texture(sbase, texCoord);
|
||||
#ifdef _AlphaTest
|
||||
if(texel.a < 0.4)
|
||||
discard;
|
||||
|
@ -102,18 +99,18 @@ void main() {
|
|||
// baseColor = pow(baseColor, vec3(2.2)); // Variant 2
|
||||
|
||||
#ifdef _MetTex
|
||||
float metalness = texture(smetal, newCoord).r;
|
||||
float metalness = texture(smetal, texCoord).r;
|
||||
#endif
|
||||
|
||||
#ifdef _RoughTex
|
||||
float roughness = texture(srough, newCoord).r;
|
||||
float roughness = texture(srough, texCoord).r;
|
||||
#endif
|
||||
#ifdef _RoughStr
|
||||
roughness *= roughnessStrength;
|
||||
#endif
|
||||
|
||||
#ifdef _OccTex
|
||||
float occ = texture(socclusion, newCoord).r;
|
||||
float occ = texture(socclusion, texCoord).r;
|
||||
#else
|
||||
float occ = occlusion;
|
||||
#endif
|
||||
|
|
|
@ -112,7 +112,7 @@ void main() {
|
|||
vec3 p = getPos2(invVP, depth, texCoord);
|
||||
vec2 metrough = unpackFloat(g0.b);
|
||||
|
||||
vec3 v = normalize(eye - p.xyz);
|
||||
vec3 v = normalize(eye - p);
|
||||
float dotNV = dot(n, v);
|
||||
|
||||
vec3 albedo = surfaceAlbedo(g1.rgb, metrough.x); // g1.rgb - basecolor
|
||||
|
@ -124,7 +124,7 @@ void main() {
|
|||
l = lightDir;
|
||||
}
|
||||
else { // Point, spot
|
||||
l = normalize(lightPos - p.xyz);
|
||||
l = normalize(lightPos - p);
|
||||
}
|
||||
|
||||
vec3 h = normalize(v + l);
|
||||
|
|
|
@ -126,21 +126,22 @@ float shadowTest(vec4 lPos) {
|
|||
void main() {
|
||||
|
||||
#ifdef _NorTex
|
||||
vec3 n = (texture(snormal, texCoord).rgb * 2.0 - 1.0);
|
||||
vec3 n = texture(snormal, texCoord).rgb * 2.0 - 1.0;
|
||||
n = normalize(TBN * normalize(n));
|
||||
|
||||
// vec3 normal = texture(snormal, texCoord).rgb * 2.0 - 1.0;
|
||||
// vec3 nn = normalize(normal);
|
||||
// vec3 dp1 = dFdx( position );
|
||||
// vec3 dp2 = dFdy( position );
|
||||
// vec2 duv1 = dFdx( texCoord );
|
||||
// vec2 duv2 = dFdy( texCoord );
|
||||
// vec3 dp2perp = cross( dp2, nn );
|
||||
// vec3 dp1perp = cross( nn, dp1 );
|
||||
// vec3 dp1 = dFdx(position);
|
||||
// vec3 dp2 = dFdy(position);
|
||||
// vec2 duv1 = dFdx(texCoord);
|
||||
// vec2 duv2 = dFdy(texCoord);
|
||||
// vec3 dp2perp = cross(dp2, nn);
|
||||
// vec3 dp1perp = cross(nn, dp1);
|
||||
// vec3 T = dp2perp * duv1.x + dp1perp * duv2.x;
|
||||
// vec3 B = dp2perp * duv1.y + dp1perp * duv2.y;
|
||||
// float invmax = inversesqrt( max( dot(T,T), dot(B,B) ) );
|
||||
// float invmax = inversesqrt(max(dot(T,T), dot(B,B)));
|
||||
// mat3 TBN = mat3(T * invmax, B * invmax, nn);
|
||||
// vec3 n = normalize(TBN * nn);
|
||||
// vec3 n = (TBN * nn);
|
||||
#else
|
||||
vec3 n = normalize(normal);
|
||||
#endif
|
||||
|
@ -156,7 +157,6 @@ void main() {
|
|||
else { // Point, spot
|
||||
l = normalize(lightPos - position.xyz);
|
||||
}
|
||||
float dotNL = dot(n, l);
|
||||
|
||||
float visibility = 1.0;
|
||||
#ifndef _NoShadows
|
||||
|
@ -181,11 +181,10 @@ void main() {
|
|||
vec3 v = normalize(eyeDir);
|
||||
vec3 h = normalize(v + l);
|
||||
|
||||
float dotNL = dot(n, l);
|
||||
float dotNV = dot(n, v);
|
||||
float dotNH = dot(n, h);
|
||||
float dotVH = dot(v, h);
|
||||
float dotLV = dot(l, v);
|
||||
float dotLH = dot(l, h);
|
||||
|
||||
#ifdef _MetTex
|
||||
float metalness = texture(smetal, texCoord).r;
|
||||
|
|
|
@ -130,7 +130,6 @@ void main() {
|
|||
else { // Point, spot
|
||||
l = normalize(lightPos - position.xyz);
|
||||
}
|
||||
float dotNL = max(dot(n, l), 0.0);
|
||||
|
||||
float visibility = 1.0;
|
||||
#ifndef _NoShadows
|
||||
|
@ -157,11 +156,10 @@ void main() {
|
|||
vec3 v = normalize(eyeDir);
|
||||
vec3 h = normalize(v + l);
|
||||
|
||||
float dotNV = max(dot(n, v), 0.0);
|
||||
float dotNH = max(dot(n, h), 0.0);
|
||||
float dotVH = max(dot(v, h), 0.0);
|
||||
float dotLV = max(dot(l, v), 0.0);
|
||||
float dotLH = max(dot(l, h), 0.0);
|
||||
float dotNL = dot(n, l);
|
||||
float dotNV = dot(n, v);
|
||||
float dotNH = dot(n, h);
|
||||
float dotVH = dot(v, h);
|
||||
|
||||
#ifdef _MetTex
|
||||
float metalness = texture(smetal, texCoord).r;
|
||||
|
|
|
@ -2966,7 +2966,8 @@ class ArmoryExporter:
|
|||
# shader_data_path_with_mask = 'build/compiled/ShaderDatas/' + ArmoryExporter.renderpath_id + '/' + shader_data_name_with_mask + '.arm'
|
||||
# # Copy data if it does not exist and set stencil mask
|
||||
# if not os.path.isfile(shader_data_path_with_mask):
|
||||
# json_file = open(shader_data_path).read()
|
||||
# with open(shader_data_path) as f:
|
||||
# json_file = f.read()
|
||||
# json_data = json.loads(json_file)
|
||||
# dat = json_data['shader_datas'][0]
|
||||
# dat['name'] += mask_ext
|
||||
|
|
|
@ -65,35 +65,47 @@ def write_data(res, defs, json_data, base_name):
|
|||
|
||||
# Parse shaders
|
||||
if 'vertex_shader_path' in c:
|
||||
vert = open(c['vertex_shader_path']).read().splitlines()
|
||||
with open(c['vertex_shader_path']) as f:
|
||||
vert = f.read().splitlines()
|
||||
else:
|
||||
vert = open(c['vertex_shader']).read().splitlines()
|
||||
with open(c['vertex_shader']) as f:
|
||||
vert = f.read().splitlines()
|
||||
|
||||
if 'fragment_shader_path' in c:
|
||||
frag = open(c['fragment_shader_path']).read().splitlines()
|
||||
with open(c['fragment_shader_path']) as f:
|
||||
frag = f.read().splitlines()
|
||||
else:
|
||||
frag = open(c['fragment_shader']).read().splitlines()
|
||||
with open(c['fragment_shader']) as f:
|
||||
frag = f.read().splitlines()
|
||||
|
||||
parse_shader(sres, c, con, defs, vert, len(sres['contexts']) == 1) # Parse attribs for the first vertex shader
|
||||
parse_shader(sres, c, con, defs, frag, False)
|
||||
|
||||
|
||||
if 'geometry_shader' in c:
|
||||
if 'geometry_shader_path' in c:
|
||||
geom = open(c['geometry_shader_path']).read().splitlines()
|
||||
with open(c['geometry_shader_path']) as f:
|
||||
geom = f.read().splitlines()
|
||||
else:
|
||||
geom = open(c['geometry_shader']).read().splitlines()
|
||||
with open(c['geometry_shader']) as f:
|
||||
geom = f.read().splitlines()
|
||||
parse_shader(sres, c, con, defs, geom, False)
|
||||
|
||||
if 'tesscontrol_shader' in c:
|
||||
if 'tesscontrol_shader_path' in c:
|
||||
tesc = open(c['tesscontrol_shader_path']).read().splitlines()
|
||||
with open(c['tesscontrol_shader_path']) as f:
|
||||
tesc = f.read().splitlines()
|
||||
else:
|
||||
tesc = open(c['tesscontrol_shader']).read().splitlines()
|
||||
with open(c['tesscontrol_shader']) as f:
|
||||
tesc = f.read().splitlines()
|
||||
parse_shader(sres, c, con, defs, tesc, False)
|
||||
|
||||
if 'tesseval_shader' in c:
|
||||
if 'tesseval_shader_path' in c:
|
||||
tese = open(c['tesseval_shader_path']).read().splitlines()
|
||||
with open(c['tesseval_shader_path']) as f:
|
||||
tese = f.read().splitlines()
|
||||
else:
|
||||
tese = open(c['tesseval_shader']).read().splitlines()
|
||||
with open(c['tesseval_shader']) as f:
|
||||
tese = f.read().splitlines()
|
||||
parse_shader(sres, c, con, defs, tese, False)
|
||||
|
||||
def parse_shader(sres, c, con, defs, lines, parse_attributes):
|
||||
|
|
|
@ -25,36 +25,46 @@ def make(base_name, json_data, fp, defs):
|
|||
|
||||
shader['vert_name'] = c['vertex_shader'].split('.', 1)[0]
|
||||
if 'vertex_shader_path' in c:
|
||||
shader['vert'] = open(c['vertex_shader_path']).read().splitlines()
|
||||
with open(c['vertex_shader_path']) as f:
|
||||
shader['vert'] = f.read().splitlines()
|
||||
else:
|
||||
shader['vert'] = open(c['vertex_shader']).read().splitlines()
|
||||
with open(c['vertex_shader']) as f:
|
||||
shader['vert'] = f.read().splitlines()
|
||||
|
||||
shader['frag_name'] = c['fragment_shader'].split('.', 1)[0]
|
||||
if 'fragment_shader_path' in c:
|
||||
shader['frag'] = open(c['fragment_shader_path']).read().splitlines()
|
||||
with open(c['fragment_shader_path']) as f:
|
||||
shader['frag'] = f.read().splitlines()
|
||||
else:
|
||||
shader['frag'] = open(c['fragment_shader']).read().splitlines()
|
||||
with open(c['fragment_shader']) as f:
|
||||
shader['frag'] = f.read().splitlines()
|
||||
|
||||
if 'geometry_shader' in c:
|
||||
shader['geom_name'] = c['geometry_shader'].split('.', 1)[0]
|
||||
if 'geometry_shader_path' in c:
|
||||
shader['geom'] = open(c['geometry_shader_path']).read().splitlines()
|
||||
with open(c['geometry_shader_path']) as f:
|
||||
shader['geom'] = f.read().splitlines()
|
||||
else:
|
||||
shader['geom'] = open(c['geometry_shader']).read().splitlines()
|
||||
with open(c['geometry_shader']) as f:
|
||||
shader['geom'] = f.read().splitlines()
|
||||
|
||||
if 'tesscontrol_shader' in c:
|
||||
shader['tesc_name'] = c['tesscontrol_shader'].split('.', 1)[0]
|
||||
if 'tesscontrol_shader_path' in c:
|
||||
shader['tesc'] = open(c['tesscontrol_shader_path']).read().splitlines()
|
||||
with open(c['tesscontrol_shader_path']) as f:
|
||||
shader['tesc'] = f.read().splitlines()
|
||||
else:
|
||||
shader['tesc'] = open(c['tesscontrol_shader']).read().splitlines()
|
||||
with open(c['tesscontrol_shader']) as f:
|
||||
shader['tesc'] = f.read().splitlines()
|
||||
|
||||
if 'tesseval_shader' in c:
|
||||
shader['tese_name'] = c['tesseval_shader'].split('.', 1)[0]
|
||||
if 'tesseval_shader_path' in c:
|
||||
shader['tese'] = open(c['tesseval_shader_path']).read().splitlines()
|
||||
with open(c['tesseval_shader_path']) as f:
|
||||
shader['tese'] = f.read().splitlines()
|
||||
else:
|
||||
shader['tese'] = open(c['tesseval_shader']).read().splitlines()
|
||||
with open(c['tesseval_shader']) as f:
|
||||
shader['tese'] = f.read().splitlines()
|
||||
|
||||
for shader in shaders:
|
||||
ext = ''
|
||||
|
|
|
@ -25,15 +25,13 @@ exporter = ArmoryExporter()
|
|||
|
||||
def compile_shader(raw_shaders_path, shader_name, defs):
|
||||
os.chdir(raw_shaders_path + './' + shader_name)
|
||||
if utils.get_os() == 'mac':
|
||||
fp = os.path.relpath(utils.get_fp())
|
||||
else:
|
||||
fp = utils.get_fp()
|
||||
fp = utils.get_fp()
|
||||
|
||||
# Open json file
|
||||
json_name = shader_name + '.shader.json'
|
||||
base_name = json_name.split('.', 1)[0]
|
||||
json_file = open(json_name).read()
|
||||
with open(json_name) as f:
|
||||
json_file = f.read()
|
||||
json_data = json.loads(json_file)
|
||||
|
||||
lib.make_datas.make(base_name, json_data, fp, defs)
|
||||
|
|
|
@ -189,11 +189,12 @@ def write_probes(image_filepath, disable_hdr, cached_num_mips, generate_radiance
|
|||
|
||||
# Parse sh coefs produced by cmft into json array
|
||||
def sh_to_json(sh_file):
|
||||
sh_lines = open(sh_file + '.c').read().splitlines()
|
||||
with open(sh_file + '.c') as f:
|
||||
sh_lines = f.read().splitlines()
|
||||
band0_line = sh_lines[5]
|
||||
band1_line = sh_lines[6]
|
||||
band2_line = sh_lines[7]
|
||||
|
||||
|
||||
irradiance_floats = []
|
||||
parse_band_floats(irradiance_floats, band0_line)
|
||||
parse_band_floats(irradiance_floats, band1_line)
|
||||
|
|
Loading…
Reference in a new issue