Improve channel viewing in 2D view

This commit is contained in:
luboslenco
2020-01-10 20:01:56 +01:00
parent 93aa57497b
commit 20ec554ff0
15 changed files with 66 additions and 10 deletions
+16 -1
View File
@@ -1,8 +1,23 @@
#version 330
uniform sampler2D tex;
uniform int channel;
in vec2 texCoord;
in vec4 color;
out vec4 FragColor;
void main() {
FragColor = textureLod(tex, texCoord, 0) * color;
if (channel == 1) {
FragColor = textureLod(tex, texCoord, 0).rrra * color;
}
else if (channel == 2) {
FragColor = textureLod(tex, texCoord, 0).ggga * color;
}
else if (channel == 3) {
FragColor = textureLod(tex, texCoord, 0).bbba * color;
}
else if (channel == 4) {
FragColor = textureLod(tex, texCoord, 0).aaaa * color;
}
else {
FragColor = textureLod(tex, texCoord, 0).rgba * color;
}
}
Binary file not shown.
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
..\..\..\bin\hlslbin.exe cursor.vert.hlsl ..\cursor.vert.glsl vs_5_0 -i nor -i pos -i tex
..\..\..\bin\hlslbin.exe cursor.frag.hlsl ..\cursor.frag.glsl ps_5_0
..\..\..\bin\hlslbin.exe layer_view.vert.hlsl ..\layer_view.vert.glsl vs_5_0 -i col -i pos -i tex
..\..\..\bin\hlslbin.exe layer_view.frag.hlsl ..\layer_view.frag.glsl ps_5_0
..\..\..\bin\hlslbin.exe layer_merge.vert.hlsl ..\layer_merge.vert.glsl vs_5_0 -i col -i pos -i tex
..\..\..\bin\hlslbin.exe layer_merge.frag.hlsl ..\layer_merge.frag.glsl ps_5_0
..\..\..\bin\hlslbin.exe mask_merge.frag.hlsl ..\mask_merge.frag.glsl ps_5_0
+16 -1
View File
@@ -1,5 +1,20 @@
Texture2D<float4> tex;
SamplerState _tex_sampler;
uniform int channel;
float4 main(float4 color : TEXCOORD0, float2 texCoord : TEXCOORD1) : SV_Target0 {
return tex.SampleLevel(_tex_sampler, texCoord, 0) * color;
if (channel == 1) {
return tex.SampleLevel(_tex_sampler, texCoord, 0).rrra * color;
}
else if (channel == 2) {
return tex.SampleLevel(_tex_sampler, texCoord, 0).ggga * color;
}
else if (channel == 3) {
return tex.SampleLevel(_tex_sampler, texCoord, 0).bbba * color;
}
else if (channel == 4) {
return tex.SampleLevel(_tex_sampler, texCoord, 0).aaaa * color;
}
else {
return tex.SampleLevel(_tex_sampler, texCoord, 0).rgba * color;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -77,7 +77,7 @@ void raygeneration() {
float b = 1.0 - a;
color = color * b + accum.xyz * a;
}
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 0.0f);
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 1.0f);
}
[shader("closesthit")]
+1 -1
View File
@@ -79,7 +79,7 @@ void raygeneration() {
float b = 1.0 - a;
color = color * b + accum.xyz * a;
}
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 0.0f);
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 1.0f);
}
[shader("closesthit")]
@@ -81,7 +81,7 @@ void raygeneration() {
float b = 1.0 - a;
color = color * b + accum.xyz * a;
}
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 0.0f);
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 1.0f);
}
[shader("closesthit")]
@@ -78,7 +78,7 @@ void raygeneration() {
float b = 1.0 - a;
color = color * b + accum.xyz * a;
}
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 0.0f);
render_target[DispatchRaysIndex().xy] = float4(color.xyz, 1.0f);
}
[shader("closesthit")]
+3 -1
View File
@@ -191,7 +191,9 @@ package arm;
@:enum abstract PaintTex(Int) from Int to Int {
var TexBase = 0;
var TexNormal = 1;
var TexPack = 2;
var TexOcclusion = 2;
var TexRoughness = 3;
var TexMetallic = 4;
}
@:enum abstract ProjectModel(Int) from Int to Int {
+20 -3
View File
@@ -6,6 +6,7 @@ import kha.graphics4.PipelineState;
import kha.graphics4.VertexStructure;
import kha.graphics4.VertexData;
import kha.graphics4.BlendingFactor;
import kha.graphics4.ConstantLocation;
import zui.Zui;
import zui.Id;
import iron.system.Input;
@@ -28,6 +29,7 @@ class UIView2D {
public var panY = 0.0;
public var panScale = 1.0;
var pipe: PipelineState;
var channelLocation: ConstantLocation;
var texType = TexBase;
var uvmapShow = false;
@@ -46,6 +48,7 @@ class UIView2D {
pipe.blendDestination = BlendingFactor.BlendZero;
pipe.colorWriteMaskAlpha = false;
pipe.compile();
channelLocation = pipe.getConstantLocation("channel");
var scale = Config.raw.window_scale;
ui = new Zui({font: App.font, theme: App.theme, color_wheel: App.color_wheel, scaleFactor: scale});
@@ -94,22 +97,36 @@ class UIView2D {
ui.g.pipeline = pipe;
var l = Context.layer;
var tex: Image = null;
var channel = 0;
if (type == View2DLayer) {
tex = texType == TexBase ? l.texpaint : texType == TexNormal ? l.texpaint_nor : l.texpaint_pack;
if (Context.layerIsMask) tex = l.texpaint_mask;
tex =
Context.layerIsMask ? l.texpaint_mask :
texType == TexBase ? l.texpaint :
texType == TexNormal ? l.texpaint_nor :
l.texpaint_pack;
channel =
texType == TexOcclusion ? 1 :
texType == TexRoughness ? 2 :
texType == TexMetallic ? 3 :
0;
}
else { // View2DAsset
tex = UITrait.inst.getImage(Context.texture);
}
ui.currentWindow.texture.g4.setInt(channelLocation, channel);
var th = tw;
if (tex != null) {
th = tw * (tex.height / tex.width);
if (!UITrait.inst.textureFilter) {
ui.g.imageScaleQuality = kha.graphics2.ImageScaleQuality.Low;
}
ui.g.drawScaledImage(tex, tx, ty, tw, th);
if (!UITrait.inst.textureFilter) {
ui.g.imageScaleQuality = kha.graphics2.ImageScaleQuality.High;
}
@@ -165,7 +182,7 @@ class UIView2D {
ui._x = 2;
ui._y = 2;
ui._w = ew;
texType = ui.combo(Id.handle({position: texType}), ["Base", "Normal Map", "ORM"], "Texture");
texType = ui.combo(Id.handle({position: texType}), ["Base Color", "Normal Map", "Occlusion", "Roughness", "Metallic"], "Texture");
ui._x += ew + 3;
ui._y = 2;
uvmapShow = ui.check(Id.handle({selected: uvmapShow}), "UV Map");