#Iris - A Journey through OpenGL and beyond to learn Graphics

1 messages ยท Page 2 of 1

frank sail
#

and the dims of the matrix are similarly flipped just to troll graphics programmers

wicked notch
#

They did troll me quite hard, ngl

frank sail
#

Searching the topic on Google yields countless stackoverflow questions lol

#

Up there with null pointers for sure :^)

wicked notch
#

I am one foot away from doing a good ole glReadPixels

#

Why did nobody think of making a debugger for shaders?!

wispy spear
#

renderdoc is

#

not with your usual break points, but you can pretty much do printf-like debugging with it

wicked notch
#

Yeah but

#

I miss step-by-step debugging :(

wispy spear
#

martty was working on some debugger thing

#
wicked notch
#

I am so happy

#

Finally

#

Now I can ponder why humans can't ever reach an agreement on anything

#

Why GLSL/HLSL don't follow the same goddamned conventions

wicked notch
#

Quick backup to not lose this

#

Also, I have no idea what the "stabilize" part of the code does, if anyone can explain it that would be much appreciated

frank sail
#

Looks like it snaps the light matrix's offset somehow

#

Probably to prevent shimmering/swimming artifacts when the camera moves slightly

wicked notch
#

Looks like it

#

It has something to do with filtering later too somehow.

#

According to the blog post I am following to do this

#

It's huge but it's very good, I should credit this

frank sail
#

it's a great post

#

btw, I don't see where it mentions the stabilization thing in the post

#

is the code for it in the accompanying code?

wicked notch
#

Could I use AMD's shadow denoiser on non-raytraced shadows ๐Ÿค”

frank sail
#

You could

wicked notch
#

Does it make sense to?

frank sail
#

I'm not sure tbh

#

I'd lean towards no since it aims to denoise shadows that are very expensive to generate, whereas you can just take more samples and/or apply a cheaper denoiser in your case

#

Are you using random disk sampling for your shadows yet frogstare

wicked notch
#

That's exactly why I asked ๐Ÿ˜„

#

I am using Poisson Disk sampling right now

#

I mean

#

I would be using Poisson Disk if my shadows weren't broken

#

But yeah, that's the plan.

frank sail
#

are you using hardware pcf as well

#

that's like an extra 4x total samples for freeโ„ข๏ธ

wicked notch
#

Very broken ๐Ÿ˜ฆ

frank sail
#

hmm it's not terribly wrong though

#

maybe it's just something shrimple like using the wrong matrix for some of the cascades

wicked notch
#

I think either my PSSM is broken or the shadow frustum's min Z is

#

Leaning towards the latter.

#

This is why I'm leaning towards the second by the way.

#

No idea what happened in Slice 1

#

Slice 0 is empty too for some unknown reason

#

1st and 2nd matrices are definitely broken in some way I don't know.

wicked notch
#

I can't find any problems though...

wicked notch
#

Turns out there are problems

wicked notch
#

Going CPU side

#

One day GPU debuggers will exist I'm sure.

#

Even though it's been 40 years

wispy spear
#

maybe you can help martty with work on his

wicked notch
#

I don't think I have the required skills, I wish I could help though

#

Also it looks like it works only on AMD GPUs sadly ๐Ÿ˜ฆ

#

But it makes sense, since they have open source drivers after all

wispy spear
#

doesnt mean it has to stay on amd, and i think you are quite smart

#

just seeing you how much effort you put into small things

wicked notch
#

If only I'd decided to do everything on the CPU first..

#

It was such a trivial error that I'm truly ashamed of anything I've done

#
struct cascade_data_t {
    mat4 projection;
    mat4 view;
    mat4 global;
    mat4 pv;
    vec4 scale;
    vec4 offset; // w is split
};

is supposed to be

struct cascade_data_t {
    mat4 projection;
    mat4 view;
    mat4 pv;
    mat4 global;
    vec4 scale;
    vec4 offset; // w is split
};
wicked notch
#

Alright, now last issue

#

Why the hell PSSM does not produce correct results

wicked notch
#

We did it

wispy spear
#

are those cascades?

#

ah, yes ๐Ÿ˜„

#

noice

#

something i have to implement as well :C

wicked notch
#

I'll make sure to thoroughly comment my compute shader so that people can avoid having multiple strokes over the course of weeks

#

(Like I did)

wicked notch
#

And we also have SDSMs

#

Finally

#

Turns out I had to remap the linearized Z back into [0;1] by dividing it with far - near

#

Almost subpixel perfect

wispy spear
#

that shadow looks sharp

#

but something is wrong with your base color/albedo

wicked notch
#

Yeah, the shadow map is basically this

#

Just the thingy

wicked notch
wispy spear
#

it could just be the poor quality of the textures ofc, but it looks so washed out that the colors seem to roll around somehow

wicked notch
#

Does this look bad as well?

wispy spear
#

you can see that uglyness on the pillar behind the thing

wicked notch
#

It does to be to be honest

wispy spear
#

yeah it looks schtrange

wicked notch
#

Ah I see

#

What could it be?

wispy spear
#

mayhaps initial textures are just shit

wicked notch
#

This is garbage, yes

wispy spear
#

if you can disable everything you have going and just output albedo

#

mayhaps we can see whats fooking with the colors

wicked notch
#

Albedo only looks kind of good?

#

Albedo * AMBIENT looks bad

wispy spear
#

yeah

#

now the plant pot thing looks somewhat like red marble (in the top image) - how it should be

wicked notch
#

Storing every texture as linear SRGB and disabling the SRGB framebuffer results in this

#

Which is reasonable I guess?

wispy spear
#

albedo/emissive needs to be srgb

wispy spear
wicked notch
wicked notch
#

What am I doing wrong ๐Ÿค”

wispy spear
#

are you doing some gamma correction somewhere mayhaps?

#

pow(..., 2.2)

wicked notch
#

Not at all

wispy spear
#

hmm looks harmless, but unrelated to that, you could save one texture sample there

#

if you sample your base color into a vec4 (diffusergb+alpha)

wicked notch
#

True, but I'm severely CPU limited at the moment, not exactly struggling on GPU compute ๐Ÿ˜†

#

at 2K my GPU is pulling 10 watts

wispy spear
#

yeah

#

thats the only thing jumping into my eyes

wicked notch
#

I have decided to put this on low priority

#

Since I have one huge pressing issue

#

I am severely CPU limited

#

And I don't have a weak CPU

#

I am only getting 20 FPS on San Miguel

#

With my GPU basically asleep

#

How can I go and fix this problem?

frank sail
wicked notch
#

Should I do something about the 3786 issues NSight is reporting nervous

frank sail
#

nah it's probably fine bleakekw

wicked notch
frank sail
#

hmm

#

Maybe your tone mapper is scuffed

#

I'd have to look at a capture to see if the srgbisms are correct, tbh

wicked notch
#

I have no tonemapper yet

#

True I could just send a capture for inspection

frank sail
#

basically, there are a few places where you need to think about sRGB:

  • where you create material textures (albedo should almost always be sRGB, everything else not)
  • just before you output color to the screen (you either need to apply the linear-to-nonlinear sRGB conversion yourself, or enable framebuffer sRGB so it happens automagically)
  • in deferred renderers, it's useful to make your albedo gbuffer texture sRGB to maximize precision (but it won't affect absolute correctness, just how much banding there is)
wicked notch
#

It has a SRGB framebuffer, GLFW_SRGB_CAPABLE is true and albedo textures are stored as GL_SRGB8_ALPHA8

frank sail
#

should be all good then

wicked notch
#

it isn't

#

Something must be fucked

frank sail
#

I'll send a pic of how albedo looks on my machine

#

Btw one trick you can use is to display albedo only and see if it looks exactly as it appears when you open the actual image file in the model

wicked notch
#

Thing is, albedo looks fine if I output that only

#

But if I multiply it by a small constant, say 0.025 then it gets ugly quickly

frank sail
#

I don't see the issue tbh

wicked notch
wicked notch
# wicked notch

Looks worse than this (Non SRGB framebuffer + Non SRGB textures)

#

for some unknown reason

frank sail
#

Non sRGB everything cancels out to the correct result when you have no lighting

frank sail
vivid boughBOT
#

Alright Jaker, I'll remind you about check this capture in 5 hours. ID: 56576618

wicked notch
#

Ah I forgor to mention one thing

#

If I make the offscreen framebuffer SRGB too

#

It looks fine

#

Disregard that

#

It doesn't KEKW

frank sail
#

here is albedo in mine

#

direct lighting (I have a tonemapper so it's not exactly comparable)

wicked notch
#

If my eyes and monitor are portraying colors correctly

frank sail
#

hmm

#

I'm using the gltf from the khronos gltf samples repo

#

also you need to enable anisotropic filtering

#

look how blurry the floor is next to the lion bust

#

but that's irrelevant hehe

wicked notch
#

Ah by the way, do you know any good denoisers to use in combo with Poisson Disk sampling?

frank sail
#

I don't know of any specifically for pcf

#

a small (3x3) bilateral filter might work for sun shadows specifically

#

otherwise you just take more samples I guess

#

Pcf is very cheap in that regard

#

And ideally you have hardware pcf enabled too (via shadow samplers)

#

I'll send a rdc capture of my thing in a sec

wicked notch
#

Yeah I just did that

frank sail
#

I have to leave soon so it'll be easier for me to do that than to look at yours

wicked notch
#

Sure, thanks a lot

frank sail
#

frick it's 300 mb

#

one sec gotta use a smoller scene

#

this model is SM_Deccer_Cubes_Textured_Embedded.gltf

frank sail
# frank sail

I'm drawing the g-buffer albedo on top of everything else in this one (at the end of the shading pass)

wicked notch
#

uhm

#

There's a lot of undefineds

frank sail
#

that's fine

wicked notch
#

Should I be concerned?

frank sail
#

nah it's normal

#

for my thing

#

I call glInvalidateNamedFramebufferData before drawing the base pass, so it looks like that in renderdoc

#

Tbh, I think there's a good chance that your thing isn't wrong

wicked notch
#

Looks like it was my oversight

#

Nah it was wrong

#

I said making the offscreen framebuffer didn't work

#

Turns out it did, but I forgor to set it to sRGB when resizing

#

so it was just going back to UNORM

frank sail
#

rip

wicked notch
#

Works fine now, onto poisson disk

wicked notch
#

This blog just called me naive ๐Ÿ˜ 

#

I read 3 lines and he already insults me KEKW

wispy spear
#

๐Ÿ˜„

#

hehehe

wicked notch
#

This is going to take a long time to implement isn't it..

wispy spear
#

this is neat

frank sail
#

Did you know that you can see noise in the penumbra of dynamic light shadows in half life 2

twin bough
frank sail
#

I launched HL2:DM a while ago and saw that most object shadows were just chunky hardware pcf, but for some reason I couldn't use the frickin flashlight

twin bough
#

most object shadows were just chunky hardware pcf,
thats the RTT shadows ๐Ÿ˜„

frank sail
#

anyways, here's what I'm talking about, but in gmod

twin bough
#

yeah

#

its this

#

if im correct

#

they even have contact hardening

#

unfortunately it doesnt work

frank sail
#

rip

wicked notch
#

Before I take the leap into the never-ending rabbit hole of MDI

#

Should I apply the bilateral filter before the albedo pass?

frank sail
#

the noise doesn't bother me personally

#

btw, are you using blue noise?

#

or some kind of low discrepancy sequence

wicked notch
#

Just a regular poisson disk.

frank sail
#

but what kind of noise/random numbers are you using to sample it

#

white noise?

wicked notch
#

Hmm I'm sampling the whole disk sequentially, as in:

for each in poisson_disk { texture(shadow_map, uv + each * texel_size); }```
frank sail
#

what is poisson_disk

#

is it a specific sequence of random numbers?

wicked notch
#

A vec2[] with a lot of random values

frank sail
#

how do you make those random values

wicked notch
#

Right now they're static, but I could make a poisson generator make them every frame, should I?

frank sail
#

not yet

#

can you describe how you generate the random numbers though? this is the important detail I'm wondering about

#

because random numbers matter a lot, and sometimes you want certain kinds of random numbers

wicked notch
#

The ones in the poisson disk?

frank sail
#

ye

wicked notch
#

I just took the array from some random GLSL sample I found on github nervous

frank sail
#

ok I have a task for you

#

have you heard of low discrepancy sequences?

wicked notch
#

Nope ๐Ÿ˜ฆ

frank sail
#

notice how there is no clumping and no voids, but the samples still appear to be somewhat randomly placed

wicked notch
#

Ah I see

frank sail
#

white noise suffers from clumps and voids, which, while eventually converging to the correct result (with enough samples), is visually displeasing

#

I'll whip together a quick shadertoy to show how blue noise vs white noise looks for dithering

wicked notch
#

Alright

twin bough
#

and then theres IGN

frank sail
#

too soon

wicked notch
#

Oh hi, I have a new member in this rambling thread

frank sail
#

you can see which gradient appears smoother

wicked notch
#

Blue noise looks like it's the wrong way around?

frank sail
#

the goal is to approximate a black2white gradient with a limited palette

frank sail
wicked notch
#

Oh it's correct then

#

Fair enough

#

The bottom one I thought was "wrong" but it's all good then.

frank sail
#

ah

#

yeah the bottom one is showing what happens when you just quantize without any noise

#

anyways, the value of blue noise in sampling is that it gives you nice coverage of the sampling domain with few samples

wicked notch
#

Hmm, so I use the output of blue noise to sample the shadow map then right?

frank sail
#

yeah

wicked notch
#

blueNoise.rg

frank sail
#

well, there's two places that need randomness

#

first, you're taking multiple samples per pixel, so you need some LDS/blue noise for those samples

#

second, you want each pixel to have a different seed to start with, otherwise you get big banding artifacts

wicked notch
#

resolution * frag_coord + time to the rescue

frank sail
#

what I do is use a hammersley sequence to generate random samples on a disk for the samples, then sample a blue noise texture to generate per-pixel noise

wicked notch
#

So uh

frank sail
#

I'll show code

wicked notch
#
uv = hammersley(...);
shadow = texture(shadow_map, shadow_uv + texture(blue_noise, uv).rg * texel_size);```
frank sail
#

it's a little more involved than that, because hammersley only gives 2 random numbers in [0, 1], but we actually want a radius + angle (for disk sampling)

#

vec2 xi = 2 random numbers

#

float r = radius (I use sqrt because I want to uniformly sample the disk, no sqrt means you get more samples near the center)

#

then I do polar to cartesian on the next line

wicked notch
#

Why does sqrt give you uniformness?

frank sail
#

think of it this way

#

the circumference of a small circle is smaller than the circumference of a large circle

#

that is, at smaller values of r, points (at random angles) clump up more

#

I'm explaining this horribly ๐Ÿ˜„

wicked notch
#

Nah I get it

frank sail
wicked notch
#

Square root graph in [0;1] more or less looks like ln

frank sail
#

you can find a proof of sqrt being the correct normalization thingy on stackoverflow

wicked notch
#

And it makes sense to sample less/(more?) at smaller radiuses

frank sail
#

yeah so you want fewer small radii because points are closer on those

wicked notch
#

I'll take the proof

frank sail
#

lol the top answer is the asker themselves ๐Ÿ˜„

wicked notch
#

Alright next query.

frank sail
#

now I need to explain toroidal shifts bleakekw (AKA why there is fract in my code)

wicked notch
#

I don't see you sampling blue noise here, am I supposed to use vec2(r * cos(theta), r * sin(theta)) to sample the blue noise?

frank sail
#

oh that's because this code isn't actually using blue noise bleakekw

#

but I can show you where you would plug it in

#

that shitty hash function on the line I linked should be replaced by sampling a blue noise texture

wicked notch
#

Ah I see

#

What are the uvs of this blue noise texture? gl_FragCoord?

frank sail
#

the fract, btw, is used for combining the two noise sources correctly

frank sail
#

you want to sample exactly the texel at gl_FragCoord % blueNoseTextureSize

#

so you use texelFetch for that

wicked notch
#

so fract(gl_FragCoord)?

#

Oh wait not fract uhh

#

Eh modulus operator is good enough

frank sail
#

well I did something stupid in my code that uses blue noise

#

textureLod(s_blueNoise, (vec2(gid) + 0.5) / textureSize(s_blueNoise, 0), 0).xy;

#

pretend gid is the same as gl_FragCoord (I use it because this is from a compute shader rather than a fragment shader)

#

idk why I didn't use texelFetch

wicked notch
#

We don't like division so texture(blue_noise, fract(gl_FragCoord / vec2(textureSize(blue_noise, 0))))

#

notice how we still divide, epic

frank sail
#

I guess you can argue that mod is a lot slower on GPUs

#

but it's literally one op so who cares

wicked notch
#

True

#

Now last query

#

How do I generate blue noise (the texture itself)

frank sail
#

ah, I present you with two methods

wicked notch
#

A whopping two, incredible

frank sail
#

pranked, I gave you three options

wispy spear
#

hoodwinked ๐Ÿ™‚ thats a new one

#

jaker you damn hoodwinkler

frank sail
#

then, after all this, you can do the MDI or bilateral filteringisms if you feel the shadows are still too noisy ๐Ÿ˜„

wicked notch
#

I have decided.

#

Method 1 is good

frank sail
#

heh, deccer showed me that

#

I haven't even used it myself ๐Ÿ˜… but it looks handy

wicked notch
#

I wonder if you could implement blue noise generators on the GPU

frank sail
#

afaik one challenge is that blue noise algorithms tend to be very serial

#

blazing fast
6 minutes for 1024^2 blue noise on a 2080 Ti
bleakekw

wicked notch
#

What's a good resolution, 128^2?

frank sail
frank sail
#

too small usually gives you obvious tiling artifacts

#

the biggest one I have in my repo is 256^2, so I guess I found that to be satisfactory for my uses

wispy spear
#

i saw void use 128^2 and i use it since, it feels like it also looks better than 32^2

frank sail
#

I think it depends on what you use it for

wispy spear
#

ja

frank sail
#

tiny ones probably work for shadow PCF

#

but they fail for things like GI

wispy spear
#

i used the big one for shadow ๐Ÿ˜‰

#

but it could also just be a brain messing with your vision thing

frank sail
#

256^2 vs 16^2 blue noise for my rsm

wispy spear
#

exactly

#

smoller ones leave that uegly pattern

wicked notch
#

Does this look good?

for (uint i = 0; i < sampled_count; ++i) {
    const ivec2 noise_size = textureSize(blue_noise, 0);
    const ivec2 noise_texel = ivec2(int(gl_FragCoord.x) % noise_size.x, int(gl_FragCoord.y) % noise_size.y);
    const vec2 xi = fract(sample_hammersley(i, sampled_count) + texelFetch(blue_noise, noise_texel, 0).xy);
    const float r = sqrt(xi.x);
    const float theta = xi.y * 2.0 * 3.1415926535897932384626433832795;
    const vec2 offset = vec2(r * cos(theta), r * sin(theta));
    const vec2 s_uv = shadow_frag_pos.xy + offset * scaled_texel_size;
    shadow_factor += texture(shadow_map, vec4(s_uv, cascade, light_depth)).r;
}```
#

Shadows look very soft and nice

twin bough
#

can i see closeup?

#

looks nice

#

also 3.1415926535897932384626433832795; u might wanna setup defines for common math constants

wicked notch
#

Hmm closeup is very sharp.

#

That's because I am using SDSM.

#

How can I soften shadows based on how far I am from them?

#

Too sharp

twin bough
#

this calls for a PCSS implementation ๐Ÿ˜„

#

or any contact hardening solution

wicked notch
#

Ah yes

#

SDSM + PSSM + CSM + PCSS

#

Here's a closeup with SDSM disabled

twin bough
#

nice

wicked notch
#

Well I'll do PCSS and then move on

#

Shadows already look great to be honest

twin bough
#

gjgj

#

ur using atlas for the csm right

wicked notch
#

No, a regular layered framebuffer

twin bough
#

ah

wicked notch
#

Alright, we're going in deep boys

#

It's time for MDI.

wispy spear
wicked notch
#
float calculate_kernel_shift() {
    float d = texture(depth, gl_FragCoord.xy / vec2(textureSize(depth, 0))).r;
    d = (2.0 * camera.near * camera.far) / (camera.far + camera.near - d * (camera.far - camera.near));
    const float x = ((d - camera.near) / (camera.far - camera.near)) * 2.0 - 1.0;
    return clamp(1 / (1 + exp(-x)), 0.0, 1.0);
}``` is this a good way of mapping linear depth [-1;1] to a sigmoid?
wicked notch
#

Damn my current mesh and model classes are completely incompatible with MDI nervous

wispy spear
#

heh realizing that is the first step to mdi

cunning atlas
#

from looking through this thread you are making great progress ๐Ÿ™‚

wicked notch
#

Thanks, I'm slowing down a bit since the things I want to do are getting exponentially harder nervous

#

But I'll still try to keep up

wicked notch
#

Hmm MDI is all about huge buffers

#

Real max chungus buffers

#

But even those humongous buffers will eventually run out (at least if I allocate them reasonably big and not take the whole VRAM with me)

#

How to handle this... hmm

#

Perhaps, each mesh is actually just a vertex offset + index offset + pointer to the "global" VBO/EBO?

#

When drawing I could probably do vector<vector<MESH_ID>> where the first vector is the index of the vbo

#

I would then use them like this?

vector<vector<mesh_handle>> stuff(MAX_VBOS, vector<mesh_handle>());
// when loading a mesh
auto [vbo_id, mesh_handle] = load_mesh();
stuff[vbo_id].emplace_back(mesh_handle);
// much later

for each [vbo_id, meshes] in stuff {
    bind_vbo(vbo_id);
    vector<MDI_struct> more_stuff;
    for each mesh in meshes {
        more_stuff.push_back({ mesh.indices, mesh.offsets, etc });
    }
    memcpy(mapped_indirect_buffer_ptr, more_stuff.data(), size_bytes(more_stuff));
    glMultiDrawIndirectโ„ข();
}```
#

What to do about different shaders then, hmm...

#

Even more grouping, perhaps

#

vector<vector<vector<mesh_handle>>>

#

[vbo_id][shader_id][mesh_id]

#

I have no idea if I'm on the right track, how do you guys handle this?

wispy spear
#

mayhaps keep it a little more shrimple

#

here is what i do

#

i stuff all my mesh primitives into 1 vbo/ebo pair

#

via something called MeshPool

#

MeshPool keeps track of VertexOffset/VertexCount/IndexOffset/IndexCount per mesh primitive

#

and owns the VBO/EBO

#

i do something similar for my materials

#

then when i draw meshprimitive1, i grab it from the pool (vertexoffset/count/indexoffset/count) and add an entry in my indirectbuffer

#

and at the same time into my instancebuffer (instancebuffer is just my worldmatrix+materialindex per mesh i want to render)

#

then i bind all those

#

vbo/ebo/materialbuffer/instancebuffer/indirectbuffer and glMultiDrawElementsIndirect

#

all my materials use bindless textures

#
...
layout(location = 2) out flat int v_mesh_material_id;
...
struct GpuModelMeshInstance
{
    mat4 WorldMatrix;
    ivec4 MaterialId;
};

layout(binding = 1, std430) readonly buffer InstanceBuffer
{
    GpuModelMeshInstance Instances[];
} instanceBuffer;

void main()
{
    GpuModelMeshInstance modelMeshInstance = instanceBuffer.Instances[gl_BaseInstance + gl_DrawID];
    v_position = (modelMeshInstance.WorldMatrix * vec4(i_position, 1.0)).xyz;
...
    v_mesh_material_id = modelMeshInstance.MaterialId.x;
...
    gl_Position = cameraInformation.ProjectionMatrix * cameraInformation.ViewMatrix * vec4(v_position, 1.0);
#

thats my vs

#
...
#extension GL_ARB_bindless_texture : enable
#extension GL_ARB_gpu_shader_int64 : enable
...
layout(location = 2) in flat int v_mesh_material_id;
...
struct GpuMaterial
{
    vec4 BaseColor;
   
    vec4 MetalnessRoughnessOcclusion;
    
    vec4 EmissiveColor;
    
    uvec2 BaseColorTexture;
    uvec2 NormalTexture;
    
    uvec2 MetalnessRoughnessTexture;
    uvec2 SpecularTexture;
    
    uvec2 OcclusionTexture;
    uvec2 EmissiveTexture;
};

layout(binding = 2, std430) buffer MaterialBuffer
{
    GpuMaterial[] Materials;
} materialBuffer;
...
void main()
{
    GpuMaterial material = materialBuffer.Materials[v_mesh_material_id];
...
``` and my fs
wicked notch
#

Hmm yes but if two meshes in vbo 0 need different shaders, you need a way to differentiate right?

#

Can this happen, is it useless?

frank sail
#

It could happen

wicked notch
#

I guess this doesn't concern VBOs though, just how you group them for draw

#

for each vbo -> for each shader -> for each mesh

wispy spear
#

you could keep vbo/ebo/instancebuffer and just switch the pipeline to some other shader mayhaps a different materialpool, and then its also just glMDI

frank sail
#

I have one shader for my mdi stuff

#

"pbr"

#

and one big vertex buffer and index buffer

#

then, all I have to manage are the little meshies

#

for an actual game, you'd probably want a way to put a different shader on a mesh (for effects and stuff)

wispy spear
#

perhaps group them by that shader

wicked notch
#

Fair enough, I'll think about what happens if the VBO fills up later

#

What allocator do you guys use?

#

Regular free-list allocator? Something fancier?

wispy spear
#

anything you like

frank sail
#

a shrimple linear allocator will work for a shrimple app

#

consider if you actually need to be able to delete stuff

wicked notch
#

I'm an ambitious person

#

My snow game thingy needs to be open world because I like open worlds

#

So I think I need to stream meshes in and out?

wispy spear
#

yeah

#

you might have to consider LOD too

#

and keep various lods of your mesh in the vbo/ebo etc

wicked notch
#

Yes, to keep things spicy

wispy spear
#

: )

wicked notch
#

Alright, free-list it is

wispy spear
#

another thing with the mdiism you can do

#

which i also want to do at some point, not just lod

#

but also cull primitives

#

and have that compute shader populate the indirectbuffer

wicked notch
#

Ah the thing where the GPU feeds itself, it was in the AZDO thing yes

wispy spear
#

yeah

#

hence indirectbuffer

wicked notch
#

It's very far down in my listโ„ข๏ธ

wispy spear
#

heh

#

fair

#

its under the rug on my list ๐Ÿ˜„

frank sail
#

I made a crappy mdi allocator for my voxel engine

#

It just tracks blocks of memory and splits them up or combines them as necessary

#

O(N) for everything, but it works fine since I don't have a billion tiny allocations

wicked notch
#

RB-trees to the rescue

#

O(logN) boys

frank sail
#

I smell overengineering frogstare

wispy spear
#

when are you going to write your LustriOS to run your LustriGL-mmo on it?

wicked notch
#

I'm not that ambitious KEKW

wispy spear
#

the lie detector detected: its a lie

wicked notch
#

Considering I am yet to write a single line to actually implement the things I'm talking about here, I confirm the lie detector's result

wispy spear
#

hehe

#

luckily there is no rush

wicked notch
#

Of course not, slow and steady

#

Since SDSMs are too damn precise when very close to the shadows, I needed to figure out a way to increase the PCF kernel, but using view_depth gave me too much shimmering, so I settled with this

#

Can I do better?

frank sail
#

Btw glsl has a built in bitfieldReverse function

#

You have to make a hack in shadertoy because glsl es is scuffed beyond belief

wicked notch
#

Nice, not so nice for shadertoy though

#

I wouldn't want to spend more time on shadows, but is a bilateral filter + view depth based kernel size going to reduce shimmering?

frank sail
#

bilateral filter will not fix temporal shimmering

wicked notch
#

But temporal accumulation will?

frank sail
#

yeah, some form of it

#

but that's a big brain worm

#

the view depth based kernel size may work

wicked notch
#

How big of a worm?

frank sail
#

you can spend infinite time tweaking your temporal reprojection

#

one does not shrimply implement it "correctly"

wicked notch
#

Interesting

frank sail
#

it also requires deep integration with the rest of your renderer to support motion vectors

wicked notch
#

How would this temporal accumulation work, at a high level I mean

#

Just the overview of the algorithm

frank sail
#

game studios sometimes employ one or two people whose sole job is to make sure TAA works

wicked notch
frank sail
#

so you are distributing samples both spatially and temporally

wicked notch
#

Hmm

frank sail
#

reusing temporal samples is tricky because the scene is dynamic

#

you have to figure out how much stuff has moved (with motion vectors) and determine where disocclusion (areas that previously weren't on the screen) has occurred

#

failing to do any of that perfectly can lead to a myriad of artifacts. You probably know about TAA ghosting already, which is when your sample rejection heuristic didn't reject a sample it should've

wicked notch
#

Sure

#

I am one of the few people that hates all kind of ghosting/shimmering

#

DLSS, DLAA, FSR, TAA, you name it

#

I don't like them, I'd rather stick with FXAA

#

But for shadows only it shouldn't be a big deal right?

frank sail
#

Well purely screen space techniques will have pretty bad shimmering (specular aliasing) compared to TAA

#

But no ghosting

frank sail
wicked notch
#

True, it's all about tradeoffs

#

So let me see if I understand the algorithm

frank sail
#

I have a presentation somewhere

wicked notch
#
render_jittered_shadow_maps_and_motion_vectors();
if (check_if_any_bad_things_happened_such_as_dissoclusion()) {
    discard_history_or_something();
}
read_previous_screen_space_shadow_only_pass_and_merge_with_history():
render_scene_with_new_screen_space_history_buffer();```
#

I think

#

I'm unsure as to whether I need to jitter the shadow map themselves, or a shadow only render of the scene from the camera's POV (or neither of them and I'm just rambling)

frank sail
#

I haven't done temporal shadows so I'll theorize with you

#

I guess jittering the shadow projection is what you want

wicked notch
#

When sampling or when drawing?

frank sail
#

Because swimming is produced by aliasing in the shadow map

frank sail
wicked notch
#

I see

frank sail
#

temporally filtering shadows is a bit funky though

#

you have to write the shadow mask to a texture and filter that I think

#

which means that you can practically filter a limited number of shadows (like just from the sun)

wicked notch
#

This mask does not need PCF right?

#

I mean, it's just a shadow mask

frank sail
#

generic TAA is nice here because it applies to everything

wicked notch
#

There will be no point lights in my game, only area lights frog_police

frank sail
#

aka how occluded the light is

wicked notch
#

Ah so PCF included

#

damn

wicked notch
frank sail
#

yeah

#

temporal filter

wicked notch
#

And then that results will get used by the final pass where I draw pretty colors multiplied by the filtered result?

frank sail
#

ye

#

that's how I'd approach it anyways

wicked notch
#

It makes sense, the only thing I have no idea how to do is "do temporal accumulation"

frank sail
#

maybe there is some clever way to filter multiple light shadows efficiently that I'm not aware of

wicked notch
#

I'm sure it's more involved than mix(old, new, 1 / (frames + 1))

wicked notch
#

Yeah exactly KEKW

frank sail
#

in fact, that code will work if nothing moves

#

I legit suggest trying that to start

wicked notch
#

I will

frank sail
#

then upgrading it with reprojection

wicked notch
#

but now I sleepy

#

Good theorycrafting session, I'll see if I can find a paper or something on this

frank sail
#

gn

frank sail
wicked notch
#

I awoke.

#

I also read the slides and they're basicaly telling me to apply TAA to the mask and sample that

#

But TAA is a huge jar of worms.

frank sail
#

luckily you can get away with more hacks when it's just shadows

wicked notch
#

Therefore TSSMโ„ข๏ธ (Temporal Supersampling Shadow Mapping (New technique patented by Jaker and Yours Truly)) is postponed

frank sail
#

embrace imperfection

#

your shadows are pretty awesome already

#

way cooler than anything I've done for them

twin bough
#

yeah agree

#

just implement contact hardening and im happy

wicked notch
#

It's on the listโ„ข๏ธ

twin bough
#

noice ๐Ÿ˜„

wicked notch
#

Time for MDI

frank sail
#

"just add contact hardening" bleakekw

twin bough
#

its a can of worms

wispy spear
#

its a worm of cans

wispy spear
#

lol

#

REWE is one of the local supermarket chains here

frank sail
#

do they sell cups of wriggling worms

wispy spear
#

wouldnt surprise me they have shops outside, even in the US like Lidl and Aldi

wicked notch
#

We're back to our humble origins.

wicked notch
#

And we have an indirect triangle

twin bough
#

noice

wicked notch
#

Two triangles

#

Incredible

#

Alright, it's time to draw the rest of the owl

wispy spear
wispy spear
wicked notch
#

I'm wondering something though, whether I should switch to: every attribute gets its own vertex buffer

#

Instead of every attribute is tightly packed into one vertex buffer, I wonder if that makes handling multiple vertex formats easier?

wispy spear
#

i personally just use interleaved vertexformats

#

the only difference for you is how you setup the vao, everything else remains the same

#

you also may or may not save a few bytes here or there, depending on what attribute you want to source

wicked notch
#

Upon pondering I have decided that making one VBO per attribute actually makes my life harder.

#

Interleaved it is.

wispy spear
#

maybe try both

#

see what works best for you or the scenario you want to render

#

maybe interleaved makes more sense for a general purpose mesh, but separate buffers make more sense for something like a planet or so

wicked notch
#

I've thought about that, but in the case of missing attributes, if you don't want to specify separate offsets for each attribute in each VBO, you'd have to pad with zeros

#

Creating lots of waste

wispy spear
#

usually meshes for some pbrism have positions and same amounts of normals uvs and tangents etc

wicked notch
#

I am thinking.

#

VAO store the format of the attributes in the VBO.

#

Is it then reasonable to create one VAO per VBO/EBO combination?

#

With these VBO/EBO being, of course, very large

frank sail
#

imo you should only have one vao per vertex format

#

then use glVertexArrayAttribFormat and co. to facilitate that

wicked notch
#

Yeah but another vertex format implicitly means another VBO (In my thing at least)

wispy spear
#

and glVertexArrayVertexBuffer/glVertexArrayElementBuffer to bind VBO/EBO when necessary

wicked notch
#

I found that if I stuffed more than one vertex format in a VBO, offsets would get funky

wispy spear
#

you can group geometry into various vbos if you need/want

wicked notch
#

That's why I decided this one-to-one relationship between vertex formats and VBOs

wispy spear
#

in general geometry is usually the same though, pos/normal/uv/tangents for static geometry + weights for animated

wicked notch
wispy spear
#

game worlds are made out of the same type of geometry

#

on top of that you might have things like foliage or UI elements or special geometry for effects of sorts, those dont share the "typical" vertex format

#

be it your space game with big asteroid fields, or your open world mmo with dunes and rocks or cities

#

you might only have 4, 5, 6 vertex formats

#
  1. your pos/normal/uv/tangents for static geometry... houses... rocks... statues... ships
#
  1. same as 1) but with weights and bonematrices for animated geometry
#
  1. some debug nonsense, perhaps simple lines or grids, which is just position and color
#
  1. perhaps some font rendering
#
  1. mayhaps part of 4) UI elements... just pos and uv for instance
#

maybe 1) and 2) are split into several vbos/ebo maybe not

wicked notch
#

Hmm.

wispy spear
#

when noobs ask in #opengl we usualyl suggest just make 1 vao per mesh, when they start out

#

95% of them will never come back and ask for more because it was just some homework or so, and doing that (vao per mesh) is also completely fine

#

there is another camp of people ๐Ÿ™‚

#

those who reuse 1 vao for everything, just like japser said he reuses 1 fbo for all the shtuff

frank sail
#

jasper*

wicked notch
#

I have decided.

frank sail
#

anyways, sounds like lvstri will use 1 vao per vbo anyways due to mdi

wicked notch
#

One VAO per vertex format it is.

wicked notch
#

So there actually wasn't this one-to-one relationship, I would end up creating redundant VAOs where I could've just done glVertexArrayElementBuffer

frank sail
#

I'm a little confused

#

Wouldn't you normally have 1 vbo (or set of vbos) and one index buffer per vao with mdi

wicked notch
#

Yeah, but say your VBO is full but your EBO can still house stuff

#

Attempting to insert a new mesh would result in a new VBO but the same EBO

#

So two mesh belonging to the same EBO could have different VBOs and vice versa.

wispy spear
#

i am also a little conchfused now

#

if you assume all your geometry has verticles and indicles

#

then you always bind both

#

and provide both (data wise)

#

if you add a new mesh, you add vertices to the vbo and indices to the ebo

#

if you cant fit, then its a different problem

#

you could try to evict old geometry/indices or simply your renderer knows it needs to switch to a different set of vbo/ebo because the other is "full"

wicked notch
#

But VBO and EBO are not tied

wispy spear
#

they are kinda

#

ofc you can store stuff in there however you want, an make it super complicated

wicked notch
#

Say vbo[0] is full but ebo[0] is not, a new mesh would go in vbo[1] and ebo[0]

wispy spear
#

then your renderer needs to keep track of that

wicked notch
#

Hmm so you're saying I could just make a VBO and EBO a single "package"

wispy spear
#

yeah

wicked notch
#

Definitely sounds simpler.

wispy spear
#

like my MeshPool class for instance

#

owns 1 vbo and 1 ebo (for now, i dont need more right now but while talking to you right now ...)

#

i could make it own as many as it wanted, but also just keep track of what mesh lives in what "pair" of vbo/ebo

#

and then bind the right ones later during draw

#

i might have to split my glMDI into n calls too

#

or even more perverse, when you do vertexfetch/pull you could bind several vbo/ibo as ssbo, then might not need to "batch" or "split" your mdi calls, but then you still need to keep track which mesh sits in which of them so that you can index from the vertexshader

frank sail
#

I don't even consider the possibility of a vbo or ibo being overfilled in mine

#

just make beeg buffers

wicked notch
#

allocate(glGetInteger(GL_VRAM))

#

I hope MeshPool isn't trademarked because I'm stealing the name

wispy spear
#

: )

#

absolute naive

#

i keep MeshPrimitive around for some reason

#

thats the actual vertex container on the cpu, which i get from my gltfloader, pos/normal/uv/andwhatnot

wicked notch
#

Ah you went for the linear allocator, fair fair.

wispy spear
#

yeah

wicked notch
#

I wrote a generic free-list one because it might turn useful for other stuff in the future maybe?

wispy spear
#

perhaps

wicked notch
#

Not sure but it's pretty short and I already knew how to make one

#

Speaking of, I always wondered if the best we can do for best-fit is O(N)? Are there fancier methods?

wispy spear
#

i suppose it depends entirely on your use case or how you want to write/use code

wicked notch
#

Not that I particularly care tbh

wispy spear
#

and performance is probably not really of concern, but who knows

wicked notch
#

Yeah, it's not like this allocator will be used profusely, even when streaming data

frank sail
#

the allocator I mentioned was used for storing voxel meshes (which change fairly frequently) and it was never even close to being a bottleneck

wicked notch
#

Yeah we're absolutely fine here, alright, time to do the meshpoolโ„ข๏ธ

wicked notch
#

The mesh pool is done and it was surprisingly not painfulโ„ข๏ธ to do.

#

All that remains is the grouping and batching

#

The I should be able to plug this bad boy into my model loader.

#

Emphasis on the should.

wicked notch
#

gl_DrawID my absolute beloved.

wicked notch
#

We have max(normal, light_dir); shaded indirect sponza ๐Ÿฅณ

twin bough
#

how's perf atm

wicked notch
#

Probably meaningless to measure, there's no significant load anywhere, I'll report once I get shadows and compute up and running on the indirect renderer

twin bough
#

noice

wispy spear
#

mayhaps introduce Labels for your things too

#

and pass them down to glObjectLabel that makes debugging schlightly more useful

wicked notch
#

Labels?

wispy spear
#

ah sorry, strings

#

i call them Labels in my engine

wicked notch
#

Hmm right now my model class takes in a "mesh pool", does that make sense or should I do something else ๐Ÿค”

wispy spear
#

i think those are separate

#

or rather it depends

#

Model can be the sole container of the verticles/indicles/materials you loaded from a file

#

or its your "abstraction" for how you setup your world

#

where Model is just a handle knowing about pooled material and the pooled mesh counterpart

wicked notch
#

Aha, so separating loading from uploading

wispy spear
#

if you still need vertexdata after uploading, you can keep it around

#

but you probably should (and so should i, but i havent) have no need to keep vertex data around after uploading

#

boundingsphere/boxes can be calculated from vertexpositions at loading time, navmeshes or the likes are probably created in a similar fashion

#

it probably depends on the use case/situation

wicked notch
#

Does it make sense to have a renderable class which contains all the informations required to draw that thing?

#

I.e: texture handles, mesh handles, the model it belongs too, etc.

wispy spear
#

yes

#

quite a common thing

wicked notch
#

Uhh, I have a situation going on.

#

RenderDoc crashes when I launch my program frog_sweat

frank sail
#

Are you using bindless textures

wicked notch
#

Yes, I'm trying to debug why they don't work

frank sail
#

Well, RenderDoc doesn't support bindless textures

#

You now must use nsight graphics to debug

wicked notch
#

oh

#

This is.

#

Uh

#

Very bad

frank sail
#

RenderDoc supports Vulkan "bindless" though frog_gone

wicked notch
#

Bruh

#

Is it that much effort to support bindless in OpenGL? ๐Ÿ˜ฆ

frank sail
#

idk

#

you can do bindless-like things in GL without actual bindless

#

such as using array textures

#

or you can use regular textures and just batch MDI draws by material (which is probably the most practical non-bindless approach)

wicked notch
#

I'll try using nsight for a while..

#

I have good news by the way

#

Well, both good and bad.

#

Good: bindless textures work!

#

Bad: mipmaps are... just gone?

frank sail
wicked notch
#

And mipmaps are back

frank sail
#

what was the buge?

wicked notch
#

glTextureStorage2D with levels = 1 instead of floor(log2(max(w, h))) + 1

#

I didn't have to do this with glTexImage2D ๐Ÿ˜ 

#

Also half of my draw loop is now filling up buffers KEKW

frank sail
wicked notch
#

True, I also took the opportunity and "modernized" my thing.

#

Now everything is DSA.

frank sail
#

excellent

wicked notch
#

Much much better to use to be honest, it's quite nice.

frank sail
#

much good. very sane

#

glBindThing(thing); glDoThingToThing(); is API dreamed up by the deranged

wispy spear
#

i hope that will haunt these people forever

cunning atlas
#

i remember learning opengl and my jaw was on the floor

frank sail
#

was that before or after learning vulkan

#

because I'd imagine that most wouldn't realize the API is absolutely unhinged if they learned GL first

wicked notch
#

Yeah, to be honest if you told me OpenGL was well designed I'd probably believe you.

#

I didn't have many issues using Core 3.3

frank sail
#

modern GL is a lot better, but still has a myriad of questionable design choices

#

for example, there isn't a single struct in the entire API

wicked notch
#

The only thing I wish OpenGL had is more debug features.

#

The debug callback really didn't help me all that much...

#

For some reason when the error occurs, it's always on glXSwapBuffers or something

frank sail
#

I find the callback to be quite helpful in diagnosing API misuse

wicked notch
#

Not on the site of the actual call

frank sail
#

ah

#

do you not have the synchronous callback?

wicked notch
#

I... am not sure?

#
#if !defined(NDEBUG)
    glEnable(GL_DEBUG_OUTPUT);
    glDebugMessageCallback([] (GLenum source,
                               GLenum type,
                               GLuint id,
                               GLenum severity,
                               GLsizei length,
                               const GLchar* message,
                               const void*) {
        if (severity == GL_DEBUG_SEVERITY_NOTIFICATION) {
            return;
        }
        std::cout << "debug callback: " << message << std::endl;
        if (severity == GL_DEBUG_SEVERITY_HIGH) {
            debug_break();
        }
    }, nullptr);
#endif```
#

Here

frank sail
#

add glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); to that snippet

#

then make an invalid GL call somewhere like glDrawArrays(1234, 0, 0);

wicked notch
#

Interesting, unfortunately I am not able at the moment since I borked the thing

#

Will try as soon as I unborke the borke

cunning atlas
#

i got used to it then I switched to vulkan KEKW

wispy spear
#

heh

#

despite gl being somewhat clunky, i now how to get a tringle on a screen with no effort

#

if i did the same in vulkan, id probably get half of the frametimes ๐Ÿ˜„

cunning atlas
#

aye I don't blame you. vulkan is a beast

wispy spear
#

im still too afraid to play with it

wicked notch
#

I'll try Vulkan sooner or later, probably after my Snowโ„ข๏ธ thingy

#

So very far into the future KEKW

cunning atlas
#

from what I've seen in this thread, I think you've been really productive with OpenGL

frank sail
#

I have a feeling you'll like ๐Ÿ…ฑ๏ธulkan

#

but also you're already productive af with OpenGL, so maybe don't ruin that by using vulkan bleakekw

wicked notch
#

I like ๐Ÿฆle stuff to be honest

cunning atlas
wicked notch
#

Now, if the unhingedness of the API outweighs the ๐Ÿฆle-ness then it's another matter entirely bleakekw

frank sail
#

you just gotta make/find the right wrapper to re-hinge it

#

shilling time: #1019779751600205955

wicked notch
#

Ah yes, the "un-unhinged OpenGLโ„ข๏ธ"

wispy spear
#

i hate this mekanism

#

but

#

wouldnt surprise me if its a german invention

frank sail
#

lol some of the cupboards in my house have that mechanism and it's a pain in the ass

wispy spear
#

yeah

frank sail
#

it keeps schlipping

wispy spear
#

exactly because of that reason

frank sail
#

coming loose, etc.

#

not fooking staying closed

wispy spear
#

and when you try to balance, you have to do all 4 of them not just the 2 ๐Ÿ˜„

cunning atlas
#

trying to make a door straight with these

#

a nightmare

wispy spear
cunning atlas
#

fuck doors

frank sail
#

all my homies love windows (the kind that you peer through)

cunning atlas
#

you just got played

wicked notch
#

I have been reading

#

512MiB of garbage data past the end of my buffer

#

And the driver just goes: "yeah sure, why not"

#

Instead of crashing, brilliant.

wicked notch
#

And we're back!

#

Now my GPU is getting utilized quite well in this scene, previously one frame took 70ms, now it's 5ms.

wispy spear
#

oi

#

just from going with MDI?

wicked notch
#

Yes, well, in this scene there were something like 30'000 draw calls nervous

wispy spear
#

what you could try now is instance that scene ๐Ÿ˜„

#

like 4 or 40 more times

wicked notch
#

I will soon, once I figure out why textures work fine normally but stop working in NSight

wispy spear
#

oh?

wicked notch
#

Yeah, these textures are very clearly wrong.

#

But it works fine if I don't run my app in NSight...

wispy spear
#

most likely you miss samplers

#
glGetTextureSamplerHandle + glMakeTextureHandleResident
wicked notch
#

Hmm I can see all my textures resident in NSight though..

#

It's probably the texture ids that are wrong?

#

This tree is sus.

frank sail
#

imposter tree

wicked notch
#

In NSight it's even more sus.

#

For the record, these colors are not random, for some reason NSight gets different texture ids...

wicked notch
#

I am failing to understand this "bug".

#

Assimp is so awfully slow in debug mode this is painful..

frank sail
#

new task: integrate a gltf loader frog_shrimple

wicked notch
#

I am literally idle

#

Waiting for Assimp to finish loading.

#

For every minute that passes like this the priority of integrating a faster loader grows..

frank sail
#

could you perchance link a release build of ass imp to your debug builds

wicked notch
#

Hmm, that may work as a temporary fix for this madness.

#

I didn't think about that.

#

How awful does your CMake have to be to completely break if I link a release build

#

Goddamnit

wispy spear
#

my cmake template uses cgltf

wicked notch
#

Yeah, I'm wasting too much time on this

#

Fighting the linker just to get this stupid loader to work isn't really worth it.

wicked notch
frank sail
#

integrating a gltf loader may take some time

#

well you implement stuff insanely quickly, so maybe not KEKW

wispy spear
wicked notch
#

Turns out I don't need to change loader because the bug is not there.

#

Apparently if I make my buffer so huge that the entire model fits in one VA0/VBO/EBO set, then NSight likes it.

frank sail
#

why did you use a zero for VAO but 'o' for the other ones frogstare

wicked notch
#

I didn't even notice until now KEKW

#

The weird thing is that texture indices are completely disconnected from VAO/VBO/EBOs

wispy spear
#

yep

#

they should perhaps belong to the "instance" of geometry

wicked notch
#

Not even that, it's just a counter that gets incremented

#

Although I plan to make this counter "local" to the model.

wispy spear
#

yeah thats a little brainworm

#

atm i use strings for that still

#

for materials i do the same as with meshes, i throw them into a MaterialPool

#

that also means i have a cpu side Material, a gpu side GpuMaterial and PooledMaterial which is pretty much the global index of the material i then use to update my MaterialIndex in the instanceism

#

if that makes any sense

wicked notch
#

Yeah I had something similar in mind

#

Anyway

#

I think I entered the backrooms

#

Which level is this again?

frank sail
#

looks like a glitchy cp2077 render

#

in other words, it's AAA quality

wicked notch
#

The incredibly funny thing is that this happens strictly in NSight

#

When a mesh doesn't fit in the huge VBO

#

Also, can you show me your (hopefully correct) render of bistro?

#

I need some ground truth here

#

I have no idea what is bugged and what's not.

#

From this angle is good

#

Interior too if possible

frank sail
#

do you know where I can find a gltf of it

wicked notch
#

I do not

#

I had to convert it myself in blender

frank sail
#

i cri everytim

#

hopefully my work is okay with installing blender on my pc

wicked notch
#

Just roll a nat20 stealth

frank sail
#

which ones did you import

#

all three?

#

bistro interior, exterior, and "wine"

wicked notch
#

Just interior and exterior

frank sail
#

oh jeez I selected shaded view

wicked notch
#

"Compiling shaders..."

frank sail
#

the door to the "main cafe" seems a little screwed up with both interior and exterior

#

looks like there are two doors that are almost overlapping

wicked notch
#

I know my thing is the least trustworthy possible, but it looks like that for me too.

frank sail
#

I'd show you a pic, but my blender is frozen trying to export as gltf bleakekw

#

it's hammering one core, probably 90% overhead from the python interpreter

#

it finished finally

frank sail
#

sheeit

#

oh god

wicked notch
frank sail
#

it worked eventually

wicked notch
#

Interesting

frank sail
#

now I gotta test it in my indirect renderer

wicked notch
#

So it's completely borked even without NSight

#

great.

frank sail
#

works in bindless+MDI renderer

wicked notch
frank sail
#

bounding box view is comically useless here lol

wicked notch
#

Onto figuring out how I went from broken to more broken then.

#

I do have to wonder how every other model I've tested just works (outside nsight) but I'll leave that for laterโ„ข๏ธ

wispy spear
#

now im curious too

#

blender uses 1 core to import and 1 core to export

#

disk io is also almost 0

#

smells like its not optimized at all

#

66ms sounds a lot - just exterior

#

i mdi this scene like 3 times (2x directional light shadow) 1x gbuffer

wicked notch
#

Everything I do borks it further KEKW

frank sail
#

None of us have AA though ๐Ÿ˜ข

#

Needs shadows to make it more canny ๐Ÿ˜„

#

Hmm, how much vram do you have deccer?

#

This scene uses over 16 gigs on my AMD machine since I don't have compressed textures

wispy spear
#

ram ram wise, was like 12GiB

wicked notch
#

I have been debugging an issue that doesn't exist for a long time.

#

Indices are good in NSight now

#

Just by removing layout (bindless_sampler) uniform and glMakeTextureHandleResidentARB

#

Which means my bindless texture usage is illegal in some way?

frank sail
#

did you fix your debug callback setup yet

wicked notch
#

Yeah, been silent all this time KEKW

frank sail
#

classic

wicked notch
#

I really didn't have to comment much from the shader

#

Just this chunk:

layout (bindless_sampler) uniform;
layout (std430, binding = 5) readonly restrict buffer b_texture {
    sampler2D[] textures;
};```
#

And somehow NSight now likes my program

frank sail
#

you should read the extension spec for GL_ARB_BINDLESS_TEXTURE to make sure you didn't goof somehow

wicked notch
#

So it took 1 day and a few minutes this morning

#

To remove layout (bindless_sampler) uniform; (was causing big issues)

#

And make sure I was reading the correct set of UVs

#

Today I learned there can be more than one set of UVs in a mesh

wispy spear
#

i dont think its even necessary, that layout thing, i dont have it anywhere in my shaders at least

wicked notch
#

I will save this snippet because it's pretty cool though:

vec3 hsv = vec3(fract(M_GOLDEN_CONJ * (i_diffuse_texture + 1)), 0.5, 0.95);
if (i_diffuse_texture == -1) {
    hsv = vec3(0.0, 0.0, 0.0);
}
diffuse = hsv_to_rgb(hsv);```
wispy spear
#

what does it do?

#

shift a color hue

wicked notch
#

For each number it associates a completely unique color

#

Because math apparently

wispy spear
#

yeah, you find this "question" or "talk" scattered across the server sometimes

#

when people implement vbuffer or just go mdi and want to visualize materialids or any other id

#

implodee? i think used a cool cosine based function for that, i believe its in #wip

#

#wip message

frank sail
#

Make sure you fix the spelling before using the code

wicked notch
#

And we're back to where we were (now without bugs).

twin bough
#

Nice job

wicked notch
#

NSight still sends me to the backrooms if I dare to use more than one VBO

wicked notch
#

Holy shit

#

I have no idea how this worked before

#

But I fixed it, this was a super extra large bug.

wicked notch
#

Alright, NOW all (obvious) bugs have been fixed

wispy spear
#

i dont even know what you are talking about

#

when you talk about nvidia bugs ๐Ÿ˜„

#

perhaps this warrants a minimap code example that everyone can try to reproduce, and if its an actual bug we could raise it somewhere ๐Ÿ™‚

wicked notch
#

No no it's my fault haha

#

I fixed it, the indirect groups I was creating were mismatched at some point with the objects

wispy spear
#

ah : )

wicked notch
#

Damn KTX is a lot of work

frank sail
#

Let me know when you get it to work so I can copy you

wicked notch
#

Could've just bought a 7900xtx

#

As God intended

#

24GB of VRAM

wispy spear
#

you could just get the w7900

#

as Lisa intended

#

48gb

wicked notch
#

Alright, I rewrote the entire loading thing for the third time

#

Let's see if I've got good enough to make this work first try (spoiler: no)

#

It doesn't even compile

#

First segfault of many to come

wicked notch
#

Is there no DSA glCompressedTexImage2D?

frank sail
#

I guess not

wicked notch
#

Thankfully I don't really need that, I actually need the Sub thing.

frank sail
#

also no immutable storage for them

wicked notch
#

And we segfaulted once more, the counter is at 12 for now.

#

Memory is hard

#

Lovely vertex data

frank sail
#

or maybe you can do it all at once with glTextureStorage2D

wicked notch
#

"It works" meaning "I don't segfault but because the rest of my program is broken beyond god's help I can't test if it actually works"

frank sail
#

the ref page for glTexStorage2D is probably wrong, since it doesn't include compressed texture formats

#

internalformat must be one of the sized internal formats given in Table 1 below, one of the sized depth-component formats GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT16, one of the combined depth-stencil formats, GL_DEPTH32F_STENCIL8, or GL_DEPTH24_STENCIL8, or the stencil-only format, GL_STENCIL_INDEX8.

#

very sus

wicked notch
#

I saw how KTX-Software implements ktxTexture2_GLUpload and it uses glTexStorage2D + glCompressedTexSubImage2D with compressed formats so we're good (assuming Khronos doesn't L I E)

#

Also gltfpack was quantizing my vertices

#

So we got funny vertex data.

frank sail
#

I was looking at the GL spec, but it's quite annoying as it takes you on a wild goose chase trying to find what's legal

wicked notch
#

Yeah I spent a whopping 5 minutes looking at glTextureStorage2D for any sign of compressed formats

#

I gave up and went to see an actual implementation

frank sail
#

Does libktx come with a compressor, or is it just for reading and writing ktx files?

#

Ideally, I'd like to be able to load gltfs with or without compressed textures, but always have compressed textures internally (for minimizing bandwidth and VRAM usage)

wicked notch
#

It does, but I just use gltfpack to compress textures

#

It does it automagickally

frank sail
#

Hmm that lib sounds familiar

#

Looks pretty nice

#

Do you invoke it at runtime?

#

I was considering compressonator, but this looks much more automagic for my needs

wicked notch
#

Hopefully I'll have something that looks at the glTF, tells me if it's optimized and if it isn't I invoke gltfpack

#

Well it's a start...

#

hOLY POG IT WORKS

twin bough
#

Pog

#

Nice work

wicked notch
#

Now I can load bistro diffuse + normal maps without killing my GPU in the process

twin bough
#

How's ๐Ÿ…ฑ๏ธerf

frank sail
wicked notch