-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for mirrors seeing other mirrors #646
base: master
Are you sure you want to change the base?
Conversation
It used to crash because after recursing into R_MirrorPoint(), which calls tr.CropRenderSize(), about MAX_RENDER_CROPS times, CropRenderSize() wrote behind the end of tr.renderCrops[] and damaged a pointer. Even if it didn't crash because of that, endlessly recursing is a bad idea, so it's limited now. The limit can be configued with the new r_maxMirrorRecursion CVar, but the hard limit is MAX_RENDER_CROPS-3 = 5 Another problem was that mirrors and other subviews render into a texture, specifically globalImages->scratchImage ("_scratch"), so it could happen that it got written to several times before being used. Now there are 8 scratch images (+ the original "_scratch" which is also used by gamecode) that the subview code cycles through to minimize the chance of overwriting something that's still in use.
As usual, download testbuilds at https://github.com/dhewm/dhewm3/actions/runs/12921127187?pr=646 under "Artifacts" (once the builds are done) Video: d3-mirrors-fixed.mp4 |
I was just about to make a request about this. A long time ago, I requested the same thing for Doom 3 on an old forum, and someone replied suggesting creating the following script:
However, this have the same issues that you report early. I don't know why, but on Doom 3 Alpha Leaked (from 2002) this feature works awesome, look: the crystal visors from soldiers helmet's have reflect effect too: reflect glass window showcase at 15:13 doom 3 retail reflect glass script: we can compare the alpha script, are very similar:
doom 3 alpha leaked script: I hope you can do it, doom 3 alpha leaked looks awesome and Doom 3 had much of those effects stripped away. |
ou! i noticed that #367 was maded by me on 2021 ! 😨 |
Testing time... Render into the same image problem Ghosting problem If you pay atention at the background of reflected image, theres a "ghosting" effect. I hope this help some. |
Something I noticed: There are two ways to create mirrors in Doom3. One is the global The other way to create a mirror is the Note that I did not try to make the mirror using |
hm, and what about making [mirrorRenderMap] only reflects objets? i mean, i noticed on alpha leaked only the player and monster are reflected, not the world map. it will be a solution for solve these weird glitch that shows portions of the world map into the reflex. |
Not sure this is possible, AFAIK a feature of Doom3 (compared to previous idTech versions) was to render everything the same ("unified rendering"). Also, it wouldn't help with glitches involving the playermodel like in this video: d3-mirrorbug.mp4Generally speaking, rendering only objects and using a cubemap for the world might be a nice optimization for rendering mirrors and especially mirror-like surfaces that don't need look perfect like glass. No idea if this is something that is or was commonly done though. Anyway, I think at least part of the problem with the
The problem here is that the
thing from the .mtr file. So while that image for the (I tried setting one of the windows in my testmap to my testmap: the used materials are from reflectglass.zip from #367 |
hm, now i understand why mirrors and reflexes are a nightmare to program on video games. In the video can be more detailed what I'm say: Is very sad, but the old engines manage this problem and I don't know how. |
Duke3D supported mirrors looking into mirrors? |
youre right 😂 sorry, forget those what i say |
Also note that Duke3Ds mirrors were really hacky: They required an empty room on the other side of the mirror that's big enough to hold everything the mirror can show, the engine then automatically mirrored the geometry into there. In Doom3 mirrors can be in the middle of the room and you can walk around them if you want. |
wow!! i don't know about that of doom 3! 😮😮😮 i'll try. |
some ideas, im not programmer, so i think may be wrong, but here we go: Idea 1: Assign a Single Scratch Image per Surface. Modify R_MirrorRender() in tr_subview.cpp to create a new texture on each render
What I think this do: A new texture is created in Idea 2: Force Different Materials for Each Surface Duplicate the material but in the .mtr file
This would cause glass1 and glass2 to be treated as separate materials and not share the same reflection texture, reducing the overwriting issue. Idea 3: Use Framebuffers Instead of Scratch Textures modify R_MirrorRender() to render in a framebuffer but this i think this last idea is a very very more hard work to do. i don't know. |
It used to crash because after recursing into R_MirrorPoint(), which calls tr.CropRenderSize(), about MAX_RENDER_CROPS times, CropRenderSize() wrote behind the end of tr.renderCrops[] and damaged a pointer.
Even if it didn't crash because of that, endlessly recursing is a bad idea, so it's limited now. The limit can be configued with the new r_maxMirrorRecursion CVar, but the hard limit is MAX_RENDER_CROPS-3 = 5
Another problem was that mirrors and other subviews render into a texture, specifically globalImages->scratchImage ("_scratch"), so it could happen that it got written to several times before being used. Now there are 8 scratch images (+ the original "_scratch" which is also used by gamecode) that the subview code cycles through to minimize the chance of overwriting something that's still in use.
This fixes #367