#DARE (Danny's Awesome Rendering Engine)

1 messages Β· Page 4 of 1

dawn wave
#

i realized

#

my code doesn't even do type conversion

#

as it will auto return if it's the same type

#

which most are

#

so bleakekw

devout mesa
#

show me the new loading code

dawn wave
#

you would cry

#

so i won't

devout mesa
#

I know, I will not ask you to nuke it

#

for now

dawn wave
#

KEKW ill nuke it soon-ish after i fixed this stupid bug

devout mesa
#

it's not that bad actually

dawn wave
#

This is the best compliment I have recieved in my lifetime KEKW

devout mesa
#

minus this garbage of course get_accessors_from_primitives

dawn wave
#

KEKW yeah that is garbage

devout mesa
#

This should instantly disappear but w/e

#

can't really find the bug though

#

it doesn't help that me and rust are infinitely distant bleakekw

dawn wave
#

yeah that's the issue. my tests are passing, smaller meshes work but larger meshes bork

devout mesa
#

try it out with the smol mesh that bork

dawn wave
#

oh yeahh

#

maybe i'll go through it's gltf file and see what is causing it

devout mesa
#

I mean

#

you have a debugger right?

#

use that

dawn wave
#

yeah my debugger is saying it works well too KEKW

#

images are all loading

devout mesa
#

Right I meant stepping in the code

dawn wave
#

the buffer is fine so this is really ethereal

#

ohh yeah

#

ill do that

#

but like my print statements kinda did that bleakekw

devout mesa
#

uh

#

right

#

use a debugger thanks

dawn wave
#

LMAOO

#

okok

devout mesa
#

I can only accept print statements inside shaders

dawn wave
#

wait you can do that?

#

okay so i did debugging

#

and uh

#

it went normally bleakekw

devout mesa
#

It's basically the number 2 major reason why Vulkan appealed to me so much

dawn wave
#

WAIT YOU CAN?

devout mesa
#

the number 1 major reason was validation layers

#

yes, you can't in OpenGL though 😭

dawn wave
#

how

#

show me the way

dawn wave
#

it...

#

no way

#

debugPrintfEXT

#

All hail debugPrintfEXT

#

is there a vulkan extension that needs to be enabled as well?

#

i refuse to believe

#

it's this easy

#

no way

devout mesa
#

just debug utils

#

well

dawn wave
#

oh KEKW phobos has abstracted this away from me

devout mesa
#

VkValidationFeaturesEXT as well

#

but you really shouldn't use validation layers in your app

#

just use vkconfig

dawn wave
#

what

#

ohh

#

use the built-in sdk stuff

#

oh phobos has indeed

#

hidden this away from me

#

AHHH I NEED TO STOP GETTING DISTRACTED

devout mesa
#

mate

#

just use vkconfig

dawn wave
#

oh Debug Output

#

i completely forgot

#

vkconfig

#

thank you for reminding me of it

dawn wave
#

so uh

#

everything works fine

#

yet my uvs

#

scream otherwise

#

I LIED THEY DO

#
Mesh index: 67379424548
[Shader] My albedo_texture ID: 0.000000 - 2955270660 

Now my critical thinking brain is telling me

#

67379424548 != 2955270660

#

Hear me out

#

so the issue was

#

actually how i represented my meshes

#

πŸ€”

devout mesa
#

Texture ID being float is also very concerning

dawn wave
#

kekw that is me being dumb

#

ill change it to int

#

iirc %i

#
struct ObjectDescription {
    // 0 - None
    uint64_t vertex_buffer;
    uint64_t index_buffer;
    uint64_t normal_buffer;
    uint64_t tex_buffer;
    int material;
};
#

hmmmm this should be fine?

devout mesa
#

sure

dawn wave
#

I just need to make sure to include the scalar block i think

devout mesa
#

scalar block layout will save your ass every time

dawn wave
#

yeah

#

hmmm

#
#[repr(C)]
#[derive(Clone, Copy, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct CMesh {
    pub vertex_buffer: u64,
    pub index_buffer: u64,
    pub normal_buffer: u64,
    pub tex_buffer: u64,
    pub material: i32,
}
devout mesa
#

unfortunately I do not read Rust spec

#

so I dunno alignment rules

#

assuming Rust is a sane language, this should be fine

dawn wave
#

well repr(C) forces it to follow c alignment rules

devout mesa
#

Then it is probably fine, uncertain

dawn wave
#

so I think we should be fine?

devout mesa
#

do you have #pragma pack(push, 4)?

dawn wave
#

huh?

#

oh alignment?

devout mesa
#

can you manually tell rust how to align a struct

dawn wave
#

yeah

#

align(x)

devout mesa
#

i.e: I want to align this to 4 bytes please

dawn wave
#

WAIT FUCK

#

we don't

#

hehe

#

hehehe manual alignment

#

😎

#

nvm we do

#

that uh didn't fix it

#

in fact i'm starting to think this debug output

#

is faulty

#

and wrong

devout mesa
#

that is extremely unlikely

dawn wave
#

it's weird how it;s only outputting that however

#

like you would think it would output other things too for other primitives

#

but it only outputs that

#

also tilting my camera too far will cause it to crash bleakekw

devout mesa
#

you may have your vkconfig set to call std::terminate on debug output

dawn wave
#

uhh where is that?

#

oh I don't think I did so

#

if you're talking about the Break under Debug Action

devout mesa
#

ye that's not it

#

you may have UB I guess

#

does it happen without validation on?

dawn wave
#

no it doesn't

#

but oddly only happens with the vkconfig validation layer

#

what

#

the bug fixed itself

#

what the

#

it seems like one mesh is causing the behavior

devout mesa
#

ah yes

#

bugs fixing itself

#

or as I like to call it

#

undefined behavior

#

or unacceptable behavior

dawn wave
#

ill uh hunt it down

#

it's weird it only happens when the validation layer is on only but the vkconfig one

#

the one phobos has doesn't crash

devout mesa
#

just for the record

#

validation layers are one and the same

#

the ones enabled through the app and enabled through vkconfig

#

they call into the same functions and use the same parameters

dawn wave
#

oh

#

Seems like it's the GPU base causing the crash

#

i lied it was the printf

#
debugPrintfEXT("My albedo_texture ID: \n");

I have no clue how this is even causing the crash

#
WARN  phobos::core::debug             > [VALIDATION]: UNASSIGNED-DEBUG-PRINTF (-1841738615): Validation Warning: [ UNASSIGNED-DEBUG-PRINTF ] Object 0: handle = 0x203f484d020, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x92394c89 | WARNING - Debug Printf message was truncated, likely due to a buffer size that was too small for the message
#

I thought the message size only applies to per-message

#

does it apply to the entire log?

tropic vigil
#

btw @dawn wave you can add extensions in phobos just fine

tropic vigil
devout mesa
#

if you call debugPrintfEXT too many times you will overrun the buffer

dawn wave
#

AHHHHH

#

makes sense

devout mesa
#

you are supposed to call it once per subgroup or only in one or two invocations

#

it is not a tool to be used lightly

dawn wave
#

hm how to have it run once

devout mesa
#

if (all(equal(gl_LaunchIDEXT, ivec2(0))))

dawn wave
#

gotcha thanks

devout mesa
#

or any pixel you want

#

you can specify a range, whatever you want

dawn wave
#

Mhm crash is no more

#

that was it thank you

#

I have unfortunate news huston

#

the addresses lineup

#

so it's not input

#

67379780100 = 67379780100

#

i need to think harder

#

the issue must be import then

#

ah i'll nuke the accessor function

#

and redo that and see if that fixes anything

#

Is there a gltf viewer that allows me to read the buffer data decoded?

#

okay so my buffer is correct so it isn;t the loader at least the accessors

#

images...

#

not images too

#

dafauq is causing it then bleakekw

#

Ahhh can someone look at my shader again

#

I'm talking the UV data from the gltf file

#

then using that directly to determine the UVs

#

yes, i have tried to invert the v component

dawn wave
#

this is what happens when i flip the components around

#

it's cohrenet but f'd up

dawn wave
#

JAHAHAHAAH

#

i found my first bug replication

#

clearly

#

something is wrong

#

(rotated wrong)

devout mesa
#

barycentrics are supposed to be vec3(1 - u - v, u, v) if that helps

dawn wave
#

hmm okok

#

does this look right...?

#
const vec3 barycentrics = vec3(1.0 - attribs.x - attribs.y, attribs.x, attribs.y);
#

this should be correct UVs

devout mesa
#

I mean I doubt NVIDIA would provide you with wrong barycentrics bleakekw

dawn wave
#

hmmm

#

now it's time to trial and error

#

each gltf file

#

and find the common demoninator

#

i realized the duck models are the same KEKW

#

it's just that they have diffenet lighting

#

now the average person wil say

#

"Wow, the channels seem reversed"

devout mesa
#

Uh no

#

there are big differences that aren't related to inverted coordinates

dawn wave
#

ya

#

maybe the indices are f'd?

#

that can't be possible however

#

if indices were f'd

#

vertices would be

#

so what

devout mesa
#

try with even simpler meshes

#

a plane

dawn wave
#

it works with stupid simple meshes

devout mesa
#

or a cube

#

then something is wrong with how you stuff things into buffers

dawn wave
#

probably

#

as simple meshes work fine

#
/// Convert a slice of bytes as another
fn cast_bytes_slice_type<
    T: 'static + num_traits::ToPrimitive + bytemuck::Pod + Sync,
    U: 'static + num_traits::NumCast + bytemuck::Pod + Send,
>(
    contents: &[u8],
) -> Vec<u8> {
    // If same type, return early
    if std::any::TypeId::of::<T>() == std::any::TypeId::of::<U>() {
        return contents.to_vec();
    }
    let from_size = std::mem::size_of::<T>();
    let target_size = std::mem::size_of::<U>();

    assert_eq!(contents.len() % from_size, 0); // Must be perfectly sliced

    // Cast contents (bytes) -> T -> Cast to U -> Reinterpret back to bytes
    let contents: Vec<U> = bytemuck::cast_slice::<u8, T>(contents)
        .par_iter()
        .map(|x| num_traits::NumCast::from(*x).unwrap())
        .collect();
    bytemuck::cast_slice::<U, u8>(contents.as_slice()).to_vec()
}
#

ah.

#

ah.

#

ah.

#

ah.

devout mesa
#

this is all uselessly clamplicated

#

don't you have a way to memcpy all the uvs of a primitive into a vector

dawn wave
#

i could

#

tbfh i should

devout mesa
#

it's a oneliner in C++

devout mesa
dawn wave
#

i could just memcpy it all

devout mesa
#

you must

dawn wave
#

yeah but type conversions :(

devout mesa
#

do you need those

#

have you actually come across a mesh where this code actually does something

#

I haven't

dawn wave
#

yes

#

wait have i don't keep track

devout mesa
#

well regardless

dawn wave
#

well i mainly use it to convert my indices to u32

#

which could be done in 3 lines KEKW

devout mesa
#

right that's one type conversion I will allow

#

sometimes models do come with u16 indices

#

but others are just useless

#

I'm not even telling you to nuke this code tbh

#

Just shelve it somewhere and use it when it is needed

#

Otherwise a memcpy will suffice

dawn wave
#

ill quickly override it

feral trellis
#

Why all of this bro

#

bytemuck does it for you no?

dawn wave
#

KEKW does it?

#

like do numeric conversion?

feral trellis
#

Then it isn't a byte cast

#

Why is there a comment saying this is a byte cast

dawn wave
#

ah fuck

feral trellis
#

If you're doing numeric conversions just use as

dawn wave
#

misinformation

dawn wave
#

as least with generics

devout mesa
#

common rust L

dawn wave
#

i had to use num_traits

#

tried adding a + Into<U>

#

complains about it being a non-primitive cast

feral trellis
#

Forgot to type the 't

dawn wave
#

we live another day

feral trellis
#

Still odd that you'd require to do something like that though

#

Where do you call cast_bytes_slice_type?

dawn wave
#

It's so I can do this

devout mesa
#

regardless

dawn wave
#

cast_bytes_slice_type<u8, u32>
cast_bytes_slice_type<u16, u32>
cast_bytes_slice_type<..., u32>

devout mesa
#

as a human being

#

i beg you

feral trellis
#

It seems overcomplicated nyo capperinos

devout mesa
#

do the simple thing first

#

like not even in programming

#

in life in general

dawn wave
#

yeah but complicated thing better

devout mesa
#

shrimple first

devout mesa
dawn wave
#

ok shrimple first

#

silently keeps code

devout mesa
#

that's fine

#

just don't use it until you actually need it

dawn wave
#

i see i see

#

see it's realistically only being used for my

#

indices

#

hmmmm

feral trellis
#

again

  1. make it work properly first, doesn't matter if the code is slow
  2. refactor
devout mesa
#

to be fair

#

it'll probably be fasterbleakekw

#

but ye

#

at the cost of sounding like a broken record, KISS

#

They even made a wiki page

dawn wave
#

ok i give up

#

ill memcpy

feral trellis
#

Yess I love kiss (KISS)

dawn wave
#

that uh didn't solve it

devout mesa
#

that's one less place to look at then

dawn wave
#

hmmm mismatched accessors?

#

nope

#
Tex buffer used by: Some("V-Tech_0 0"). Index: 6. Name: Some("V-Tech_0 0 accessor Gltf(TexCoords(0)) 6")
#

🫑 ethereal bug

#

after a whole day of bug hunting

#

this bug alludes me

#

🫑

#

indices can't be wrong.

#

i know that for sure

dawn wave
#

how do you i put it...

#

it seems wrong?

dawn wave
#

bro i'm so done with this bug man

#

i've verified that my buffers are indeed the same

#

wtf do i do

#

is it because the gltf package is importing things wrong?

devout mesa
#

this is just sRGB vs non sRGB

dawn wave
#

Ahhhh i haven’t learnt much of that yet

dawn wave
#

IH NY GOD

#

IS IT BECAUSE OF SRGB

#

NO WAY

#

OH MY FUCKING GOD

#

IS IT BECAUSE OF THAT?

#

NO WAY

devout mesa
#

srgb won't make a chunk of sponza have 0 uvs

dawn wave
#

oh 😒

#

yeah srgb really shouldn't affect anything

devout mesa
#

my reference sponza image is srgb btw

dawn wave
devout mesa
#

looks correct now

dawn wave
#

oh that was your iamge KEKW

#

i just repasted it so i don't have to scroll up

devout mesa
#

epic

dawn wave
#

i'm crying rn this bug is a menace

#

0.012300 29.703600 i:40 id:37

#

πŸ€”

#

it seems fucked

devout mesa
#

this be the uv?

dawn wave
#

yeah

#

of the red wall in that image

devout mesa
#

definitely fucked yes

dawn wave
#

hmm possible unintentional offset?

#

i'll try something stupid

devout mesa
#

it actually looks like the x and y components are swapped

dawn wave
#

i tried doing that

#

but it ends up fucked

#

ill play around with it

#

shifting does not help

#

ill try to reverse uit

#

0.012300 14.850000 i:62 id:37

#

uh

#

this seems wrong

#

swapping did not work

dawn wave
#

hyh

#

so it is swapped

#

14.85, 0.0123000145,

#

wait is it...

dawn wave
#

there is an offset

#

i can't figure out why

#

it seems to be -1.000

#

meaning UB

#

Buffer [0.6061, 0.9925]
vs
Shader -1.000000 0.606090

#

like it's obvious what the data is supposed to be

devout mesa
#

what are you comparing

dawn wave
#

data in the buffer itself

devout mesa
#

versus?

#

which is which

dawn wave
#

wdym?

devout mesa
#

Ah there it is

#

very much wrong indeed

dawn wave
#

yeah it seems to be a shift

devout mesa
#

at least you have a lead

dawn wave
#

idfk how that -1 is ending up there

#

as my buffer views are correct

devout mesa
#

-1.0 is 0xbf800000

#

if that helps

dawn wave
#

hmm

layout(buffer_reference, scalar) buffer TexCoords { vec2 v[]; }; // TexCoords

I believe this is fine for Vec2_F32

#
layout(buffer_reference, scalar) buffer Indices {ivec3 i[]; }; // Triangle indices

HMMMMM

#

all my indices should be uint

#

that fixed nothing

#

a shift that randomly appears...

devout mesa
#

I really don't think the issue is in the shader

#

as a quick test you could try displaying gl_PrimitiveID

dawn wave
#

Well my buffer says everything is perfectly fine

#

hmm ill try

#

but I doubt that is the issue

devout mesa
#

ye, it's how you memcpy it into the phobos buffer

#

if there is a mismatch between what the GPU sees and what the CPU sees

dawn wave
#

I checked already on the GPU

devout mesa
#

then the vkCmdCopyBuffer or the memcpy(buffer.mapped, ...) is wrong

dawn wave
#

there wasn't any issues

#

it is pulling a -1.000 out of it's arse

#

maybe i'm calculating my offsets wrong?

#

see shifting it back

#

by 4 bytes

#

reproduces it

#

uh i'm a bit stupid

#

how would I convert a bufferview's vkaddress (962140119452) into an index usable by nsight?

devout mesa
dawn wave
devout mesa
#

you don't KEKW

#

ye BDA tooling is sad

dawn wave
#

wtf am i supposed to do then

devout mesa
#

go into the device memory tool and find the buffer

dawn wave
#

i uh found it

#

zero clue how to convert it though

devout mesa
#

wym convert

dawn wave
#

take the address given and find the index

devout mesa
#

yeah no that's not how addresses work

dawn wave
#

pain

devout mesa
#

GPUs too use virtual memory

dawn wave
#

this is a problem i cant seem to fix bleakekw i got zero clue what is causing this
My buffers on cpu are fine

#

gpu seem fine

#

but that assumes the offsets are right which i assume they would be

#

maybe this is some fukery related to alignment?

#

But buffers aren't subjected to those same rules

devout mesa
#

I can't compile your shit

#

error[E0560]: struct `phobos::image::ImageCreateInfo` has no field named `memory_type`
   --> src\assets\scene\loader\gltf.rs:769:21
    |
769 |                     memory_type: phobos::MemoryType::GpuOnly,
    |                     ^^^^^^^^^^^ `phobos::image::ImageCreateInfo` does not have this field
    |
    = note: available fields are: `width`, `height`, `depth`, `usage`, `format` ... and 3 others
dawn wave
#

oh KEKW i haven't updated it

#

my changes to the git

devout mesa
#

this man making me write rust

#

smh

dawn wave
#

LMAOO you don't need to 😭

#

it's fine i'll uh mald through this

devout mesa
#
match image_data.format {
    Format::R8 | Format::R16 => vk::Format::R8G8B8A8_UNORM,
    Format::R8G8 | Format::R16G16 => vk::Format::R8G8B8A8_UNORM,
    Format::R8G8B8 | Format::R16G16B16 | Format::R32G32B32FLOAT => {
        vk::Format::R8G8B8A8_UNORM
    }
    Format::R8G8B8A8 | Format::R16G16B16A16 | Format::R32G32B32A32FLOAT => {
        vk::Format::R8G8B8A8_UNORM
    }
}``` also wtf is this
dawn wave
#

shhh

devout mesa
#

you return the same thing all the time

dawn wave
#

yeah i know

#

it's old cod-

devout mesa
#

epic

#

just push

#

something that I can compile

dawn wave
#

will it even work on your system bleakekw

#

main.rs 102 is where you indicate file location to load assets

devout mesa
#

not an issue

#

unless you use SER i can run anything

dawn wave
#

SER?

devout mesa
#

shader execution reordering

dawn wave
#

oh heard that new tech was really good for having a shit ton of shaders

#

also changes pushed

devout mesa
#

"use of unstable library feature" what

dawn wave
#

what

#

oh fuck you need to switch over to unstable branch of rust

devout mesa
#

how do I do that

dawn wave
#

rustup install nightly
rustup override set nightly

#

do in the project directory

#

oh yeah ignore anything to do with transition layout KEKW

#

it was blindly copy pasting it from older code

#

so it's gonna produce errors

#

oh yeah scroll wheel to increase camera speed

devout mesa
#

damn it's unbearably slow

dawn wave
#

yeah ik that's because the uh

#

printf thingy

#

if i disable it, it becomes way faster

devout mesa
#

no, the loading

dawn wave
#

oh yeah it's shitte

#

i made it all single threaded

#

cuz i became paranoid it was misordering of stuff

devout mesa
#

nah, singlethreaded is good

#

I can load bistro in less than a second, singlethreaded

dawn wave
#

oh then it's doodoo architecture

#

or the gltf importing

#

i'm using the default one by the package KEKW

#

that might also be why

#

ill try to add padding and see if that fixes it

#

istg if this was padding issues this whole time

#

@devout mesa IT WAS PADDING

#

LMAOOOOO

#

IT WAS FUCKING PADDING

devout mesa
#

this man managed to get a padding issue with scalar block layout

dawn wave
#

idfk how i did it too

#

all my types are multiples of 4

#

oh no

#

problem still exists

#

bleakekw manual padding

#

you know

#

i think you were right

#

in the idea of making giant f32 vecs

#

dealing with the mess that this is

#

oml

dawn wave
#

It isn't that bad nvm

#

I compacted all my buffers into one vector which is why i got alignment issues. I didn't align them

#

tears in my eyes

#

i need mip mapping

devout mesa
#

was it padding?

dawn wave
#

yeah

#

So I was storing it all into one monlithic buffer

#

but storing it as bytes

#

so I could just throw it all into it

#

and I forgor padding

#

it was a simple fix. alignment - (offset % alignment) where alignment is size of dimension * component_size

devout mesa
#

epic

devout mesa
#

good luck my boy

dawn wave
#

🫑

#

it can't be as bad as the padding issue

#

that's all i know

devout mesa
#

sure KEKW

dawn wave
#

i'm gonna settle of linear mip maps and no more none of that fancy compute shader stuff with like trilinear or smth whatever penguin did

devout mesa
#

I'm afraid, but mipmaps are a sort of fever dream with RT

#

it's not as easy as enabling them

dawn wave
#

wdym

devout mesa
#

well go ahead and try different things

dawn wave
#

oh no

#

Could you uh

#

not use distance from origin to hit to determine the mip map level?

#

or am I beyond brain dead

devout mesa
#

no

#

do you know how mips work with regular rendering

dawn wave
#

not really bleakekw I know that they're smaller compressed versions of their original textures which are then selected depending on their distance

devout mesa
#

I'm strictly speaking about selecting a mip btw

#

and no, they are not selected based on distance

#

when you call texture the hw will compute a gradient for your uvs and compute partial derivatives

#

these derivatives are used in the formula 1 + floor(log2(max(dudx/dudy, dvdx/dvdy)))

dawn wave
#

mhm

devout mesa
#

this ain't possible with RT

#

because you don't have triangles from neighboring invocations to take derivatives from

#

you have rays

#

and rays can intersect any triangle of the scene

#

so you get ridiculous numbers

dawn wave
#

mhm

devout mesa
#

therefore

#

I present to you two solutions

#

The second one is easier than the first one, but exponentially more expensive

dawn wave
#

ray cones

#

:D

#

so this mayber

#

is worse

#

this looks like hell

#

so does a ray cone

#

basically simulate what we want from the pixel quad?

devout mesa
#

uh

#

disclaimer

#

I don't understand either of these techniques bleakekw

dawn wave
#

Oh bleakekw

devout mesa
#

so good luck

dawn wave
#

LVSTRI i'm gonna join you in radiance only

#

textures are for nerds

#

oh

#

they have code

#

thank god

#

okay we're safe

#

oh

#

it isn't that bad

#

huh

#

I think I understand it?

#

Oh it makes sense

dawn wave
#

ah fuck this

#

let's do actual ray tracing

#

i'll get punctual lights working

#

then it's off to the rays

#

i wanna pretty lights not mf debugging

devout mesa
#

one piece of advice

#

iteration >>> recursion

#

do not even consider recursion where possible

dawn wave
#

yeah i've learnt that from the nvidia

#

recursion -> oh no

#

me when my shader exponentially recursively grows

#

ahh i need to restudy raytracing theory and all i completely forgor it all

devout mesa
#

I'll tell you raytracing theory

#

random

dawn wave
devout mesa
#

just random

dawn wave
#

Integration -> Sum

devout mesa
#

now go trace light

#

with randomness

dawn wave
#

but pdfs :(

#

those are scary

#

i've never understood them

devout mesa
#

random

#

everything is a normal distribution

#

do random

#

think later

#

random first

dawn wave
#

random

#

shoot random

#

oh wait brdf

#

eh lambertian

devout mesa
#

bro legit just do

for (bounce = 0; bounce < N; ++bounce) {
    trace_ray();
    if (hit) {
        ray_color *= hit.material.color;
        incoming_light += hit.material.emissive_strength * hit.material.emissive_color * ray_color;
        ray.origin = ray.origin + ray.t * ray.direction;
        ray.direction = random_lmao();
    } else {
        break;
    }
}
imageStore(output, gl_LaunchIDEXT.xy, incoming_light);
dawn wave
#

start shrimple ok

dawn wave
#

AHHHHHHHHHHHHHHHHHHHHHHHHHHHH

#

alignment

#

once again

#
/// Represents the material c-struct for use in shaders
#[repr(C, align(16))]
#[derive(Copy, Clone, PartialOrd, PartialEq)]
pub struct CMaterial {
    pub albedo_texture: i32,
    pub albedo_color: [f32; 3],
    pub normal_texture: i32,
    pub emissive_texture: i32,
    pub emissive_factor: [f32; 3],
}
#

this still doesn't work

devout mesa
#

why the hell align 16

#

do you hate yourself

#

align 4

dawn wave
#

yeah but it's complaining about the stride not be a multiple of 16

devout mesa
#

who's bitching

dawn wave
#

the validation layer

#

and it crashes

#
 ERROR phobos::core::debug             > [VALIDATION]: VUID-VkShaderModuleCreateInfo-pCode-01379 (706474367): Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01379 ] Object 0: handle = 0x2283e778f30, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x2a1bf17f | SPIR-V module not valid: Structure id 40 decorated as Block for variable in StorageBuffer storage class must follow relaxed storage buffer layout rules: member 0 contains an array with stride 36 not satisfying alignment to 16
#

Do I just bite the bullet

#

and add padding into the struct itself?

devout mesa
#

do you use scalar block layout

#

for that ssbo

dawn wave
#

yes

devout mesa
#

are you sure

dawn wave
#
layout (set = 1, binding = 2, scalar) buffer MaterialDescription_ {
    MaterialDescription m[];
} MaterialDescriptionArray;

Seems very scalar to me

#

also alignment issues somehow still exist bleakekw

#
/// Describes the material properties of the object
struct MaterialDescription {
    // -1 - None
    int albedo_texture;
    vec3 albedo_factor;
    int normal_texture;
    int emissive_texture;
    vec3 emissive_factor;
};
#

ahhh ill bite the bullet

#

and just throw junk data for padding

dawn wave
#

AHHH

#

i don't get it dawg

#

i'm so lost why it is complaining about this

devout mesa
#

btw

#

I use vec3's all the time with scalar block layout

#

And there has never been any complaint, so there must be something wrong

#

did you recompile your shaders

dawn wave
#

yes hmmm

#

ahh ill play it safe

#

convert my structs to bytes

#

then upload it

devout mesa
#

wat

dawn wave
#

i don't get it either

devout mesa
#

you weren't doing that?

dawn wave
#

no i was letting phobos do it

#

it was probably tightly packing all of it

#

which is possibly why it borked

devout mesa
#

which is good actually

#

you want everything contiguous, zero padding

dawn wave
#

yeah and i end up with alignment issues with me textures

#

it's how i ended up getting a normal texture of a flower to show up

#

100% certain

#

this is the same behavior

#

of misaligned (these are supposed to be normals)

devout mesa
#

remember to align(4)

dawn wave
#

no :(

#

it didn't fix it

devout mesa
#

uh

#

I dunno what kind of issue this is tbh

#

it could be a skill issue

#

or a Rust issue

#

or a phobos issue bleakekw

tropic vigil
dawn wave
#

no way phobos

#

mfw the normals give me the tangent

#

this is a certified alignment moment

devout mesa
#

scalar block layout was supposed to save you from alignment

#

at least it did for me bleakekw

dawn wave
#

it betrayed me

#

f32, int

#

shouldn't cause issues

#

why

#

WHAT DOES THIS

#

EVEN MEAN ANYMORE

#
 ERROR phobos::core::debug             > [VALIDATION]: UNASSIGNED-Debug-Printf (-1804403757): Validation Error: [ UNASSIGNED-Debug-Printf ] Object 0: handle = 0x1b44e54a300, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x9472fbd3 | Error during shader instrumentation: line 176: Structure id 40 decorated as Block for variable in StorageBuffer storage class must follow relaxed storage buffer layout rules: member 0 contains an array with stride 36 not satisfying alignment to 16```
tropic vigil
#

array elements must align to 16 bytes

dawn wave
#

they are bleakekw

devout mesa
#

there is no array in the material struct

tropic vigil
#

was

devout mesa
#

also what the hell is that rule, never heard of it lol

dawn wave
#

do I just change my struct to align(16)?

tropic vigil
devout mesa
#

I mean

tropic vigil
#

just pad it manually to 48

#

imo

dawn wave
#

ahh junk data

#

bet

devout mesa
#

I have structs that have odd byte sizes btw

#

never had vulkan complain lol

dawn wave
#

well my vulkan is built different

tropic vigil
#

lol

dawn wave
#

hmmm

devout mesa
#

I have a buffer that's 1584365 bytes in size

dawn wave
#

so i figured it out

#

it seems to think

#

wait

#

it's a shift

#

again

#

oh my god

#

no i refuse to deal with this

#

if i pretend the issue does not exist

#

it doesn't exist 😏

tropic vigil
#

why

dawn wave
#

ah. it's 100% an alignment issue

#

i can't figure out what would be causing it

tropic vigil
#

its tricky to track down

#

i just never use vec3s tbh

dawn wave
#

it's obvious as

  1. this does not affect smaller meshes
  2. this does affect larger meshes
  3. it's a small shift of 1-2 indices
#

kowalski analysis

tropic vigil
#
struct MaterialDescription {
    // -1 - None
    vec4 albedo; // xyz is factor, w is texture (cast to int)
    vec4 emissive; // same
    int4 normal; // x used, yzw unused
};
#

this is what i would use

dawn wave
#

OHHHHHHHHHH

#

cook

#

wait what about tangents?

tropic vigil
#

what about them

dawn wave
#

nvm i'm stupid

tropic vigil
dawn wave
#

i'll yoink and twist that

#

this wouldn't be align to 16 bytes however

#

wait i'm brain dead

#

please ignore me

tropic vigil
#

it does KEKW

dawn wave
#

4*4

#

i literally forgor

#

Praige

#

no work :(

#

WAIT

#

THIS WAS BETRAYAL BY MY ASSET SYSTEM

#

plot twist of the century

tropic vigil
#

lmao

dawn wave
#

i was an idiot

#

i used my texture

devout mesa
dawn wave
#

to determine the index of the image and not my image

#

hehehe

#

now uh how do i make an image that i can use to average out my results

#

i forgor

tropic vigil
#

make storage image

#
if (pc.frame_id > 0) {
        vec3 old_color = imageLoad(old_image_in, ivec2(gl_LaunchIDEXT.xy)).xyz;
        // Calculate contribution ratio of this frame's color data
        float a = 1.0f / float(pc.frame_id + 1);
        // Mix the old and new colors together
        vec3 final_color = mix(old_color, hit_value, a);
        // Store to the image
        imageStore(rt_out, ivec2(gl_LaunchIDEXT.xy), vec4(final_color, 1.0));
    } else {
        // This is the first frame rendering this scene, we don't need to do any 
        // accumulation, simply store the value
        imageStore(rt_out, ivec2(gl_LaunchIDEXT.xy), vec4(hit_value, 1.0));
    }
#

increment frame_id and reset when anything changes

dawn wave
#

hmm okokok

devout mesa
#

why do you want to average results you don't have

#

first you get results

#

then you average

tropic vigil
#

real

dawn wave
#

you're not wrong

devout mesa
#

I will not allow you to write averaging code until I see a noisy image

dawn wave
#

okok

#

let me get results first

#

uh skybox

#

= blue

#

:)

dawn wave
#

fuck how do you generate

#

random ahh directions

devout mesa
#

generate 3 random numbers with a normal distribution

#

normalize the result

#

a normal distribution is spherically symmetrical

tropic vigil
#

Im not sure if that’s uniform

dawn wave
#

uniform?

#

oh the same probability all around

#

i don't think it would be

devout mesa
#

it's uniformly distributed on a unit sphere

tropic vigil
#

Alright

#

Ill believe it

devout mesa
#

lemme get the source

dawn wave
#

how to uh generate normal distribution of random number

#

fuck nvm,

dawn wave
#

uh how would I calculate the final color

dawn wave
#

maybe I'm stupid but how is ray_color relevant then?

devout mesa
#

I forgor to mul it by the inc light

dawn wave
#

lmaoo okok it makes sense

devout mesa
#

there

dawn wave
#

ah fuck i forgot

#

in emissive textures

#

R channel is the only one you only care about yeah

#

no im stupid

#

i am begging

#

can i finally average :D

#

pls

devout mesa
#

good, you may average

dawn wave
#

aw fuck

#

it's too late i'm addicted to staring at sponza

#

it's joever

devout mesa
#

Ah yes

#

I have experienced that as well

dawn wave
#

i wonder what bistro is like

#

did you have emissives in your model you sent to me

devout mesa
#

probably I dunno

#

just do sunlight

dawn wave
#

ik one doesn't have it

devout mesa
#

sun

#

make the sun illuminate le sponza

dawn wave
#

no :(

devout mesa
#

yes

dawn wave
#

nuh yh

devout mesa
#

the sun is epic

#

#1090390868449558618 message

#

look how gud the sun is

dawn wave
#

ok fine

#

🫑 goodbye pc

#

there has to be a better way of formatting my images

#

it takes up 90% of my loading time

#

for doing something relatively minor

devout mesa
#

I have never had to poke an image's format btw

dawn wave
#

kekw

#

wtf how did you get

#

r8g8b8 to work then

#

what format did you use?

devout mesa
#

I did not

#

I always use rgba8

dawn wave
#

o-

devout mesa
#

I just don't care about it

dawn wave
#

wtf

#

i try to do that

#

then crash

devout mesa
#

either rgba8 srgb or unorm depending on the texture

dawn wave
#

yeah i try setting my format to r8g8b8

#

then it crashes

#

and say it's unsupported

devout mesa
#

right, no one supports rgb8

dawn wave
#

ya

#

maybe i'm doing this wrong then KEKW

devout mesa
#

just use rgba

dawn wave
#

yeah but that means i have to go through each pixel and add an A channel

devout mesa
#

what kind of textures require you to do that

dawn wave
#

huh i assumed you had to add the a channel

devout mesa
#

no I mean

dawn wave
#

or else it would end up taking the next pixel's R channel

devout mesa
#

usually you can load base color and normal textures as rgba just fine

#

I recall

#

hmm

#

yes you mentioned your gltf library being dumb and stupid

dawn wave
#

yeah

#

it doesn't automatically format the images i import in

#

as rgba

#

nono it insist

#

i take the rgb

#

because uh

#

I'll probably find another image import crate

#

that can do that for me

devout mesa
#

yes

dawn wave
#

anyways

#

🫘 stro

devout mesa
#

sun

dawn wave
#

i dimmed it

devout mesa
#

I want a sun right now

#

right this instant

#

you have 5 picoseconds

dawn wave
#

oh fuck

#

how to generate sun

#

i need like shit tons of hydrogen

devout mesa
#

I'll leave that as an exercise

#

hint: you don't make a sun by making a literal flaming ball of death

dawn wave
devout mesa
#

you use good ol math

dawn wave
#

probably but rn i should focus more on getting my entire engine polished

#

shrimple then refine

devout mesa
#

no

#

I'm willing to make an exception for pretty graphics

dawn wave
devout mesa
#

pretty graphics rule

dawn wave
#

ReSTIR any%

devout mesa
#

anyway

#

make sun

#

with mathematique

dawn wave
devout mesa
#

think, what is a sun ray

dawn wave
#

let me add averaging

devout mesa
#

no sun is easier

#

do sun first

dawn wave
#

think

#

a sphere

devout mesa
#

a sun ray is a sphere?

dawn wave
#

but realistically a circle

#

oh a ray

devout mesa
#

what direction do sun rays have

dawn wave
#

1

#

usually uniform

devout mesa
#

what the hell do you mean 1

#

magnitude?

dawn wave
#

im so lost

#

like general direction or like direction direction

devout mesa
#

think about the sun irl

dawn wave
#

oh

#

infinite?

devout mesa
#

yes

#

well 150 million km away but we can consider that infinite distancebleakekw

#

so we can think about sun rays being always in the same direction

#

ie parallel to each other

#

now how do you trace a sun ray

dawn wave
#

you just point that ray in the direction to the sun

devout mesa
#

yes

dawn wave
#

wait how would i add this nicely

#

without having to do a seperate ray trace

#

for the sun for each bounce

devout mesa
#

what happens then

dawn wave
#

if it misses, then it's in the sunlgiht therefore sun

devout mesa
#

wrong

#

not for each bounce

dawn wave
#

the final bounce?

devout mesa
#

yes

dawn wave
#

hmhmhm okok

#

you know

#

what is a virtual resource

devout mesa
#

wat

#

where did this come from

dawn wave
#

it's phobos thingy

devout mesa
#

ah

#

no idea KEKW

dawn wave
#

hmmmm

#

does this resource last

#

or is it just a per-frame thing

#

judging by how it's being refreshed every frame

#

i assume so?

devout mesa
#

where sun

dawn wave
#

sun :D

#

🌞

#

i forgor how to make another shader

#

and tell it explicitly to use that shader

devout mesa
#

you don't need it for the sun me mate

#

make sun

dawn wave
#

but i get pissed off

#

if i have to do some fuckery

#

and make a monolithic shader

devout mesa
#

uber shaders are the best

#

DOOM eternal uses exclusively uber shaders

dawn wave
#

ah fuck

#

doom

#

now i have to agree they're good

devout mesa
#

they are the best solution to an impossible problem

dawn wave
#

what about that new out order shader execution thingy

devout mesa
#

only available on 40 series

#

stop getting distracted and make a sun

dawn wave
#

then i;ll target only for 40 series

devout mesa
#

you don't even have a 40 series card

dawn wave
#

mhm

#

huston

#

we have a problem

#

i am stupid

#

tf do i make the direction

devout mesa
#

I dunno

#

normalize(vec3(0.25, 0.75, 0.25))

#

sounds like a good direction to me

dawn wave
#

okok

#

bro

#

it's pitch black KEKW

devout mesa
#

amazing

dawn wave
#

ill uh

#

fix it

#

let there be ligt

#

guys

#

i think i fucked up the entire shader

devout mesa
#

unfuck it then

dawn wave
#

what did you make me do

devout mesa
#

doesn't look like sun to me

dawn wave
#

no looks like we're about to enter it

#

idfk

#

what is happening here

devout mesa
#

ight

#

now you may average

dawn wave
#

ah fyck

#

how do i account for cosine distributed hemisphere

dawn wave
#

Uhh

#

How do I create another push constant...

#

it isn't working for me KEKW

#
.push_constant(vk::ShaderStageFlags::RAYGEN_KHR, 0, &view)
                    .push_constant(vk::ShaderStageFlags::RAYGEN_KHR, 64, &projection)
                    .push_constant(vk::ShaderStageFlags::RAYGEN_KHR, 128, &self.frame_id)