Skip to content

Commit

Permalink
set up the vertex index thing, although it doesn't work yet
Browse files Browse the repository at this point in the history
  • Loading branch information
DragoniteSpam committed Nov 17, 2019
1 parent 89d63f5 commit 73c557a
Show file tree
Hide file tree
Showing 14 changed files with 398 additions and 21 deletions.
16 changes: 16 additions & 0 deletions DDDEditor2.yyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

292 changes: 292 additions & 0 deletions datafiles/data/basic/cage-indexed.d3d

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions datafiles_yy/data/basic/cage-indexed.d3d.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions objects/EditorGraphics/Create_0.gml
@@ -1,5 +1,10 @@
event_inherited();

// this is a very bad workaround and i feel bad about writing it but it
// makes a lot of things easier, like when import_d3d tries to access
// the vertex formats belonging to Stuff.graphics
Stuff.graphics = id;

gpu_set_alphatestenable(true);
gpu_set_alphatestref(20);
gpu_set_tex_repeat(true);
Expand Down Expand Up @@ -61,6 +66,9 @@ c_shape_load_trimesh("data\\basic\\ccube.d3d");
c_shape_end_trimesh(c_shape_block);
c_transform_identity();

basic_cage = import_d3d("data\\basic\\cage.d3d", false);
indexed_cage = import_d3d("data\\basic\\cage-indexed.d3d", false);

water_tile_size = 0xffff;
water_reptition = 256;

Expand Down
3 changes: 0 additions & 3 deletions objects/Stuff/Create_0.gml
Expand Up @@ -390,10 +390,7 @@ event_prefab[EventNodeTypes.DEACTIVATE_EVENT] = create_event_node_basic("Deactiv
// at some point there shouldn't necessarily need to be an active
// map in existence for this to work, but for now there does
instance_create_depth(0, 0, 0, Controller);
// this feels really weird but import_d3d references Stuff.graphics so it needs
// the variable to have already been set for it to work
graphics = instance_create_depth(0, 0, 0, EditorGraphics);
graphics.basic_cage = import_d3d("data\\basic\\cage.d3d", false);
// various types of editors
map = instance_create_depth(0, 0, 0, EditorModeMap);
data = instance_create_depth(0, 0, 0, EditorModeData);
Expand Down
24 changes: 21 additions & 3 deletions scripts/selection_render_single/selection_render_single.gml
Expand Up @@ -2,17 +2,35 @@

var selection = argument0;

transform_set(0, 0, selection.z * TILE_DEPTH + 1, 0, 0, 0, 1, 1, 1);
//transform_set(0, 0, selection.z * TILE_DEPTH + 1, 0, 0, 0, 1, 1, 1);

var x1 = selection.x * TILE_WIDTH;
var y1 = selection.y * TILE_HEIGHT;
var x2 = (selection.x + 1) * TILE_WIDTH;
var y2 = (selection.y + 1) * TILE_HEIGHT;
var z1 = selection.z * TILE_DEPTH;
var z2 = (selection.z + 1) * TILE_DEPTH;

var w = 12;
/*var w = 12;
draw_line_width_colour(x1, y1, x1, y2, w, c_red, c_red);
draw_line_width_colour(x1, y1, x2, y1, w, c_red, c_red);
draw_line_width_colour(x2, y1, x2, y2, w, c_red, c_red);
draw_line_width_colour(x1, y2, x2, y2, w, c_red, c_red);
transform_reset();
transform_reset();*/

shader_set(shd_bounding_box);
shader_set_uniform_f_array(shader_get_uniform(shd_bounding_box, "actual_color"), [1, 0, 0, 0]);
shader_set_uniform_f_array(shader_get_uniform(shd_bounding_box, "offsets"), [
x1, y1, z1,
x1, y1, z2,
x1, y2, z1,
z1, y2, z2,
x2, y1, z1,
x2, y1, z2,
x2, y2, z1,
z2, y2, z2,
]);
The vertices are not appearing in the right place, which usually means the math is wrong
vertex_submit(Stuff.graphics.indexed_cage, pr_trianglelist, -1);
shader_reset();
8 changes: 2 additions & 6 deletions shaders/sh_shadow/sh_shadow.fsh
@@ -1,9 +1,5 @@
//
// Simple passthrough fragment shader
//
uniform vec4 Colour;

void main()
{
void main() {
gl_FragColor = Colour;
}
}
8 changes: 2 additions & 6 deletions shaders/sh_shadow/sh_shadow.vsh
@@ -1,9 +1,5 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)

void main()
{
void main() {
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(in_Position, 1.0);
}
}
5 changes: 5 additions & 0 deletions shaders/shd_bounding_box/shd_bounding_box.fsh
@@ -0,0 +1,5 @@
varying vec4 v_vColour;

void main() {
gl_FragColor = v_vColour;
}
21 changes: 21 additions & 0 deletions shaders/shd_bounding_box/shd_bounding_box.vsh
@@ -0,0 +1,21 @@
// super secret secret: none of these are actually used except for color, it's
// mostly just all here so that the default vertex format can be used (and even
// then, color isn't actually used to store color data).
attribute vec3 in_Position;
attribute vec3 in_Normal;
attribute vec4 in_Colour;
attribute vec2 in_TextureCoord;

varying vec4 v_vColour;

uniform vec4 actual_color;
uniform vec3 offsets[8];

void main() {
// this is (r | (g << 1) | (b << 2)) except you can't actually do those operations
// in OpenGL ES apparently, so i'm settling for the next best thing
int index = int(floor(in_Colour.r / 255.)) + int(floor(in_Colour.g / 255.)) * 2 + int(floor(in_Colour.b / 255.)) * 4;
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * vec4(offsets[index], 1.);

v_vColour = actual_color;
}
7 changes: 7 additions & 0 deletions shaders/shd_bounding_box/shd_bounding_box.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shaders/shd_default_autotile/shd_default_autotile.vsh
Expand Up @@ -6,7 +6,7 @@ attribute vec4 extra; // (autotile id or 0, na, na, na)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

const int maxpositions=12*16*8*2;
const int maxpositions = 12 * 16 * 8 * 2;
uniform float texoffset[maxpositions];

void main() {
Expand Down
3 changes: 2 additions & 1 deletion views/0adcea53-c2c0-45b3-8388-e353c02fcb21.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion views/822d20ac-b324-44d7-9830-1ef34e909b17.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73c557a

Please sign in to comment.