-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Regarding the incompatibility between texture coloring and specular, and the new flag about ambientMaterial #6133
Comments
For whether or not Are you imagining that I think it would be great to allow the use of |
The problem is that the way to switch texture coloring to per-vertex coloring is the act of calling fill() pointlessly. Since there is no function like enablePerVertexColoring(), the only way to set the flag is to call it like fill(0). Regarding the order, I think that there is no problem if I add it to the reference. In the first place, it was unexpected for me that ambientMaterial() and specularMaterial() would make _tex null. This is exactly the case when it comes to ordering issue, but it's not written anywhere in the reference. Rather than adding this, I think it would be better to stop making _tex null in the first place. The texture is used only to determine the baseColor within the shader, and is completely independent of processing such as specular. It's also puzzling that texture() turns off the flag to use specular. I think the two should be able to coexist naturally.
If texture() stops turning off the flag for using specular, etc., and functions such as specularMaterial() stop setting _tex to null, the ordering issue does not occur, but oversight and If you have a serious problem, I would appreciate it if you could let me know. |
Personally, I think the reason why texture and specular cannot coexist is that there was an oversight in #5774 when specularMaterial() etc. was changed so that colors can be specified individually. From start to finish, that pull request didn't consider alternative coloring methods such as textures at all. It seems very natural for texture coloring and lighting to coexist, but I wonder why specular can't be used. If you only use fill(255) and only use ambientMaterial(), you can only do monochromatic colors, but I think it's inconvenient. |
I think that change makes sense. For fill/specularMaterial, we should just look through the docs and:
|
The only spec change I'm proposing for fill() is to set _hasSetAmbient to false when it runs. So if there is a problem, it will be when used together with ambientMaterial(). As for specularMaterial(), I'm going to stop nulling _tex, but there probably isn't an example of using this with texture, so I'm going to have a unit test to prove that it works too.
for fill(): "If you execute this, the ambientColor will be the same color that was determined at that time, but if you want to determine the ambientColor yourself, you must then execute ambientMaterial() before drawing.''
If ambientMaterial and specularMaterial coexist, I think there is already an example at specularMaterial(), but I think it makes sense if I create an example that is not monochromatic. |
I would like to write it like "ambientColor (color determined by ambientMaterial())" because it is easier for the reader to understand (because it is difficult to understand with the variable name in the shader). |
I'll create a pull request for now. I'm not sure why textures aren't allowed to coexist with specular, so I'll run it through unit tests and see what happens. |
This is a comparison video. There are three versions: the current version, the latest version, and the version with this specification change applied. For each of them, I changed the order of calling texture() and specularMaterial() and checked them in two ways. current versionNo texture is applied, or the color is faded when applied. fujisan0.mp4latest versionThe color fading problem is gone, but no specular is applied. 2023-05-09.20-43-55.mp4the version with this specification change appliedThe colors are not faded and the specular is applied neatly out of order. 2023-05-09.20-44-23.mp4 |
I wanted to raise it to a pull request, but it didn't work for some reason, so I put it here. I'm sorry. |
There is no way to deal with it because it does not respond at all. As long as ambientMaterial() isn't called, the color won't fade, so that's fine. One of the suggestions is the texture part of this issue. After all, the process of setting _tex to null is incomprehensible, so I regard it as a bug and launch a new pull request just to solve it. Another is to introduce the idea used in easyCam to orbitControl() to make the movement smoother. If this goes well, I think it will be a lot easier to operate. |
Hi, sorry for the delay, I got sick on the weekend so I haven't been active on Github. It looked like tests passed on your PR after you made it, I can take a look at the code now if you're still interested! |
Thank you for your reply. I've opened a pull request. Please leave a review. Take care. |
Topic
First of all, I don't know why this is the case, but I would like to raise an issue.
Regarding the fact that texture coloring and specular cannot be combined
Currently, using texture coloring with specularMaterial() does not reflect specular.
currentOutput / expectedOutput
texture_specular
Ignore the color fading problem for the time being (it was resolved in a recent pull request, but...)
This is because texture() turns the specularMaterial flag off inside the function (it also truns the emissiveMaterial flag off).
I don't know why they don't make it compatible, but it doesn't seem to be a problem even if it's compatible within the shader, so I don't think it's necessary to fold it (If it's folded for a reason, I left it as it is. I think it's better...).
In addition, specularMaterial(), ambientMaterial(), and emissiveMaterial() all set _tex to null, but I don't think this is necessary either. This is because they are compatible within the shader without contradiction.
The question of whether fill() and texture() should set _hasSetAmbient to false
In #6130 a flag _hasSetAmbient was created. This is true once ambientMaterial() is called and there is no way to make it false. Also, if false, the color specified by ambientMaterial() will be the baseColor.
But I think it's better to turn off this flag when fill() and texture() are called.
First, currently the way to enable per-vertex coloring is to call fill(). Also, the way to enable texture coloring is to call texture().
If the _hasSetAmbient flag is set, and you want ambientMaterial() to set the same color as fill(), this can be achieved by specifying the same color as fill() was called with. However, in the case of vertex coloring and texture coloring, this method cannot be used, and the same color cannot be used without breaking the flag.
If you want the color determined by fill() or texture() to be compatible with the color determined by ambientMaterial(), you can achieve this by calling ambientMaterial() after fill() or texture (for that, ambientMaterial( ) should not cause _tex to be null...).
Also, when drawing only with lighting processing and ambientMaterial() without using fill() or texture(), the flag remains set and there should be no particular problem (in this case, the color determined by fill() is remains white).
Summary,
I would like to discuss these.
The text was updated successfully, but these errors were encountered: