Bake up axis

This commit is contained in:
luboslenco
2019-12-06 21:21:25 +01:00
parent acd5702914
commit 3f4134fc37
5 changed files with 11 additions and 4 deletions
Binary file not shown.
+3 -1
View File
@@ -10,7 +10,7 @@ struct Vertex {
struct RayGenConstantBuffer { struct RayGenConstantBuffer {
float4 v0; // frame, strength, radius, offset float4 v0; // frame, strength, radius, offset
float4 v1; float4 v1; // envstr, upaxis
float4 v2; float4 v2;
float4 v3; float4 v3;
float4 v4; float4 v4;
@@ -63,6 +63,8 @@ void raygeneration() {
accum = normalize(accum / SAMPLES) * 0.5 + 0.5; accum = normalize(accum / SAMPLES) * 0.5 + 0.5;
if (constant_buffer.v1.y > 0) accum.xyz = float3(accum.x, accum.z, 1.0 - accum.y);
float3 color = float3(render_target[DispatchRaysIndex().xy].xyz); float3 color = float3(render_target[DispatchRaysIndex().xy].xyz);
if (constant_buffer.v0.x == 0) { if (constant_buffer.v0.x == 0) {
color = accum.xyz; color = accum.xyz;
+6
View File
@@ -68,10 +68,16 @@ class MakeBake {
else if (UITrait.inst.bakeType == 3) { // Normal (World) else if (UITrait.inst.bakeType == 3) { // Normal (World)
frag.n = true; frag.n = true;
frag.write('fragColor[0] = vec4(n * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);'); frag.write('fragColor[0] = vec4(n * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);');
if (UITrait.inst.bakeUpAxis == 1) { // Y up
frag.write('fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);');
}
} }
else if (UITrait.inst.bakeType == 4) { // Position else if (UITrait.inst.bakeType == 4) { // Position
frag.wposition = true; frag.wposition = true;
frag.write('fragColor[0] = vec4(wposition * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);'); frag.write('fragColor[0] = vec4(wposition * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), 1.0);');
if (UITrait.inst.bakeUpAxis == 1) { // Y up
frag.write('fragColor[0].rgb = vec3(fragColor[0].r, fragColor[0].b, 1.0 - fragColor[0].g);');
}
} }
else if (UITrait.inst.bakeType == 5) { // TexCoord else if (UITrait.inst.bakeType == 5) { // TexCoord
frag.write('fragColor[0] = vec4(texCoord.xy, 0.0, 1.0);'); frag.write('fragColor[0] = vec4(texCoord.xy, 0.0, 1.0);');
+1
View File
@@ -191,6 +191,7 @@ class RenderPathRaytrace {
f32[2] = UITrait.inst.bakeAoRadius; f32[2] = UITrait.inst.bakeAoRadius;
f32[3] = UITrait.inst.bakeAoOffset; f32[3] = UITrait.inst.bakeAoOffset;
f32[4] = Scene.active.world.probe.raw.strength; f32[4] = Scene.active.world.probe.raw.strength;
f32[5] = UITrait.inst.bakeUpAxis;
var baketex2 = path.renderTargets.get("baketex2").image; var baketex2 = path.renderTargets.get("baketex2").image;
Krom.raytraceDispatchRays(baketex2.renderTarget_, f32.buffer); Krom.raytraceDispatchRays(baketex2.renderTarget_, f32.buffer);
+1 -3
View File
@@ -992,7 +992,7 @@ class UITrait {
bakes.push("BentNormal (DXR)"); bakes.push("BentNormal (DXR)");
#end #end
bakeType = ui.combo(bakeHandle, bakes, "Bake"); bakeType = ui.combo(bakeHandle, bakes, "Bake");
if (bakeType == 3 || bakeType == 4 || bakeType == 8) { if (bakeType == 3 || bakeType == 4 || bakeType == 9) {
var bakeUpAxisHandle = Id.handle({position: bakeUpAxis}); var bakeUpAxisHandle = Id.handle({position: bakeUpAxis});
bakeUpAxis = ui.combo(bakeUpAxisHandle, ["Z", "Y"], "Up Axis"); bakeUpAxis = ui.combo(bakeUpAxisHandle, ["Z", "Y"], "Up Axis");
} }
@@ -1031,8 +1031,6 @@ class UITrait {
} }
if (ui.changed) { if (ui.changed) {
MaterialParser.parsePaintMaterial(); MaterialParser.parsePaintMaterial();
// Context.pdirty = 4;
// pushUndo
} }
} }
else { else {