KillzXGaming / Cafe-Shader-Studio

A program to preview various materials and shaders in games.
MIT License
47 stars 8 forks source link

Mesh picking - transparency on background issue #17

Open S41L0R opened 2 years ago

S41L0R commented 2 years ago

Transparency doesn't fully work when rendering onto background when object is selected with mesh picking. This problem seems to come from Picking.frag or how it is used.

Tested in Gagb_MarioCircuit in MK8 WiiU

image

KillzXGaming commented 2 years ago

Selection rendering is done through a solid opaque renderer https://github.com/KillzXGaming/Cafe-Shader-Studio/blob/main/BfresEditor/Bfres/Render/BfresModelAsset.cs#L333 . Probably could be improved visually though I don't find it as a big deal atm.

S41L0R commented 2 years ago

I agree it's not a big deal.. but the problem here is that it's only rendering if it's on top of the background.

KillzXGaming commented 2 years ago

An idea which will probably be used. The current method draws a solid mesh and offsets it creating an outline but a better way of handling it would be outputting a second color pass that has color or not depending on what is selected. Then it can be created later during the post processing. http://www.geoffprewett.com/blog/software/opengl-outline/index.html

This method will support proper outlines for transparent models and also will save on performance not needing to be redrawn twice. Also with this I can add a proper selection highlight color that adds to the whole model.

The tricky part is implementing it with custom shaders. I'll need to try adding onto shaders during compilation with custom editor code.