videoplay
This commit is contained in:
parent
b733d7a329
commit
35e6905ed8
|
|
@ -6,3 +6,5 @@ zig version: 0.14
|
|||
Backlog Labs Game Engine.
|
||||
|
||||
run tools/scripts/first-time-setup.py
|
||||
|
||||
ffmpeg -i INPUT.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 OUTPUT.ogv
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ pub const SceneObjectPosRot = struct {
|
|||
|
||||
pub inline fn toTransform(self: @This()) core.Transform {
|
||||
var transform = core.zm.mul(
|
||||
core.zm.scalingV(self.scale.toZm()),
|
||||
core.zm.matFromQuat(self.rotation.quat),
|
||||
core.zm.scalingV(self.scale.toZm()),
|
||||
);
|
||||
|
||||
transform = core.zm.mul(
|
||||
|
|
@ -317,8 +317,8 @@ pub const SceneSystem = struct {
|
|||
core.zm.mul(
|
||||
core.zm.translationV(posRot.position.toZm()),
|
||||
core.zm.mul(
|
||||
core.zm.matFromQuat(posRot.rotation.quat),
|
||||
core.zm.scalingV(posRot.scale.toZm()),
|
||||
core.zm.matFromQuat(posRot.rotation.quat),
|
||||
),
|
||||
),
|
||||
final,
|
||||
|
|
|
|||
|
|
@ -26,9 +26,12 @@ struct Scene
|
|||
|
||||
uint textureMode; // 0 = regular triple,
|
||||
// 0x10 = video yuv,
|
||||
uint pad0; // 0 = regular triple,
|
||||
uint pad1; // 0 = regular triple,
|
||||
uint pad2; // 0 = regular triple,
|
||||
};
|
||||
|
||||
StructuredBuffer<Scene> scene: register(t0, space0);
|
||||
StructuredBuffer<Scene> scene: register(t4, space2);
|
||||
|
||||
// from learnopengl.com
|
||||
float3 BlinnPhong(float3 normal, float3 fragPos, float3 lightPos, float3 lightColor)
|
||||
|
|
@ -186,7 +189,6 @@ float4 main(
|
|||
|
||||
|
||||
float4 s;
|
||||
float alpha = s.w;
|
||||
|
||||
int texMode = scene[Instance].textureMode;
|
||||
if (texMode == 0x10) // YUV
|
||||
|
|
@ -196,44 +198,27 @@ float4 main(
|
|||
float3 Gcoeff = float3(1.164, -0.213, -0.533);
|
||||
float3 Bcoeff = float3(1.164, 2.112, 0.000);
|
||||
|
||||
float3 yuv, rgb;
|
||||
|
||||
yuv.x =Texture0.Sample(Sampler0, UV).r;
|
||||
yuv.y =Texture1.Sample(Sampler1, UV).r;
|
||||
yuv.z =Texture2.Sample(Sampler2, UV).r;
|
||||
float3 yuv;
|
||||
float3 rgb;
|
||||
float2 uv = UV;
|
||||
|
||||
yuv.x = Texture0.Sample(Sampler0, uv).r;
|
||||
yuv.y = Texture1.Sample(Sampler1, uv).r;
|
||||
yuv.z = Texture2.Sample(Sampler2, uv).r;
|
||||
yuv += offset;
|
||||
rgb.r = dot(yuv, Rcoeff);
|
||||
rgb.g = dot(yuv, Gcoeff);
|
||||
rgb.b = dot(yuv, Bcoeff);
|
||||
|
||||
// " gl_FragColor = vec4(rgb, 1.0);\n"
|
||||
// "uniform sampler2D samp0;\n"
|
||||
// "uniform sampler2D samp1;\n"
|
||||
// "uniform sampler2D samp2;\n"
|
||||
// "const vec3 offset = vec3(-0.0625, -0.5, -0.5);\n"
|
||||
// "const vec3 Rcoeff = vec3(1.164, 0.000, 1.793);\n"
|
||||
// "const vec3 Gcoeff = vec3(1.164, -0.213, -0.533);\n"
|
||||
// "const vec3 Bcoeff = vec3(1.164, 2.112, 0.000);\n"
|
||||
// "void main() {\n"
|
||||
// " vec2 tcoord;\n"
|
||||
// " vec3 yuv, rgb;\n"
|
||||
// " tcoord = gl_TexCoord[0].xy;\n"
|
||||
// " yuv.x = texture2D(samp0, tcoord).r;\n"
|
||||
// " yuv.y = texture2D(samp1, tcoord).r;\n"
|
||||
// " yuv.z = texture2D(samp2, tcoord).r;\n"
|
||||
// " yuv += offset;\n"
|
||||
// " rgb.r = dot(yuv, Rcoeff);\n"
|
||||
// " rgb.g = dot(yuv, Gcoeff);\n"
|
||||
// " rgb.b = dot(yuv, Bcoeff);\n"
|
||||
// " gl_FragColor = vec4(rgb, 1.0);\n"
|
||||
// "}\n";
|
||||
rgb.x = dot(yuv, Rcoeff);
|
||||
rgb.y = dot(yuv, Gcoeff);
|
||||
rgb.z = dot(yuv, Bcoeff);
|
||||
|
||||
s = float4(rgb, 1.0);
|
||||
}
|
||||
else if(texMode == 0)
|
||||
{
|
||||
s = Texture0.Sample(Sampler0, UV);
|
||||
}
|
||||
|
||||
float alpha = s.w;
|
||||
if(alpha < 0.01)
|
||||
{
|
||||
discard;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
],
|
||||
"types" : {
|
||||
"_15" : {
|
||||
"_19" : {
|
||||
"name" : "type.Uniforms",
|
||||
"members" : [
|
||||
{
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"_18" : {
|
||||
"_22" : {
|
||||
"name" : "Scene",
|
||||
"members" : [
|
||||
{
|
||||
|
|
@ -55,15 +55,30 @@
|
|||
"name" : "textureMode",
|
||||
"type" : "uint",
|
||||
"offset" : 64
|
||||
},
|
||||
{
|
||||
"name" : "pad0",
|
||||
"type" : "uint",
|
||||
"offset" : 68
|
||||
},
|
||||
{
|
||||
"name" : "pad1",
|
||||
"type" : "uint",
|
||||
"offset" : 72
|
||||
},
|
||||
{
|
||||
"name" : "pad2",
|
||||
"type" : "uint",
|
||||
"offset" : 76
|
||||
}
|
||||
]
|
||||
},
|
||||
"_17" : {
|
||||
"_21" : {
|
||||
"name" : "type.StructuredBuffer.Scene",
|
||||
"members" : [
|
||||
{
|
||||
"name" : "_m0",
|
||||
"type" : "_18",
|
||||
"type" : "_22",
|
||||
"array" : [
|
||||
0
|
||||
],
|
||||
|
|
@ -117,6 +132,18 @@
|
|||
"set" : 2,
|
||||
"binding" : 0
|
||||
},
|
||||
{
|
||||
"type" : "texture2D",
|
||||
"name" : "Texture1",
|
||||
"set" : 2,
|
||||
"binding" : 1
|
||||
},
|
||||
{
|
||||
"type" : "texture2D",
|
||||
"name" : "Texture2",
|
||||
"set" : 2,
|
||||
"binding" : 2
|
||||
},
|
||||
{
|
||||
"type" : "texture2D",
|
||||
"name" : "DirectionalShadowDepthMap",
|
||||
|
|
@ -131,6 +158,18 @@
|
|||
"set" : 2,
|
||||
"binding" : 0
|
||||
},
|
||||
{
|
||||
"type" : "sampler",
|
||||
"name" : "Sampler1",
|
||||
"set" : 2,
|
||||
"binding" : 1
|
||||
},
|
||||
{
|
||||
"type" : "sampler",
|
||||
"name" : "Sampler2",
|
||||
"set" : 2,
|
||||
"binding" : 2
|
||||
},
|
||||
{
|
||||
"type" : "sampler",
|
||||
"name" : "DirectionalShadowSampler",
|
||||
|
|
@ -140,17 +179,17 @@
|
|||
],
|
||||
"ssbos" : [
|
||||
{
|
||||
"type" : "_17",
|
||||
"type" : "_21",
|
||||
"name" : "scene",
|
||||
"readonly" : true,
|
||||
"block_size" : 0,
|
||||
"set" : 0,
|
||||
"binding" : 0
|
||||
"set" : 2,
|
||||
"binding" : 4
|
||||
}
|
||||
],
|
||||
"ubos" : [
|
||||
{
|
||||
"type" : "_15",
|
||||
"type" : "_19",
|
||||
"name" : "type.Uniforms",
|
||||
"block_size" : 76,
|
||||
"set" : 3,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ struct Scene
|
|||
|
||||
uint textureMode; // 0 = regular triple,
|
||||
// 0x10 = video yuv,
|
||||
|
||||
uint pad0; // 0 = regular triple,
|
||||
uint pad1; // 0 = regular triple,
|
||||
uint pad2; // 0 = regular triple,
|
||||
};
|
||||
|
||||
StructuredBuffer<Scene> scene: register(t0, space0);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,21 @@
|
|||
"name" : "textureMode",
|
||||
"type" : "uint",
|
||||
"offset" : 64
|
||||
},
|
||||
{
|
||||
"name" : "pad0",
|
||||
"type" : "uint",
|
||||
"offset" : 68
|
||||
},
|
||||
{
|
||||
"name" : "pad1",
|
||||
"type" : "uint",
|
||||
"offset" : 72
|
||||
},
|
||||
{
|
||||
"name" : "pad2",
|
||||
"type" : "uint",
|
||||
"offset" : 76
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ entity: core.Entity = undefined,
|
|||
|
||||
textureMode: u32 = 0,
|
||||
// DEBUG for-fun function, completely override what happens when the renderer tries to render this mesh.
|
||||
cmrf: ?*rend.renderer.CustomMeshRenderFunc = null,
|
||||
cmrf: ?rend.renderer.CustomMeshRenderFunc = null,
|
||||
cmrf_ctx: ?*anyopaque = null,
|
||||
|
||||
pub const textureMode_default = 0;
|
||||
pub const textureMode_videoYUV = 0x10;
|
||||
|
|
@ -41,13 +42,16 @@ pub fn updateMesh(self: *@This()) void {
|
|||
|
||||
pub fn updateTexture(self: *@This()) void {
|
||||
if (self.textureName.handle() != 0) {
|
||||
self.setMeshByName(&self.textureName);
|
||||
self.setTextureByName(&self.textureName);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setMeshByName(self: *@This(), meshName: *core.Name) void {
|
||||
self.mesh = rend.getMeshByName(meshName);
|
||||
self.meshName = meshName.*;
|
||||
|
||||
core.engine_log("getMeshByName {d} {s}", .{ meshName.handle(), meshName.utf8() });
|
||||
// core.engine_log("late bind of mesh {s}", .{meshName.utf8()});
|
||||
}
|
||||
|
||||
// script function
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
# Blender 4.4.3
|
||||
# www.blender.org
|
||||
o Plane
|
||||
v -1.000000 0.000000 1.000000
|
||||
v 1.000000 0.000000 1.000000
|
||||
v -1.000000 0.000000 -1.000000
|
||||
v 1.000000 0.000000 -1.000000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.000000 1.000000
|
||||
s 0
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
|
|
@ -69,14 +69,14 @@ pub const MeshPool = struct {
|
|||
switch (u) {
|
||||
.new => |new| {
|
||||
var name = new.name;
|
||||
// core.engine_log("uploading mesh => {s}", .{name.utf8()});
|
||||
core.engine_log("uploading mesh => {s}", .{name.utf8()});
|
||||
|
||||
const indexSpan = try self.addTransfer(copyPass, self.indexBuffer, u32, &self.indexSpans, new.indices);
|
||||
const vertexSpan = try self.addTransfer(copyPass, self.vertexBuffer, meshes.MeshVertex, &self.vertexSpans, new.vertices);
|
||||
|
||||
// core.graphics_log("uploading {d} vertices and {d} indices", .{ vertexSpan.size, indexSpan.size });
|
||||
core.graphics_log("uploading {d} vertices and {d} indices", .{ vertexSpan.size, indexSpan.size });
|
||||
|
||||
// core.engine_log("install mesh by name {d}", .{name.handle()});
|
||||
core.engine_log("install mesh by name {d}", .{name.handle()});
|
||||
try self.installedMeshes.put(self.allocator, name.handle(), .{
|
||||
.vertex = vertexSpan,
|
||||
.index = indexSpan,
|
||||
|
|
|
|||
|
|
@ -360,7 +360,10 @@ pub const Renderer = struct {
|
|||
|
||||
// todo.. sparse uploads
|
||||
self.ssboScene = self.device.createGPUBuffer(&.{
|
||||
.usage = .{ .bufferusageGraphicsStorageRead = true, .bufferusageVertex = true },
|
||||
.usage = .{
|
||||
.bufferusageGraphicsStorageRead = true,
|
||||
.bufferusageVertex = true,
|
||||
},
|
||||
.size = MaxObjectCount * @sizeOf(meshes_vert.Scene),
|
||||
.props = 0,
|
||||
});
|
||||
|
|
@ -638,8 +641,11 @@ pub const Renderer = struct {
|
|||
self.state.pass = cmd.beginGPURenderPass(&targetInfo, 1, &depthTarget);
|
||||
const renderpass = self.state.pass.?;
|
||||
//renderpass.bindGPUGraphicsPipeline(self.testPipeline);
|
||||
renderpass.bindGPUFragmentSamplers(1, &.{ .sampler = self.blockySampler, .texture = self.defaultTexture.texture }, 1);
|
||||
renderpass.bindGPUFragmentSamplers(2, &.{ .sampler = self.blockySampler, .texture = self.defaultTexture.texture }, 1);
|
||||
|
||||
renderpass.bindGPUVertexStorageBuffers(0, &self.ssboScene, 1);
|
||||
renderpass.bindGPUFragmentStorageBuffers(0, &self.ssboScene, 1);
|
||||
renderpass.bindGPUVertexBuffers(0, &.{ .buffer = self.meshPool.vertexBuffer, .offset = 0 }, 1);
|
||||
renderpass.bindGPUIndexBuffer(&.{ .buffer = self.meshPool.indexBuffer, .offset = 0 }, .indexelementsize32bit);
|
||||
|
||||
|
|
@ -653,6 +659,8 @@ pub const Renderer = struct {
|
|||
try self.uploadUniforms(cmd);
|
||||
//rendering each mesh
|
||||
{
|
||||
// placeholder textures
|
||||
|
||||
const container = rend.MeshComponent.BaseContainer;
|
||||
const uploadCount: usize = @min(container.dense.items.len, MaxObjectCount);
|
||||
for (0..uploadCount) |i| {
|
||||
|
|
@ -663,11 +671,15 @@ pub const Renderer = struct {
|
|||
t = self.defaultTexture;
|
||||
}
|
||||
|
||||
renderpass.bindGPUFragmentSamplers(0, &.{ .texture = t.?.texture, .sampler = self.blockySampler }, 1);
|
||||
|
||||
if (component.mesh) |mesh| {
|
||||
renderpass.bindGPUFragmentSamplers(0, &.{ .texture = t.?.texture, .sampler = self.blockySampler }, 1);
|
||||
|
||||
if (component.cmrf) |cmrf| {
|
||||
cmrf(component.cmrf_ctx);
|
||||
}
|
||||
|
||||
renderpass.drawGPUIndexedPrimitives(mesh.index.size, 1, mesh.index.start, @intCast(mesh.vertex.start), @intCast(i));
|
||||
}
|
||||
} else {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -792,7 +804,7 @@ pub const RendererState = struct {
|
|||
swapchainTexture: ?*gpu.GPUTexture = null,
|
||||
};
|
||||
|
||||
pub const CustomMeshRenderFunc = *const fn (mesh: *rend.MeshComponent, renderState: *RendererState) void;
|
||||
pub const CustomMeshRenderFunc = *const fn (?*anyopaque) void;
|
||||
pub const GPUTextureType = gpu.GPUTexture;
|
||||
|
||||
const skybox_mesh_obj align(8) = @embedFile("embedded/plane.obj").*;
|
||||
const plane_obj align(8) = @embedFile("embedded/plane.obj").*;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ yTexture: *gpu.GPUTexture = undefined,
|
|||
uTexture: *gpu.GPUTexture = undefined,
|
||||
vTexture: *gpu.GPUTexture = undefined,
|
||||
|
||||
ySampler: *gpu.GPUSampler = undefined,
|
||||
uSampler: *gpu.GPUSampler = undefined,
|
||||
vSampler: *gpu.GPUSampler = undefined,
|
||||
|
||||
gpuTransferBuffer: *gpu.GPUTransferBuffer = undefined,
|
||||
|
||||
fn log(comptime fmt: []const u8, args: anytype) void {
|
||||
|
|
@ -134,7 +138,7 @@ fn releaseAndUploadFrameBuffer(self: *@This(), cmd: *gpu.GPUCommandBuffer) void
|
|||
.rows_per_layer = @intCast(self.uvHeight),
|
||||
},
|
||||
&std.mem.zeroInit(gpu.GPUTextureRegion, .{
|
||||
.texture = self.yTexture,
|
||||
.texture = self.uTexture,
|
||||
.w = @as(u32, @intCast(self.uvWidth)),
|
||||
.h = @as(u32, @intCast(self.uvHeight)),
|
||||
.d = 1,
|
||||
|
|
@ -151,7 +155,7 @@ fn releaseAndUploadFrameBuffer(self: *@This(), cmd: *gpu.GPUCommandBuffer) void
|
|||
.rows_per_layer = @intCast(self.uvHeight),
|
||||
},
|
||||
&std.mem.zeroInit(gpu.GPUTextureRegion, .{
|
||||
.texture = self.yTexture,
|
||||
.texture = self.vTexture,
|
||||
.w = @as(u32, @intCast(self.uvWidth)),
|
||||
.h = @as(u32, @intCast(self.uvHeight)),
|
||||
.d = 1,
|
||||
|
|
@ -189,6 +193,10 @@ pub fn createTextures(self: *@This()) !void {
|
|||
.size = @as(u32, @intCast(self.width * self.height * 2)),
|
||||
.props = 0,
|
||||
});
|
||||
|
||||
self.ySampler = createVideoSampler();
|
||||
self.uSampler = createVideoSampler();
|
||||
self.vSampler = createVideoSampler();
|
||||
}
|
||||
|
||||
pub fn tick(self: *@This(), dt: f64) void {
|
||||
|
|
@ -225,8 +233,45 @@ pub fn tick(self: *@This(), dt: f64) void {
|
|||
}
|
||||
}
|
||||
|
||||
fn bindVideoTextures(p: ?*anyopaque) void {
|
||||
const self: *@This() = @ptrCast(@alignCast(p));
|
||||
const ctx = rend.context();
|
||||
const renderpass: *gpu.GPURenderPass = ctx.state.pass.?;
|
||||
renderpass.bindGPUFragmentSamplers(0, &.{ .sampler = self.ySampler, .texture = self.yTexture }, 1);
|
||||
renderpass.bindGPUFragmentSamplers(1, &.{ .sampler = self.uSampler, .texture = self.uTexture }, 1);
|
||||
renderpass.bindGPUFragmentSamplers(2, &.{ .sampler = self.vSampler, .texture = self.vTexture }, 1);
|
||||
}
|
||||
|
||||
fn createVideoSampler() *gpu.GPUSampler {
|
||||
return rend.context().device.createGPUSampler(&std.mem.zeroInit(gpu.GPUSamplerCreateInfo, .{
|
||||
.min_filter = .filterLinear,
|
||||
.mag_filter = .filterLinear,
|
||||
.mipmap_mode = .samplermipmapmodeNearest,
|
||||
.address_mode_u = .sampleraddressmodeRepeat,
|
||||
.address_mode_v = .sampleraddressmodeRepeat,
|
||||
.address_mode_w = .sampleraddressmodeRepeat,
|
||||
}));
|
||||
}
|
||||
|
||||
// creates a video player entity
|
||||
pub fn createVideoPlayerEntity() !core.Entity {}
|
||||
pub fn createVideoPlayerEntity(self: *@This()) !core.Entity {
|
||||
const entity = try core.createEntity();
|
||||
const scene = entity.addComponent(core.Scene).?;
|
||||
const size = 5.0;
|
||||
const h: f32 = @floatFromInt(self.height);
|
||||
const w: f32 = @floatFromInt(self.width);
|
||||
|
||||
scene.setScale(size, size, size * (h / w));
|
||||
scene.setRotation(core.Rotation.eulerX(core.radians(90.0)));
|
||||
|
||||
if (entity.addComponent(rend.MeshComponent)) |mesh| {
|
||||
mesh.cmrf = bindVideoTextures;
|
||||
mesh.cmrf_ctx = self;
|
||||
mesh.textureMode = 0x10;
|
||||
mesh.setMesh("m_plane");
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
pub fn destroy(self: *@This()) void {
|
||||
core.engine_logs("[Videoplayer] destroying player");
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -17,7 +17,9 @@ struct Scene
|
|||
{
|
||||
float4x4 Model;
|
||||
uint textureMode;
|
||||
char _m0_final_padding[12];
|
||||
uint pad0;
|
||||
uint pad1;
|
||||
uint pad2;
|
||||
};
|
||||
|
||||
struct type_StructuredBuffer_Scene
|
||||
|
|
@ -25,8 +27,8 @@ struct type_StructuredBuffer_Scene
|
|||
Scene _m0[1];
|
||||
};
|
||||
|
||||
constant float4 _68 = {};
|
||||
constant float3 _70 = {};
|
||||
constant float4 _83 = {};
|
||||
constant float3 _85 = {};
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
|
|
@ -42,93 +44,94 @@ struct main0_in
|
|||
uint in_var_TEXCOORD4 [[user(locn4)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(4294967295)]], texture2d<float> Texture0 [[texture(0)]], texture2d<float> DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler DirectionalShadowSampler [[sampler(3)]])
|
||||
fragment main0_out main0(main0_in in [[stage_in]], constant type_Uniforms& Uniforms [[buffer(0)]], const device type_StructuredBuffer_Scene& scene [[buffer(1)]], texture2d<float> Texture0 [[texture(0)]], texture2d<float> Texture1 [[texture(1)]], texture2d<float> Texture2 [[texture(2)]], texture2d<float> DirectionalShadowDepthMap [[texture(3)]], sampler Sampler0 [[sampler(0)]], sampler Sampler1 [[sampler(1)]], sampler Sampler2 [[sampler(2)]], sampler DirectionalShadowSampler [[sampler(3)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
int _80 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
|
||||
float4 _93;
|
||||
if (_80 == 16)
|
||||
int _94 = int(scene._m0[in.in_var_TEXCOORD4].textureMode);
|
||||
float4 _128;
|
||||
if (_94 == 16)
|
||||
{
|
||||
_93 = _68;
|
||||
float3 _115 = float3(Texture0.sample(Sampler0, in.in_var_TEXCOORD0).x, Texture1.sample(Sampler1, in.in_var_TEXCOORD0).x, Texture2.sample(Sampler2, in.in_var_TEXCOORD0).x) + float3(-0.0625, -0.5, -0.5);
|
||||
_128 = float4(dot(_115, float3(1.164000034332275390625, 0.0, 1.7929999828338623046875)), dot(_115, float3(1.164000034332275390625, -0.212999999523162841796875, -0.53299999237060546875)), dot(_115, float3(1.164000034332275390625, 2.111999988555908203125, 0.0)), 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float4 _92;
|
||||
if (_80 == 0)
|
||||
float4 _127;
|
||||
if (_94 == 0)
|
||||
{
|
||||
_92 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
|
||||
_127 = Texture0.sample(Sampler0, in.in_var_TEXCOORD0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_92 = _68;
|
||||
_127 = _83;
|
||||
}
|
||||
_93 = _92;
|
||||
_128 = _127;
|
||||
}
|
||||
if (_68.w < 0.00999999977648258209228515625)
|
||||
if (_128.w < 0.00999999977648258209228515625)
|
||||
{
|
||||
discard_fragment();
|
||||
}
|
||||
float3 _146;
|
||||
float3 _182;
|
||||
do
|
||||
{
|
||||
float3 _103 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
|
||||
float _104 = length(_103);
|
||||
float _105 = _104 * _104;
|
||||
float _111;
|
||||
if (_104 > 2.0)
|
||||
float3 _139 = Uniforms.lightPosition.xyz - in.in_var_TEXCOORD1;
|
||||
float _140 = length(_139);
|
||||
float _141 = _140 * _140;
|
||||
float _147;
|
||||
if (_140 > 2.0)
|
||||
{
|
||||
_111 = 0.5 / _105;
|
||||
_147 = 0.5 / _141;
|
||||
}
|
||||
else
|
||||
{
|
||||
_111 = 1.0 / _105;
|
||||
_147 = 1.0 / _141;
|
||||
}
|
||||
float _116;
|
||||
if (_104 > 4.0)
|
||||
float _152;
|
||||
if (_140 > 4.0)
|
||||
{
|
||||
_116 = _111 * 0.5;
|
||||
_152 = _147 * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_116 = _111;
|
||||
_152 = _147;
|
||||
}
|
||||
float _118 = (_104 > 15.0) ? 0.0 : _116;
|
||||
float _120 = (_118 > 1.0) ? 1.0 : _118;
|
||||
float _154 = (_140 > 15.0) ? 0.0 : _152;
|
||||
float _156 = (_154 > 1.0) ? 1.0 : _154;
|
||||
if (length(in.in_var_TEXCOORD2) < 0.100000001490116119384765625)
|
||||
{
|
||||
_146 = (in.in_var_TEXCOORD1 * float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5)) * _120;
|
||||
_182 = (in.in_var_TEXCOORD1 * float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5)) * _156;
|
||||
break;
|
||||
}
|
||||
float3 _127 = fast::normalize(_103);
|
||||
_146 = ((float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * precise::max(dot(_127, in.in_var_TEXCOORD2), 0.0)) * _120) + (((float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_127 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _120);
|
||||
float3 _163 = fast::normalize(_139);
|
||||
_182 = ((float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * precise::max(dot(_163, in.in_var_TEXCOORD2), 0.0)) * _156) + (((float3(0.800000011920928955078125, 0.800000011920928955078125, 0.5) * powr(precise::max(dot(in.in_var_TEXCOORD2, fast::normalize(_163 + fast::normalize(in.in_var_TEXCOORD1 - Uniforms.viewPos.xyz))), 0.0), 30.0)) * 2.0) * _156);
|
||||
break;
|
||||
} while(false);
|
||||
float3 _163 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
|
||||
float3 _165;
|
||||
_165.x = _163.x;
|
||||
float2 _166 = _165.xy;
|
||||
_166.y = -_163.y;
|
||||
float _173;
|
||||
int _176;
|
||||
int _178;
|
||||
_173 = 0.0;
|
||||
_176 = 0;
|
||||
_178 = -4;
|
||||
float _174;
|
||||
int _177;
|
||||
for (; _178 <= 4; _173 = _174, _176 = _177, _178++)
|
||||
float3 _199 = ((in.in_var_TEXCOORD3.xyz / float3(in.in_var_TEXCOORD3.w)) * 0.5) + float3(0.5);
|
||||
float3 _201;
|
||||
_201.x = _199.x;
|
||||
float2 _202 = _201.xy;
|
||||
_202.y = -_199.y;
|
||||
float _209;
|
||||
int _212;
|
||||
int _214;
|
||||
_209 = 0.0;
|
||||
_212 = 0;
|
||||
_214 = -4;
|
||||
float _210;
|
||||
int _213;
|
||||
for (; _214 <= 4; _209 = _210, _212 = _213, _214++)
|
||||
{
|
||||
_177 = _176;
|
||||
_174 = _173;
|
||||
for (int _187 = -4; _187 <= 4; )
|
||||
_213 = _212;
|
||||
_210 = _209;
|
||||
for (int _223 = -4; _223 <= 4; )
|
||||
{
|
||||
_177++;
|
||||
_174 += float((in.in_var_TEXCOORD3.z - 0.004999999888241291046142578125) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_166 + float2(float(_187) * 0.000244140625, float(_178) * 0.000244140625))).x);
|
||||
_187++;
|
||||
_213++;
|
||||
_210 += float((in.in_var_TEXCOORD3.z - 0.004999999888241291046142578125) > DirectionalShadowDepthMap.sample(DirectionalShadowSampler, (_202 + float2(float(_223) * 0.000244140625, float(_214) * 0.000244140625))).x);
|
||||
_223++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
out.out_var_SV_Target0 = float4(powr(_93.xyz * ((float3(0.100000001490116119384765625) + _146) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_173 / float(_176))))), float3(0.4545454680919647216796875)), _68.w);
|
||||
out.out_var_SV_Target0 = float4(powr(_128.xyz * ((float3(0.100000001490116119384765625) + _182) + ((Uniforms.directionalLightColor.xyz * precise::max(dot(Uniforms.directionalLight.xyz, in.in_var_TEXCOORD2), 0.0)) * (1.0 - (_209 / float(_212))))), float3(0.4545454680919647216796875)), _128.w);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ struct Scene
|
|||
{
|
||||
float4x4 Model;
|
||||
uint textureMode;
|
||||
char _m0_final_padding[12];
|
||||
uint pad0;
|
||||
uint pad1;
|
||||
uint pad2;
|
||||
};
|
||||
|
||||
struct type_StructuredBuffer_Scene
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,14 @@
|
|||
# Blender 4.4.3
|
||||
# www.blender.org
|
||||
o Plane
|
||||
v -1.000000 0.000000 1.000000
|
||||
v 1.000000 0.000000 1.000000
|
||||
v -1.000000 0.000000 -1.000000
|
||||
v 1.000000 0.000000 -1.000000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vt 0.000000 0.000000
|
||||
vt 1.000000 0.000000
|
||||
vt 1.000000 1.000000
|
||||
vt 0.000000 1.000000
|
||||
s 0
|
||||
f 1/1/1 2/2/1 4/3/1 3/4/1
|
||||
|
|
@ -16,6 +16,7 @@ showWindow: bool = true,
|
|||
fpcamera: *FpCamera = undefined,
|
||||
|
||||
videoplayer: *VideoPlayer = undefined,
|
||||
videoplayerObject: core.Entity = undefined,
|
||||
|
||||
pub var NeonObjectTable: core.EngineObjectVTable = core.EngineObjectVTable.from(@This());
|
||||
|
||||
|
|
@ -48,11 +49,11 @@ const assetReferences = [_]assets.AssetImportReference{
|
|||
// "t_fox",
|
||||
// .{ .path = "gltf-samples/Fox/glTF/Texture.png" },
|
||||
// ),
|
||||
// assets.MakeImportRefOptions(
|
||||
// "Texture",
|
||||
// "t_empire",
|
||||
// .{ .path = "textures/lost_empire-RGBA.png" },
|
||||
// ),
|
||||
assets.MakeImportRefOptions(
|
||||
"Texture",
|
||||
"t_empire",
|
||||
.{ .path = "textures/lost_empire-RGBA.png" },
|
||||
),
|
||||
// assets.MakeImportRefOptions(
|
||||
// "Texture",
|
||||
// "t_skybox",
|
||||
|
|
@ -80,7 +81,9 @@ pub fn prepare(self: *@This()) !void {
|
|||
|
||||
try assets.loadList(assetReferences);
|
||||
self.videoplayer = try VideoPlayer.create(self.allocator);
|
||||
try self.videoplayer.startPlayback("OUTPUT3.ogv");
|
||||
try self.videoplayer.startPlayback("LAPWING2.ogv");
|
||||
|
||||
self.videoplayerObject = try self.videoplayer.createVideoPlayerEntity();
|
||||
|
||||
// rend.setSkyboxTexture("t_skybox");
|
||||
|
||||
|
|
@ -98,16 +101,18 @@ pub fn prepare(self: *@This()) !void {
|
|||
}
|
||||
|
||||
self.fpcamera = try FpCamera.create(self.allocator);
|
||||
self.fpcamera.setPosition(.{ .z = -15, .y = 20 });
|
||||
self.fpcamera.setPosition(.{ .z = 15 });
|
||||
self.fpcamera.activateCamera();
|
||||
|
||||
{
|
||||
core.engine_log("creating empire", .{});
|
||||
|
||||
const lostEmpire = try core.createEntity();
|
||||
const scene = lostEmpire.addComponent(core.Scene).?;
|
||||
scene.setPosition(.{ .y = -20 });
|
||||
const empireMesh = lostEmpire.addComponent(rend.MeshComponent).?;
|
||||
empireMesh.setMesh("m_empire");
|
||||
// empireMesh.setTexture("t_empire");
|
||||
empireMesh.setTexture("t_empire");
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -121,13 +126,13 @@ pub fn prepare(self: *@This()) !void {
|
|||
}
|
||||
|
||||
{
|
||||
const lightbox = try core.createEntity();
|
||||
const scene = lightbox.addComponent(core.Scene).?;
|
||||
scene.setPosition(.{ .y = 2 });
|
||||
scene.setScale(0.1, 0.1, 0.1);
|
||||
const mesh = lightbox.addComponent(rend.MeshComponent).?;
|
||||
mesh.setMesh("m_default_cube");
|
||||
mesh.setTexture("t_default");
|
||||
// const lightbox = try core.createEntity();
|
||||
// const scene = lightbox.addComponent(core.Scene).?;
|
||||
// scene.setPosition(.{ .z = 20 });
|
||||
// scene.setScale(0.1, 0.1, 0.1);
|
||||
// const mesh = lightbox.addComponent(rend.MeshComponent).?;
|
||||
// mesh.setMesh("m_default_cube");
|
||||
// mesh.setTexture("t_default");
|
||||
}
|
||||
|
||||
const moveInput = try core.Axis2dBinding.create(core.MakeName("movement"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue