Make 3D cursor work for Vulkan

This commit is contained in:
luboslenco
2020-08-21 15:43:19 +02:00
parent 6a284bde4c
commit d0e03ad279
4 changed files with 12 additions and 14 deletions
-4
View File
@@ -96,11 +96,7 @@ class Config {
raw.pressure_opacity = false;
raw.pressure_sensitivity = 1.0;
raw.material_live = true;
#if kha_vulkan
raw.brush_3d = false; // TODO
#else
raw.brush_3d = true;
#end
raw.brush_live = false;
raw.camera_speed = 1.0;
raw.displace_strength = 1.0;
+1 -1
View File
@@ -215,7 +215,7 @@ class Layers {
pipeCursor.vertexShader = Reflect.field(kha.Shaders, "cursor_vert");
pipeCursor.fragmentShader = Reflect.field(kha.Shaders, "cursor_frag");
var vs = new VertexStructure();
#if kha_metal
#if (kha_metal || kha_vulkan)
vs.add("tex", VertexData.Short2Norm);
#else
vs.add("pos", VertexData.Short4Norm);
+10 -8
View File
@@ -13,14 +13,16 @@ class MakeBrush {
frag.write('float dist = 0.0;');
}
else if (Config.raw.brush_3d) {
frag.write('vec4 inpLocal = inp;'); // TODO: spirv workaround
frag.write('vec4 inplastLocal = inplast;'); // TODO: spirv workaround
#if (kha_direct3d11 || kha_direct3d12 || kha_metal || kha_vulkan)
frag.write('float depth = textureLod(gbufferD, inp.xy, 0.0).r;');
frag.write('float depth = textureLod(gbufferD, inpLocal.xy, 0.0).r;');
#else
frag.write('float depth = textureLod(gbufferD, vec2(inp.x, 1.0 - inp.y), 0.0).r;');
frag.write('float depth = textureLod(gbufferD, vec2(inpLocal.x, 1.0 - inpLocal.y), 0.0).r;');
#end
frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix');
frag.write('vec4 winp = vec4(vec2(inp.x, 1.0 - inp.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);');
frag.write('vec4 winp = vec4(vec2(inpLocal.x, 1.0 - inpLocal.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);');
frag.write('winp = mul(winp, invVP);');
frag.write('winp.xyz /= winp.w;');
frag.wposition = true;
@@ -29,9 +31,9 @@ class MakeBrush {
frag.add_function(ShaderFunctions.str_octahedronWrap);
frag.add_uniform('sampler2D gbuffer0');
#if (kha_direct3d11 || kha_direct3d12 || kha_metal || kha_vulkan)
frag.write('vec2 g0 = textureLod(gbuffer0, inp.xy, 0.0).rg;');
frag.write('vec2 g0 = textureLod(gbuffer0, inpLocal.xy, 0.0).rg;');
#else
frag.write('vec2 g0 = textureLod(gbuffer0, vec2(inp.x, 1.0 - inp.y), 0.0).rg;');
frag.write('vec2 g0 = textureLod(gbuffer0, vec2(inpLocal.x, 1.0 - inpLocal.y), 0.0).rg;');
#end
frag.write('vec3 wn;');
frag.write('wn.z = 1.0 - abs(g0.x) - abs(g0.y);');
@@ -48,12 +50,12 @@ class MakeBrush {
}
#if (kha_direct3d11 || kha_direct3d12 || kha_metal || kha_vulkan)
frag.write('float depthlast = textureLod(gbufferD, inplast.xy, 0.0).r;');
frag.write('float depthlast = textureLod(gbufferD, inplastLocal.xy, 0.0).r;');
#else
frag.write('float depthlast = textureLod(gbufferD, vec2(inplast.x, 1.0 - inplast.y), 0.0).r;');
frag.write('float depthlast = textureLod(gbufferD, vec2(inplastLocal.x, 1.0 - inplastLocal.y), 0.0).r;');
#end
frag.write('vec4 winplast = vec4(vec2(inplast.x, 1.0 - inplast.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);');
frag.write('vec4 winplast = vec4(vec2(inplastLocal.x, 1.0 - inplastLocal.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);');
frag.write('winplast = mul(winplast, invVP);');
frag.write('winplast.xyz /= winplast.w;');
+1 -1
View File
@@ -419,7 +419,7 @@ class RenderPathPaint {
var helpMat = iron.math.Mat4.identity();
helpMat.getInverse(Scene.active.camera.VP);
g.setMatrix(Layers.cursorInvVP, helpMat.self);
#if kha_metal
#if (kha_metal || kha_vulkan)
g.setVertexBuffer(geom.get([{name: "tex", data: "short2norm"}]));
#else
g.setVertexBuffer(geom.vertexBuffer);