Transparent rays test

This commit is contained in:
luboslenco
2020-01-05 10:58:03 +01:00
parent bddd38f1cb
commit 264a692fdc
7 changed files with 53 additions and 27 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ class Layers {
var layers = Project.layers;
layers[0].texpaint.g4.begin();
layers[0].texpaint.g4.clear(kha.Color.fromFloats(defaultBase, defaultBase, defaultBase, 0.0)); // Base
layers[0].texpaint.g4.clear(kha.Color.fromFloats(defaultBase, defaultBase, defaultBase, 1.0)); // Base
layers[0].texpaint.g4.end();
layers[0].texpaint_nor.g4.begin();
+5 -1
View File
@@ -89,7 +89,11 @@ class MakeMesh {
if (Context.layer.paintBase) {
frag.add_shared_sampler('sampler2D texpaint');
frag.write('basecol = textureLodShared(texpaint, texCoord, 0.0).rgb;');
frag.write('vec4 texpaint_sample = textureLodShared(texpaint, texCoord, 0.0);');
#if kha_direct3d12
frag.write('if (texpaint_sample.a < 0.1) discard;');
#end
frag.write('basecol = texpaint_sample.rgb;');
}
else {
frag.write('basecol = vec3(0.0, 0.0, 0.0);');
+6 -1
View File
@@ -196,7 +196,8 @@ class MakePaint {
frag.write('float occlusion = $occ;');
frag.write('vec3 nortan = $nortan;');
frag.write('float height = $height;');
frag.write('float opacity = $opac;');
frag.write('float mat_opacity = $opac;');
frag.write('float opacity = mat_opacity;');
if (Context.layer.material_mask == null) {
frag.write('opacity *= brushOpacity;');
}
@@ -322,7 +323,11 @@ class MakePaint {
frag.add_uniform('sampler2D texpaint_pack_undo', '_texpaint_pack_undo');
frag.write('vec4 sample_nor_undo = textureLod(texpaint_nor_undo, sample_tc, 0.0);');
frag.write('vec4 sample_pack_undo = textureLod(texpaint_pack_undo, sample_tc, 0.0);');
#if kha_direct3d12
frag.write('fragColor[0] = vec4(' + MaterialBuilder.blendMode(frag, UITrait.inst.brushBlending, 'sample_undo.rgb', 'basecol', 'str') + ', mat_opacity);');
#else
frag.write('fragColor[0] = vec4(' + MaterialBuilder.blendMode(frag, UITrait.inst.brushBlending, 'sample_undo.rgb', 'basecol', 'str') + ', 0.0);');
#end
frag.write('fragColor[1] = vec4(mix(sample_nor_undo.rgb, nortan, str), matid);');
if (Context.material.paintHeight && MaterialBuilder.heightUsed) {
frag.write('fragColor[2] = mix(sample_pack_undo, vec4(occlusion, roughness, metallic, height), str);');
+3
View File
@@ -1424,6 +1424,9 @@ class Material {
else {
textureMap.set(tex_store, 'texture($tex_name, $uv_name.xy)');
curshader.write('vec4 $tex_store = texture($tex_name, $uv_name.xy);');
if (!tex.file.endsWith(".jpg")) { // Pre-mult alpha
curshader.write('$tex_store.rgb *= $tex_store.a;');
}
}
if (sample_bump) {
+4 -6
View File
@@ -184,20 +184,18 @@ class RenderPathPaint {
path.clearTarget(0xff000000);
}
var blendA = "texpaint_blend0";
var blendB = "texpaint_blend1";
path.setTarget(blendB);
path.bindTarget(blendA, "tex");
path.setTarget("texpaint_blend1");
path.bindTarget("texpaint_blend0", "tex");
path.drawShader("shader_datas/copy_pass/copy_pass");
var isMask = Context.layerIsMask;
var texpaint = isMask ? "texpaint_mask" + tid : "texpaint" + tid;
path.setTarget(texpaint, ["texpaint_nor" + tid, "texpaint_pack" + tid, blendA]);
path.setTarget(texpaint, ["texpaint_nor" + tid, "texpaint_pack" + tid, "texpaint_blend0"]);
path.bindTarget("_main", "gbufferD");
if ((UITrait.inst.xray || UITrait.inst.brushAngleReject) && UITrait.inst.brush3d) {
path.bindTarget("gbuffer0", "gbuffer0");
}
path.bindTarget(blendB, "paintmask");
path.bindTarget("texpaint_blend1", "paintmask");
#if (!kha_direct3d12)
if (Context.tool == ToolBake && UITrait.inst.bakeType == BakeAO) {
path.bindTarget("voxels", "voxels");