d3d11 fixes
This commit is contained in:
@@ -15,9 +15,9 @@ static float2 texPosition;
|
||||
static float4 color;
|
||||
static float4 vertexColor;
|
||||
struct SPIRV_Cross_Input {
|
||||
float2 texPosition : TEXCOORD0;
|
||||
float4 vertexColor : TEXCOORD1;
|
||||
float3 vertexPosition : TEXCOORD2;
|
||||
float3 vertexPosition : TEXCOORD0;
|
||||
float2 texPosition : TEXCOORD1;
|
||||
float4 vertexColor : TEXCOORD2;
|
||||
};
|
||||
struct SPIRV_Cross_Output {
|
||||
float4 color : TEXCOORD0;
|
||||
|
||||
@@ -138,9 +138,9 @@ class Layers {
|
||||
pipe.vertexShader = kha.graphics4.VertexShader.fromSource(ConstData.painterVert);
|
||||
pipe.fragmentShader = kha.graphics4.FragmentShader.fromSource(ConstData.painterFrag);
|
||||
var vs = new kha.graphics4.VertexStructure();
|
||||
vs.add("vertexPosition", kha.graphics4.VertexData.Float3);
|
||||
vs.add("texPosition", kha.graphics4.VertexData.Float2);
|
||||
vs.add("vertexColor", kha.graphics4.VertexData.Float4);
|
||||
vs.add("pos", kha.graphics4.VertexData.Float3);
|
||||
vs.add("tex", kha.graphics4.VertexData.Float2);
|
||||
vs.add("col", kha.graphics4.VertexData.Float4);
|
||||
pipe.inputLayout = [vs];
|
||||
pipe.blendSource = kha.graphics4.BlendingFactor.SourceAlpha;
|
||||
pipe.blendDestination = kha.graphics4.BlendingFactor.InverseSourceAlpha;
|
||||
|
||||
@@ -45,19 +45,29 @@ class MaterialBuilder {
|
||||
vert.add_out('vec3 sp');
|
||||
frag.ins = vert.outs;
|
||||
vert.add_uniform('mat4 WVP', '_worldViewProjectionMatrix');
|
||||
#if kha_direct3d11
|
||||
vert.write('vec2 tpos = vec2(tex.x * 2.0 - 1.0, (1.0 - tex.y) * 2.0 - 1.0);');
|
||||
#else
|
||||
vert.write('vec2 tpos = vec2(tex.x * 2.0 - 1.0, tex.y * 2.0 - 1.0);');
|
||||
#end
|
||||
|
||||
// TODO: Fix seams at uv borders
|
||||
vert.add_uniform('vec2 sub', '_sub');
|
||||
vert.add_uniform('float paintDepthBias', '_paintDepthBias');
|
||||
vert.write('tpos += sub;');
|
||||
|
||||
vert.write('gl_Position = vec4(tpos, 0.0, 1.0);');
|
||||
|
||||
vert.write_attrib('vec4 ndc = mul(vec4(pos.xyz, 1.0), WVP);');
|
||||
vert.write_attrib('ndc.xyz = ndc.xyz / ndc.w;');
|
||||
#if kha_direct3d11
|
||||
vert.write('sp.xy = ndc.xy * 0.5 + 0.5;');
|
||||
vert.write('sp.z = ndc.z;');
|
||||
#else
|
||||
vert.write('sp.xyz = ndc.xyz * 0.5 + 0.5;');
|
||||
#end
|
||||
vert.write('sp.y = 1.0 - sp.y;');
|
||||
|
||||
vert.add_uniform('float paintDepthBias', '_paintDepthBias');
|
||||
vert.write('sp.z -= paintDepthBias;'); // small bias or !paintVisible
|
||||
|
||||
if (UITrait.inst.brushPaint != 0) frag.ndcpos = true;
|
||||
|
||||
@@ -30,9 +30,9 @@ class UIView2D extends iron.Trait {
|
||||
pipe.vertexShader = kha.graphics4.VertexShader.fromSource(ConstData.painterVert);
|
||||
pipe.fragmentShader = kha.graphics4.FragmentShader.fromSource(ConstData.painterFrag);
|
||||
var vs = new kha.graphics4.VertexStructure();
|
||||
vs.add("vertexPosition", kha.graphics4.VertexData.Float3);
|
||||
vs.add("texPosition", kha.graphics4.VertexData.Float2);
|
||||
vs.add("vertexColor", kha.graphics4.VertexData.Float4);
|
||||
vs.add("pos", kha.graphics4.VertexData.Float3);
|
||||
vs.add("tex", kha.graphics4.VertexData.Float2);
|
||||
vs.add("col", kha.graphics4.VertexData.Float4);
|
||||
pipe.inputLayout = [vs];
|
||||
pipe.compile();
|
||||
|
||||
|
||||
@@ -245,6 +245,13 @@ class RenderPathDeferred {
|
||||
path.drawMeshes("voxel");
|
||||
path.generateMipmaps("voxels");
|
||||
}
|
||||
|
||||
//
|
||||
path.setDepthFrom("bufa", "texpaint" + tid); // Unbind depth so we can read it
|
||||
path.setDepthFrom("texpaint" + tid, "bufb");
|
||||
path.depthToRenderTarget.set("paintdb", path.renderTargets.get("bufa"));
|
||||
//
|
||||
|
||||
if (arm.UITrait.inst.paintHeight) {
|
||||
path.setTarget("texpaint" + tid, ["texpaint_nor" + tid, "texpaint_pack" + tid, "texpaint_opt" + tid]);
|
||||
}
|
||||
@@ -259,6 +266,11 @@ class RenderPathDeferred {
|
||||
path.bindTarget("texpaint_colorid0", "texpaint_colorid0");
|
||||
}
|
||||
path.drawMeshes("paint");
|
||||
|
||||
//
|
||||
path.setDepthFrom("texpaint" + tid, "bufa"); // Re-bind depth
|
||||
path.depthToRenderTarget.set("paintdb", path.renderTargets.get("texpaint" + tid));
|
||||
//
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user