TheOverfloater / pathos-public

Public release of Pathos Engine
MIT License
36 stars 7 forks source link

general place to bind textures in r_bsp.cpp? #37

Open valina354 opened 3 days ago

valina354 commented 3 days ago

i added parallax occlusion mapping to engine but i got issue which is that for some reason when dlights are on the texture binding itself breaks or something and bleeds into other ones i added this image and this image

below if(pmaterial->ptextures[MT_TX_LUMINANCE]) {

functions, in area with no dlight it looks fine like this image

but in area with dlight it breaks image

without height texture being defined this doesnt happen, so i think im binding in wrong places

valina354 commented 3 days ago

@TheOverfloater

valina354 commented 3 days ago

i notice when entering dlight area this stops triggering inside of BindTextures everything else too most likely causing the issue image

valina354 commented 3 days ago

when outside of dlight only bindtextures runs, and when inside dlight only drawfirst runs, i dont get what im doing wrong, im doing exact same as mt_tx_luminance

valina354 commented 3 days ago

it also occurs for mt_tx_ao i added

valina354 commented 3 days ago

this is my entire r_bsp.cpp to btw https://pastebin.com/gmPaQQtE

TheOverfloater commented 3 days ago

I'm afraid I can't really help here unless I were there to debug the code myself. Basically you need to use the debugger yourself to see why it doesn't trigger to begin with, it means you could be trying to use the wrong material, or that particular texture unit itself is being set to null for some reason. VS2022 allows you to set a breakpoint that triggers when a value in memory is changed, it is called a Data Breakpoint.

valina354 commented 3 days ago

i notice same thing occurs with mt_tx_luminance but in luminance it doesnt break it which is strange and it also cant be shader related because same thing occurs with ao which is well very simple just multiply by binded ao map so very strange

valina354 commented 3 days ago

i figured out i need to also blind in drawlights however it seems to cause another issue, for some reason it seems only normal and specular gets displaced, not maintexture while without dlight it renders fine very strange image

valina354 commented 3 days ago

it seems that for some reason when doing dlight it doesnt bind maintexture but even manually binding it doesnt fix

valina354 commented 2 days ago

i now tested with default luminance and even that is broken, doesnt work correctly in dlight area, i wonder if i somehow broke some code in r_bsp.cpp that is causing it its like hardest thing to debug image

valina354 commented 2 days ago

i love this engine a lot but the way rendering system is done is just so confusing in my opinion, like theres drawfirst,drawfinal,draw lights, and probably other places where you bind textueres, binding textures is literall more complex then the shaders themself, like in most other engines you just bind the textures in 1 function and thats it

valina354 commented 2 days ago

i guess my only way is to try and copy paste how MT_TX_NORMALMAP binds textures and hope it works but i dont even know if that will work

valina354 commented 2 days ago

i tried repeating similar to MT_TX_NORMALMAP but unless i did it wrong it stll happens, it basiclly seems to pretty much paste the same ao map on another unrelated textures and i cant tell why

valina354 commented 2 days ago

btw if you want to check it out yourself the issue engine is here https://github.com/Soft-Sprint-Studios/Matrix-Engine

valina354 commented 2 days ago

for vbm i literally just did this in drawmesh and it worked for both dlights and normal lights while bsp is lot of stuff image

valina354 commented 2 days ago

ok, so the only thing i can think of is that determinators are past 4096, basiclly i raised the limit to 8192 in C++, im not sure if that could be like causing it? has it been tested if more then 4096 determinators can work at same time? because with the ao and parallax i reached 7000 determinators @TheOverfloater

valina354 commented 2 days ago

i also didnt add r_checkshaderuniform to all of them but i dont think thats issue

valina354 commented 2 days ago

ok, so the only thing i can think of is that determinators are past 4096, basiclly i raised the limit to 8192 in C++, im not sure if that could be like causing it? has it been tested if more then 4096 determinators can work at same time? because with the ao and parallax i reached 7000 determinators @TheOverfloater

i removed screen space normals termporarily to get it down below 4096 but that didnt fix it so its not issue that

valina354 commented 2 days ago

omg ok, so i added ao and parallax here and it seemed to fix it! ao fully works fine without bleeding into others, however image

however parallax breaks with a dlight, this no dlight image and this with dlight image

i think dlights how they render somehow coincide with parallax or somehow break it i need to test more however

valina354 commented 2 days ago

ye its caused by the weird strange bug from before with for some reason on dlight only showing parallax on normalmap i dont understand how i would fix it

TheOverfloater commented 2 days ago

Without seeing the shader code, and the BSP Renderer changes I cannot really tell what is wrong, but I assume you would need to account for parallax mapping both when rendering the first pass(lightmaps only), then account for it with each individual dynamic light, and finally account for it again in the third pass(rendering the texture, then rendering specular highlights, cubemaps). Make sure you have these stages also account for the parallax mapping, otherwise yes, it will break.

valina354 commented 20 hours ago

i seriously dont know what to do, i added to drawfinal as its final place to bind shaders that wasnt there and yet it still didnt fix it, this is my r_bsp.cpp https://github.com/Soft-Sprint-Studios/Matrix-Engine/blob/main/matrix/sources/codesrc/engine/renderer/r_bsp.cpp and this is the shader https://github.com/Soft-Sprint-Studios/Matrix-Engine/blob/main/matrix/scripts/shaders/bsprenderer.bss if you like have any free time to check it out because tbh i dont know myself i have been checking for last few days and cant figure it out