Work on passing trixel colors to trile renderer
This commit is contained in:
parent
c1c846dfb6
commit
94c991bc4a
20
TODO.txt
Normal file
20
TODO.txt
Normal file
@ -0,0 +1,20 @@
|
||||
DONE:
|
||||
- Implement idle orbit thing using the rotation in the level editor camera. (Cool transition effect?)
|
||||
- Level editor camera movement complete.
|
||||
|
||||
TODO:
|
||||
- Level format (just a hash map?). Store a matrix so that we can rotate and maybe scale blocks. Scaling will cause problems with RDM, so figure that out.
|
||||
- Trile color textures.
|
||||
- Sun lighting and shadowmap for levels.
|
||||
- A ground plane with customizable material (ground or water or maybe a reflective floor. Think about what part of this should be done with triles and what with textures.)
|
||||
- Sky editor.
|
||||
- Level saving
|
||||
- Trile atlas saving? JSON?
|
||||
|
||||
PLANNED:
|
||||
- Render distance, sky and fog?
|
||||
- Load RDMs. Load into the Trile_GFX structure?
|
||||
- Render RDMs.
|
||||
- Start working on game port for proof of concept.
|
||||
- Maybe port tacoma in as a part of the engine in plain Vulkan without nvpro. Would also allow for cool ability to render levels as path traced for screenshots and references.
|
||||
- Improve the bz4x format, or figure out a pre-existing format.
|
||||
@ -147,19 +147,21 @@ draw_level_editor :: () {
|
||||
vs_params : Trile_Vs_Params;
|
||||
vs_params.mvp = mvp.floats;
|
||||
|
||||
mesh := get_trile_gfx("test");
|
||||
trilegfx := get_trile_gfx("test");
|
||||
|
||||
sg_apply_pipeline(gPipelines.trile.pipeline);
|
||||
|
||||
|
||||
bindings : sg_bindings;
|
||||
bindings.vertex_buffers[0] = mesh.vertex_buffer;
|
||||
bindings.vertex_buffers[1] = mesh.normal_buffer;
|
||||
bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
|
||||
bindings.vertex_buffers[1] = trilegfx.normal_buffer;
|
||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||
bindings.images[0] = trilegfx.trixel_colors;
|
||||
|
||||
sg_apply_bindings(*bindings);
|
||||
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||
|
||||
sg_draw(0, cast(s32) mesh.vertex_count, 1);
|
||||
sg_draw(0, cast(s32) trilegfx.vertex_count, 1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -436,37 +436,51 @@ generate_trile_gfx_matias :: (trileptr : *Trile) -> Trile_GFX {
|
||||
Pool.reset(*meshgenpool);
|
||||
|
||||
print("Successfully generated mesh for trile with % triangles.\n", triangleVecs.count / 3 / 3);
|
||||
return .{ trile_vert_buffer, trile_normal_buffer, triangleVecs.count / 3 };
|
||||
|
||||
// Create the texture for the trile, from which it gets it's colors for trixels.
|
||||
|
||||
materialdata : [16*16*16*4]u8;
|
||||
counter : int = 0;
|
||||
|
||||
for x: 0..15 {
|
||||
for y: 0..15 {
|
||||
for z: 0..15 {
|
||||
if trileptr.trixels[x][y][z].empty {
|
||||
// @ToDo: add some null pattern here to help in shader side.
|
||||
materialdata[counter + 0] = 0;
|
||||
materialdata[counter + 1] = 0;
|
||||
materialdata[counter + 2] = 0;
|
||||
materialdata[counter + 3] = 0;
|
||||
counter += 4;
|
||||
} else {
|
||||
r,g,b,a := material_to_rgba(trileptr.trixels[x][y][z].material);
|
||||
materialdata[counter + 0] = r;
|
||||
materialdata[counter + 1] = g;
|
||||
materialdata[counter + 2] = b;
|
||||
materialdata[counter + 3] = a;
|
||||
counter += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imgdata : sg_image_data;
|
||||
imgdata.subimage[0][0] = .{materialdata.data, materialdata.count};
|
||||
|
||||
texdesc : sg_image_desc = .{
|
||||
render_target = false,
|
||||
width = 16,
|
||||
height = 16*16,
|
||||
pixel_format = sg_pixel_format.RGBA8,
|
||||
sample_count = 1,
|
||||
data = imgdata
|
||||
};
|
||||
|
||||
img := sg_make_image(*texdesc);
|
||||
|
||||
state := sg_query_image_state(img);
|
||||
print("IMG: %\n", state);
|
||||
|
||||
return .{ img, trile_vert_buffer, trile_normal_buffer, triangleVecs.count / 3 };
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Mesh GenerateMeshMatias(Trile *trileptr){
|
||||
std::vector<float> quadVecs;
|
||||
std::vector<float> triangleVecs;
|
||||
std::vector<float> quadNorms;
|
||||
std::vector<float> triangleNorms;
|
||||
Mesh temp = {};
|
||||
|
||||
generateOptimizedQuadMesh(trileptr,quadVecs,quadNorms);
|
||||
|
||||
//generateBasicQuadMesh(trileptr,quadVecs,quadNorms);
|
||||
quadsToTriangles(quadVecs, triangleVecs,quadNorms, triangleNorms);
|
||||
|
||||
temp.vertexCount = triangleVecs.size() / 3;
|
||||
temp.triangleCount = temp.vertexCount / 3;
|
||||
|
||||
float* vecs = new float[triangleVecs.size()];
|
||||
float* norms = new float[triangleNorms.size()];
|
||||
for(int i=0; i<triangleVecs.size(); i++){
|
||||
vecs[i] = triangleVecs[i];
|
||||
norms[i] = triangleNorms[i];
|
||||
}
|
||||
|
||||
temp.vertices = vecs;
|
||||
temp.normals = norms;
|
||||
|
||||
return temp;
|
||||
}
|
||||
*/
|
||||
|
||||
@ -185,6 +185,12 @@ create_trile_pipeline :: () {
|
||||
pipeline.colors[0] = color_state;
|
||||
|
||||
gPipelines.trile.pipeline = sg_make_pipeline(*pipeline);
|
||||
gPipelines.trile.bind.samplers[0] = sg_make_sampler(*(sg_sampler_desc.{
|
||||
wrap_u = .CLAMP_TO_EDGE,
|
||||
wrap_v = .CLAMP_TO_EDGE,
|
||||
min_filter = .NEAREST,
|
||||
mag_filter = .NEAREST,
|
||||
}));
|
||||
}
|
||||
|
||||
create_sky_pipeline :: () {
|
||||
|
||||
@ -19,10 +19,20 @@
|
||||
Uniform block 'trile_vs_params':
|
||||
Jai struct: Trile_Vs_Params
|
||||
Bind slot: UB_trile_vs_params => 0
|
||||
Image 'triletex':
|
||||
Image type: ._2D
|
||||
Sample type: .FLOAT
|
||||
Multisampled: false
|
||||
Bind slot: IMG_triletex => 0
|
||||
Sampler 'trilesmp':
|
||||
Type: .FILTERING
|
||||
Bind slot: SMP_trilesmp => 0
|
||||
*/
|
||||
ATTR_trile_position :: 0;
|
||||
ATTR_trile_normal :: 1;
|
||||
UB_trile_vs_params :: 0;
|
||||
IMG_triletex :: 0;
|
||||
SMP_trilesmp :: 0;
|
||||
Trile_Vs_Params :: struct {
|
||||
mvp: [16]float;
|
||||
};
|
||||
@ -67,27 +77,33 @@ vs_trile_source_glsl430 := u8.[
|
||||
/*
|
||||
#version 430
|
||||
|
||||
layout(binding = 16) uniform sampler2D triletex_trilesmp;
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
layout(location = 0) in vec4 fnormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0)) * 0.5, 1.0);
|
||||
frag_color = texture(triletex_trilesmp, vec2(0.0));
|
||||
}
|
||||
|
||||
*/
|
||||
fs_trile_source_glsl430 := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x6c,0x61,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,
|
||||
0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,
|
||||
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,
|
||||
0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,
|
||||
0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,
|
||||
0x63,0x34,0x28,0x28,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x20,
|
||||
0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x31,0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,
|
||||
0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x31,
|
||||
0x36,0x29,0x20,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,
|
||||
0x65,0x72,0x32,0x44,0x20,0x74,0x72,0x69,0x6c,0x65,0x74,0x65,0x78,0x5f,0x74,0x72,
|
||||
0x69,0x6c,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,
|
||||
0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||
0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||
0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,
|
||||
0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,
|
||||
0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,
|
||||
0x28,0x74,0x72,0x69,0x6c,0x65,0x74,0x65,0x78,0x5f,0x74,0x72,0x69,0x6c,0x65,0x73,
|
||||
0x6d,0x70,0x2c,0x20,0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x3b,0x0a,
|
||||
0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#version 300 es
|
||||
@ -131,12 +147,14 @@ vs_trile_source_glsl300es := u8.[
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform highp sampler2D triletex_trilesmp;
|
||||
|
||||
layout(location = 0) out highp vec4 frag_color;
|
||||
in highp vec4 fnormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0)) * 0.5, 1.0);
|
||||
frag_color = texture(triletex_trilesmp, vec2(0.0));
|
||||
}
|
||||
|
||||
*/
|
||||
@ -144,17 +162,19 @@ fs_trile_source_glsl300es := u8.[
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x6c,
|
||||
0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,
|
||||
0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,
|
||||
0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,
|
||||
0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,
|
||||
0x72,0x6d,0x61,0x6c,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x66,0x6e,0x6f,0x72,
|
||||
0x6d,0x61,0x6c,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x76,0x65,0x63,0x33,0x28,0x31,
|
||||
0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,
|
||||
0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x72,0x69,0x6c,0x65,0x74,0x65,0x78,0x5f,
|
||||
0x74,0x72,0x69,0x6c,0x65,0x73,0x6d,0x70,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,
|
||||
0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20,0x68,0x69,
|
||||
0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,
|
||||
0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||
0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x72,0x69,0x6c,0x65,0x74,
|
||||
0x65,0x78,0x5f,0x74,0x72,0x69,0x6c,0x65,0x73,0x6d,0x70,0x2c,0x20,0x76,0x65,0x63,
|
||||
0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
];
|
||||
/*
|
||||
#include <metal_stdlib>
|
||||
@ -235,15 +255,10 @@ vs_trile_source_metal_macos := u8.[
|
||||
float4 frag_color [[color(0)]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 fnormal [[user(locn0)]];
|
||||
};
|
||||
|
||||
fragment main0_out main0(main0_in in [[stage_in]])
|
||||
fragment main0_out main0(texture2d<float> triletex [[texture(0)]], sampler trilesmp [[sampler(0)]])
|
||||
{
|
||||
main0_out out = {};
|
||||
out.frag_color = float4((in.fnormal.xyz + float3(1.0)) * 0.5, 1.0);
|
||||
out.frag_color = triletex.sample(trilesmp, float2(0.0));
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -257,21 +272,20 @@ fs_trile_source_metal_macos := u8.[
|
||||
0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,
|
||||
0x20,0x5b,0x5b,0x63,0x6f,0x6c,0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,
|
||||
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,
|
||||
0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||
0x66,0x6e,0x6f,0x72,0x6d,0x61,0x6c,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,
|
||||
0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,
|
||||
0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
|
||||
0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,
|
||||
0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x29,0x0a,
|
||||
0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,
|
||||
0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,
|
||||
0x6c,0x6f,0x61,0x74,0x34,0x28,0x28,0x69,0x6e,0x2e,0x66,0x6e,0x6f,0x72,0x6d,0x61,
|
||||
0x6c,0x2e,0x78,0x79,0x7a,0x20,0x2b,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x28,0x31,
|
||||
0x2e,0x30,0x29,0x29,0x20,0x2a,0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,
|
||||
0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,
|
||||
0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,0x69,0x6e,
|
||||
0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x74,0x65,0x78,0x74,
|
||||
0x75,0x72,0x65,0x32,0x64,0x3c,0x66,0x6c,0x6f,0x61,0x74,0x3e,0x20,0x74,0x72,0x69,
|
||||
0x6c,0x65,0x74,0x65,0x78,0x20,0x5b,0x5b,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,
|
||||
0x30,0x29,0x5d,0x5d,0x2c,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x20,0x74,0x72,
|
||||
0x69,0x6c,0x65,0x73,0x6d,0x70,0x20,0x5b,0x5b,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,
|
||||
0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,
|
||||
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x74,0x72,0x69,0x6c,0x65,0x74,0x65,0x78,0x2e,0x73,
|
||||
0x61,0x6d,0x70,0x6c,0x65,0x28,0x74,0x72,0x69,0x6c,0x65,0x73,0x6d,0x70,0x2c,0x20,
|
||||
0x66,0x6c,0x6f,0x61,0x74,0x32,0x28,0x30,0x2e,0x30,0x29,0x29,0x3b,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
];
|
||||
trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc: sg_shader_desc;
|
||||
@ -292,6 +306,16 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "trile_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "triletex_trilesmp";
|
||||
case .GLES3;
|
||||
desc.vertex_func.source = xx *vs_trile_source_glsl300es;
|
||||
desc.vertex_func.entry = "main";
|
||||
@ -307,6 +331,16 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].type = .FLOAT4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].array_count = 4;
|
||||
desc.uniform_blocks[0].glsl_uniforms[0].glsl_name = "trile_vs_params";
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
desc.image_sampler_pairs[0].glsl_name = "triletex_trilesmp";
|
||||
case .METAL_MACOS;
|
||||
desc.vertex_func.source = xx *vs_trile_source_metal_macos;
|
||||
desc.vertex_func.entry = "main0";
|
||||
@ -318,6 +352,17 @@ trile_shader_desc :: (backend: sg_backend) -> sg_shader_desc {
|
||||
desc.uniform_blocks[0].layout = .STD140;
|
||||
desc.uniform_blocks[0].size = 64;
|
||||
desc.uniform_blocks[0].msl_buffer_n = 0;
|
||||
desc.images[0].stage = .FRAGMENT;
|
||||
desc.images[0].multisampled = false;
|
||||
desc.images[0].image_type = ._2D;
|
||||
desc.images[0].sample_type = .FLOAT;
|
||||
desc.images[0].msl_texture_n = 0;
|
||||
desc.samplers[0].stage = .FRAGMENT;
|
||||
desc.samplers[0].sampler_type = .FILTERING;
|
||||
desc.samplers[0].msl_sampler_n = 0;
|
||||
desc.image_sampler_pairs[0].stage = .FRAGMENT;
|
||||
desc.image_sampler_pairs[0].image_slot = 0;
|
||||
desc.image_sampler_pairs[0].sampler_slot = 0;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
@module bla
|
||||
|
||||
@vs vs_trile
|
||||
|
||||
in vec4 position;
|
||||
@ -23,9 +21,12 @@ void main() {
|
||||
in vec4 fnormal;
|
||||
out vec4 frag_color;
|
||||
|
||||
layout(binding = 0) uniform texture2D triletex;
|
||||
layout(binding = 0) uniform sampler trilesmp;
|
||||
|
||||
void main() {
|
||||
frag_color = vec4((fnormal.xyz + vec3(1.0, 1.0, 1.0)) * 0.5, 1.0);
|
||||
//frag_color = vec4((fnormal.xyz + vec3(1.0, 1.0, 1.0)) * 0.5, 1.0);
|
||||
frag_color = texture(sampler2D(triletex, trilesmp), vec2(0.0));
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ trile_table : Table(string, Trile);
|
||||
#scope_export
|
||||
|
||||
Trile_GFX :: struct {
|
||||
trixel_colors : sg_image;
|
||||
vertex_buffer : sg_buffer;
|
||||
normal_buffer : sg_buffer;
|
||||
vertex_count : s64;
|
||||
@ -74,3 +75,11 @@ Trixel :: struct {
|
||||
Trile :: struct {
|
||||
trixels : [16][16][16] Trixel;
|
||||
};
|
||||
|
||||
material_to_rgba :: (mat: Material) -> (r: u8, g: u8, b: u8, a: u8) {
|
||||
r : u8 = cast(u8) (mat.color.x * 255.0);
|
||||
g : u8 = cast(u8) (mat.color.y * 255.0);
|
||||
b : u8 = cast(u8) (mat.color.z * 255.0);
|
||||
a : u8 = 255; // @ToDo: Do actual material value encode here.
|
||||
return r,g,b,a;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user