-
Notifications
You must be signed in to change notification settings - Fork 61
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
implement per-stage normalscale #231
Conversation
2996cfb
to
3ed2b3a
Compare
ce5466a
to
aff530d
Compare
This seems ready to me. |
a70f392
to
bcae383
Compare
341255a
to
42c5c43
Compare
7797e1f
to
2e91742
Compare
I added a commit to remove the |
2e91742
to
7fadc70
Compare
I noticed I forgot to make the dead liquid shader using |
@slipher, I added a small commit I want your advice on. This commit is just done to reduce boilerplate. But it replaces a definition by an affectation, do you think a compiler is able to optimize it, or, if not, this is negligible? If you think it's OK I'll squash it, otherwise I'll drop it. |
Removing r_normalScale define seems good. Not sure what you mean about stuff needing to be optimized as you simply removed the extra instructions from GLSL. |
45d8e5b
to
0931071
Compare
instead of this in 8 places: vec3_t normalScale = { 1, 1, 1 };
SetNormalScale( pStage, normalScale ); I do this in 8 places: vec3_t normalScale;
SetNormalScale( pStage, normalScale ); And this in 1 place (in normalScale[ 0 ] = 1;
normalScale[ 1 ] = 1;
normalScale[ 2 ] = 1; The code is more compact this way, and less prone to errors, but in first case the vec3 is defined to 1,1,1, in the second case the vec3 is defined to 0,0,0 then set to 1,1,1. |
1a6b5c7
to
ffd5a9e
Compare
ffd5a9e
to
dc1c627
Compare
Does anyone have something to say against that? |
…hannels rename the old normalScale expression keyword as normalIntensity
…rmal map no need to hack normalScale with a fourth channel to tell it's customized anymore
dc1c627
to
927b640
Compare
This PR sits above #230.
This is a demonstration of what ca be achieved thanks to #230.
Previously in #180 I introduced a per-material
normalFormat
option that would be able to flip channels. But then I discovered that other engines relies on anormalScale
option that can both scale (and flip) channels.A proper implementation required to be done on the stage scope.
Note that ioq3 seems to only read
normalScale X Y
while we are able to readnormalScale X Y Z
, if Z is missing, default one is used instead, to keep compatibility with material that may already exists.As an example, we can look at some materials from tex-vega_src.dpkdir that have a flipped X channel.
Before:
After:
They can be easily compared this way:
or with a slider there: https://imgsli.com/OTI4Mw
To do fix them, their materials were edited from this:
to this:
In the process we also moved from separate stages that has to be collapsed by the engine to a multi texture stage that is collapsed from the start.
Also note we inherited from XreaL another
normalScale
keyword that is currently only used by broken liquid shader, and this keyword is expecting an expression. We have to rename it. It is now named normalIntensity, this applies on XY normal map channels and can be computed on every frame by using expressions.It would have been better to keep the
normalScale
keyword for that feature (as existsfresnelScale
for example) and usenormalChannelScale
for the par-channel-scaling-and-flipping variable, butnormalScale
is already widely used by other idtech3 derivated engines, while our liquid shader is used by no one yet, even not by us.