Closed kianzarrin closed 4 years ago
public static bool HasSameNodeAndSegmentTextures(NetInfo info, Material nodeMaterial, int texID) {
foreach (var seg in info.m_segments) {
Texture t1 = nodeMaterial.GetTexture(texID);
Texture t2 = seg.m_segmentMaterial.GetTexture(texID);
if (t1 == t2)
return true;
}
return false;
}
FUN FACT: Loading screen mod changes how t1==t2
works in the code above. (I understand loading screen mod tries to minimize memory usage by removing duplicate textures from memory)
t1==t2
is truet1==t2
is false t1==t2
is truet1==t2
is true I just uploaded a hack applying HasSameNodeAndSegmentTextures
code only to NExt2 assets. But I like to find a proper solution.
Another difference I found is that:
Is that the condition I should be looking for to exempt from hide crossings?
Still don't understand why the segment texture is rendered but node texture is not.
Just to be safe side I tested the following on the NExt2 elevated 2 lane road with painted median: 1- if I clone the material but do not do any texture processing, nothing changes. 2- the output of my texture processing has same size as input : 1024 x 2048?
so if texture.width != texture.height
and m_nodeMaterial.MainTexture == m_segmentMaterial.MainTexture
then do not hide crossings. is this the condition I should be looking for?!
Ok so roads are a bit weird. There is the diffuse map, the APR map and the XYS map. The APR map is a mask blends asphalt or pavement textures into the diffuse map. In this case, I set the APR map to replace the whole roadway with straight up asphalt. Thus the node and segment diffuse maps are the same but their APR maps are different. The processing you are doing is it different per road or is this a one size fits all programatic change? You can either skip it as it does not have zebra crossings or you could simply change the diffuse texture in the roadway to just black if you are doing manual alterations for each road. I don't remember my rationale for making this intersection without crosswalks. I don't remember if elevated vanilla roads have crosswalks either.
@andreharv Sorry for the late response. Thank you so much for the info. This helps me make my code much more reliable.
The processing you are doing is it different per road or is this a one size fits all programatic change?
I blend Alpha map from segment into node. And its all automatic. I'll just make hard coded exceptions for NExt2 roads.
I don't remember my rationale for making this intersection without crosswalks
All NExt2 small/small_heavy ground roads use the same node texture from vanilla small road. You cannot do that for elevated roads because of the size difference between vanilla elevated roads and NExt2 elevated roads. I guess you did not have time to draw crosswalks yourself. or maybe you forgot. bigger elevated roads do not have this size mismatch problem so for bigger roads you can use vanilla crosswalks.
In the picture bellow you can see a road from Next2 that does not have zebra crossings texture. In my hide crossings mod I : EDIT 1- clone the material 2- get defuse texture from node material (
NetInfo.Node[0].m_nodeMaterial.GetTexture(ID_DEFUSE)
). 4- do some processing (lets say I flip the texture). 5- set the processed texture as defuse texture of the node material. And as you can see int he picture bellow it draws a weird junction texture:This is the defuse texture of
m_nodeMaterial
from mod tools:Why does it look exactly like the segment texture? in fact the are identical. So I decided to exclude the situation when node texture is equal to the segment texture in the code bellow. This solved the problem (more like a hack arround):
So 1- is the original m_nodeMaterial is not being rendered but when I change its defuse texture then it gets rendered? 2- why does it have such a weird node texture in the first place?
So far so good. but now users are complaining why my mod does not hide the crosswalks from THIS ROAD:
The node texture is the same as one of the segment textures:
Although the node texture is identical to one of the segment textures, this time the node texture IS rendered ( I don't understand why). But because my hide crossings mod will not hide the crossing because the node texture is identical to one of the segment textures.
I need to know when the node texture is rendered and when it is not so that I know when to exempt it from my hide crossing mod and when not to. The condition
node[i].m_nodeMaterial.GetTexture(texID) == segment[i].m_segmentMaterial.GetTexture(texID);
is not a good condition. So what should I look for?EDIT: while we are at it what is the difference between
NetNode.Node.m_nodeMaterial
andNetNode.Node.m_material
?