Skip to content
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

Refraction rendertype and its compatibility with custom materials #109

Open
DoctorAnsem opened this issue Mar 17, 2020 · 1 comment
Open
Labels
bug Something isn't working materials All the custom material things.

Comments

@DoctorAnsem
Copy link

I truthfully am not aware if there's been any talk about refractions either not being available or broken, or whatever. Nonetheless there is a small oddity that should be noted - a stock unit, the Bothan Spy, uses a refraction rendertype to make a fancy effect when the unit uses its invisibility weapon and, surprise surprise, turns transparent. Now given that the munge process prints a warning of some sort when dealing with refractions, the custom materials react to it surprisingly well. A tiny little flaw pops up though - the material loses its diffuse texture whenever it transitions into the refraction. It's barely even noticeable in this instance, thankfully, but it is there so bottom of the list I guess.

Just as an afterthought, I guess static refraction-mapped models might suffer from this much worse, but I don't know for sure. Generally I try to avoid using refractions on static models because of that god awful alpha sorting issue.

@PrismaticFlower PrismaticFlower added bug Something isn't working materials All the custom material things. labels Mar 18, 2020
@PrismaticFlower
Copy link
Owner

Never thought about the interaction between models using a custom material and the dynamic refraction added by cloak. Sounds like it luckily enough mostly works, save the diffuse map being missing of course.

I suspect the reason both why it is missing and why the refraction actually works is that Shader Patch only considers textures being set to slot 0 for custom materials, otherwise it backs out and does nothing. Unlike almost every other shader in the game the diffuse map for refraction is in slot 2, this seams like it is turning out to be a blessing here though since the diffuse map in slot 0 is what Shader Patch uses to identify when to use a custom material. Since it doesn't see slot 2 as a valid place for a material to go it doesn't apply it and when the game switches to using the refraction shader it just works, minus the diffuse texture now being missing.

I think it actually shouldn't be too hard to get the diffuse texture showing up though, custom materials already have the concept of a "fail safe texture" (you may have seen it in the material editor UI) that is used to keep the z-prepass working for alpha-cutout/hard edged transparency materials. The fail safe texture also happens to always be (for pbr/normal_ext/basic_unlit materials) the diffuse map/base color map so I think if we extend it's usage we should be able to fix this problem without too much work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working materials All the custom material things.
Projects
None yet
Development

No branches or pull requests

2 participants