73 of 167 modeled structures have multiple textures, as computed with the following Python script:
importospath='Extensions/LemnosLife/Map/Common/Structures/'os.chdir(path)defisTexture(s):textures=['png','jpg','svg']fortextureintextures:ifs.endswith(f'.{texture}'):returnTruereturnFalsefor_,_,filesinos.walk('.'):filesWithMultipleTextures=0filesLen=len(files)forfileinfiles:withopen(file)asf:lines=f.read().splitlines()textures=0forlineinlines:ifisTexture(line):textures+=1iftextures>1:filesWithMultipleTextures+=1print(f'{filesWithMultipleTextures}/{filesLen} have multiple textures')break
73 of 167 modeled structures have multiple textures, as computed with the following Python script:
```python
import os
path = 'Extensions/LemnosLife/Map/Common/Structures/'
os.chdir(path)
def isTexture(s):
textures = ['png', 'jpg', 'svg']
for texture in textures:
if s.endswith(f'.{texture}'):
return True
return False
for _, _, files in os.walk('.'):
filesWithMultipleTextures = 0
filesLen = len(files)
for file in files:
with open(file) as f:
lines = f.read().splitlines()
textures = 0
for line in lines:
if isTexture(line):
textures += 1
if textures > 1:
filesWithMultipleTextures += 1
print(f'{filesWithMultipleTextures}/{filesLen} have multiple textures')
break
```
Could check how many textures can be used in my computer GPU. That way, we could try passing all Downloads textures as uniforms. On the old VAIO we can have 16 textures, while on my computer we can have textures.
Face this error message otherwise:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ProgramCreationError(LinkingError("warning: fragment shader varying biome not written by vertex shader\\n.error: Too many fragment shader texture samplers\\n"))', src/main.rs:127:6
Could check how many textures can be used in my computer GPU. That way, we could try passing all `Downloads` textures as `uniform`s. On the old VAIO we can have 16 textures, while on my computer we can have textures.
Face this error message otherwise:
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ProgramCreationError(LinkingError("warning: fragment shader varying biome not written by vertex shader\\n.error: Too many fragment shader texture samplers\\n"))', src/main.rs:127:6
```
Well I adapted the ground rendering to fake 78 textures and I haven't retrieved this error on my computer so let's assume a single shader would do the trick. Used this Python script to generates the repeated code:
On the 191 textures of `Downloads/` only 78 are used by structures, thanks to the following Python script:
```python
#!/usr/bin/python3
import os
path = 'Extensions/LemnosLife/Map/Common/Structures/'
os.chdir(path)
structuresTextures = set()
for _, _, files in os.walk('.'):
for file in files:
if file.endswith('.mtl'):
with open(file) as f:
lines = f.read().splitlines()
for line in lines:
if line.startswith('newmtl '):
structuresTextures.add(line.replace('newmtl ', ''))
break
print(len(structuresTextures), structuresTextures)
```
To remove textures that aren't made for structures, you can run:
```python
path = 'Extensions/LemnosLife/Assets/Downloads/'
os.chdir(path)
for _, _, files in os.walk('.'):
for file in files:
fileName = file.split('.')[0]
if not fileName in structuresTextures:
print(f'remove {file}')
os.remove(file)
break
```
Note that for instance `glass.svg` is kept as `glass.png` is used.
Can use the following Python script to see textures in this case:
Note that this script returns `solarPowerplant`, `water` and `glass`.
```python
import os
path = '/home/benjamin/Desktop/BensFolder/DEV/Candco/CPP/Projects/LemnosLife/Rust/LemnosLife_Rust/Extensions/LemnosLife/Assets/Downloads/'
os.chdir(path)
fileNames = set()
for _, _, files in os.walk('.'):
for file in files:
fileName = file.split('.')[0]
if fileName in fileNames:
print(fileName)
else:
fileNames.add(fileName)
break
```
Well I adapted the ground rendering to fake 78 textures and I haven't retrieved this error on my computer so let's assume a single shader would do the trick. Used this Python script to generates the repeated code:
```python
for i in range(78):
print(f' tex{i}: &textures[{i}],')
```
To generate respectively `STRUCTURES_TEXTURES` and `STRUCTURES_TEXTURES_REVERSED`:
```python
import os
path = 'Extensions/LemnosLife/Assets/Downloads/'
os.chdir(path)
for _, _, files in os.walk('.'):
for filesIndex, file in enumerate(files):
fileName = file.split('.')[0]
#print(f' "{file}",')
print(f' "{fileName}" => {filesIndex},')
break
```
Triangle strip won't help us on this one as we have to go from a polygon to the other and this time there is no way to do it cleanly and efficiently. However using an IBO might improve performances.
If I remember correctly there are about 2,000,000 structures instances and 1,000 different structures.
Triangle strip won't help us on this one as we have to go from a polygon to the other and this time there is no way to do it cleanly and efficiently. However using an IBO might improve performances.
If I remember correctly there are about 2,000,000 structures instances and 1,000 different structures.
I am unable to generalize the uniforms creation. Which would be quite necessary for the structures as otherwise we need to hardcode their textures. The problem with UniformsStorage::add is that it returns UniformsStorage<'n, U, UniformsStorage<'n, T, R>>, but as the encapsulation level is pratically determined at runtime (even if defined in theory at compilation time) the type for the concatenation doesn't seem easily definible correclty. Only one person was having the same problem, according to Google, and he answers me. I should consider his answer.
I am unable to generalize [the uniforms creation](http://gitea.lemnoslife.com:3006/Benjamin_Loison/LemnosLife_Rust/src/commit/a695435dcf3a5077dcc2a52ef279aaa22d3d3b6f/src/main.rs#L186-L204). Which would be quite necessary for the structures as otherwise we need to hardcode their textures. The problem with [`UniformsStorage::add`](https://docs.rs/glium/0.32.1/glium/uniforms/struct.UniformsStorage.html#method.add) is that it returns `UniformsStorage<'n, U, UniformsStorage<'n, T, R>>`, but as the encapsulation level is pratically determined at runtime (even if defined in theory at compilation time) the type for the concatenation doesn't seem easily definible correclty. Only one person was having the same problem, according to Google, and [he answers me](https://users.rust-lang.org/t/glium-uniformsstorage-as-a-field-in-a-struct/21969/5). I should consider his answer.
To make many instances of the same object at different places, let's have a look to glium examples. Maybe blitting, instancing, picking, shadow-mapping and sprites-batching are be interesting. picking seems to be the simplest one matching our needs. Note that none of these examples show how to display two different OBJs, so I guess we have to proceed one-by-one for the OBJs rendering.
To make many instances of the same object at different places, let's have a look to [glium examples](https://github.com/Benjamin-Loison/LemnosLife-Client/issues/2#issuecomment-1279839590). Maybe [~~`blitting`~~](https://github.com/glium/glium/blob/3e143cf95f3c990f82e8aeeb170b15b339b23025/examples/blitting.rs), [`instancing`](https://github.com/glium/glium/blob/3e143cf95f3c990f82e8aeeb170b15b339b23025/examples/instancing.rs), [`picking`](https://github.com/glium/glium/blob/3e143cf95f3c990f82e8aeeb170b15b339b23025/examples/picking.rs), [`shadow-mapping`](https://github.com/glium/glium/blob/3e143cf95f3c990f82e8aeeb170b15b339b23025/examples/shadow_mapping.rs) and [`sprites-batching`](https://github.com/glium/glium/blob/3e143cf95f3c990f82e8aeeb170b15b339b23025/examples/sprites-batching.rs) are be interesting. `picking` seems to be the simplest one matching our needs. Note that none of these examples show how to display two different OBJs, so I guess we have to proceed one-by-one for the OBJs rendering.
How to deal with SVGs (basketball court, blackYellow, glass, note that the latest one is the only one using transparency), as they aren't supported as an ImageFormat? Let's use JPG format after rasterizing SVGs, as glass.svg shouldn't exist. Don't forget to modify accordingly .mtl files (515.mtl and 528.mtl here).
How to deal with SVGs (`basketball court`, `blackYellow`, `glass`, note that the latest one is the only one using transparency), as they aren't supported as an [`ImageFormat`](https://docs.rs/image/latest/image/enum.ImageFormat.html)? Let's use JPG format after rasterizing SVGs, as [`glass.svg` shouldn't exist](http://gitea.lemnoslife.com:3006/Benjamin_Loison/LemnosLife_Rust/issues/6#issuecomment-237). Don't forget to modify accordingly `.mtl` files (`515.mtl` and `528.mtl` here).
Getting the following error when encountering a .jpg that is encoded as a PNG:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Decoding(DecodingError { format: Exact(Jpeg), underlying: Some(Format("first two bytes are not an SOI marker")) })', src/main.rs:255:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The following Python script gives the textures incorrectly encoded, as their file extensions are accurate as they are more seen by the developer.
mogrify file.jpg encodes file.jpg to an actual JPEG.
Getting the following error when encountering a `.jpg` that is encoded as a PNG:
```
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Decoding(DecodingError { format: Exact(Jpeg), underlying: Some(Format("first two bytes are not an SOI marker")) })', src/main.rs:255:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
The following Python script gives the textures incorrectly encoded, as their file extensions are accurate as they are more seen by the developer.
```python
import os, subprocess
path = 'Extensions/LemnosLife/Assets/Downloads/'
os.chdir(path)
def execute(cmd):
return subprocess.check_output(cmd, shell=True).decode('utf-8')
for _, _, files in os.walk('.'):
for file in files:
cmd = f'file {file}'
result = execute(cmd)
if file.endswith('.png'):
if not 'PNG' in result:
print(file)
elif file.endswith('.jpg'):
if not 'JPG' in result:
print(file)
break
```
<!--Note that the previous script returns:
```
```-->
`mogrify file.jpg` encodes `file.jpg` to an actual JPEG.
Can't use spaces in texture names (notably `basketball court.jpg` and `iron bars.png`), the list can be obtained thanks to the following Python script:
```python
import os
path = 'Extensions/LemnosLife/Assets/Downloads/'
os.chdir(path)
for _, _, files in os.walk('.'):
for file in files:
if ' ' in file:
print(file)
break
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
73 of 167 modeled structures have multiple textures, as computed with the following Python script:
Convert
.structo.objwith following Python script.Could check how many textures can be used in my computer GPU. That way, we could try passing all
Downloadstextures asuniforms. On the old VAIO we can have 16 textures, while on my computer we can have textures.Face this error message otherwise:
Maybe reversed map will be a problem for the structures display.
Old VAIO:
On the 191 textures of
Downloads/only 78 are used by structures, thanks to the following Python script:To remove textures that aren't made for structures, you can run:
Note that for instance
glass.svgis kept asglass.pngis used.Can use the following Python script to see textures in this case:
Note that this script returns
solarPowerplant,waterandglass.Well I adapted the ground rendering to fake 78 textures and I haven't retrieved this error on my computer so let's assume a single shader would do the trick. Used this Python script to generates the repeated code:
To generate respectively
STRUCTURES_TEXTURESandSTRUCTURES_TEXTURES_REVERSED:Computer:
Triangle strip won't help us on this one as we have to go from a polygon to the other and this time there is no way to do it cleanly and efficiently. However using an IBO might improve performances.
If I remember correctly there are about 2,000,000 structures instances and 1,000 different structures.
I am unable to generalize the uniforms creation. Which would be quite necessary for the structures as otherwise we need to hardcode their textures. The problem with
UniformsStorage::addis that it returnsUniformsStorage<'n, U, UniformsStorage<'n, T, R>>, but as the encapsulation level is pratically determined at runtime (even if defined in theory at compilation time) the type for the concatenation doesn't seem easily definible correclty. Only one person was having the same problem, according to Google, and he answers me. I should consider his answer.To make many instances of the same object at different places, let's have a look to glium examples. Maybe
,blittinginstancing,picking,shadow-mappingandsprites-batchingare be interesting.pickingseems to be the simplest one matching our needs. Note that none of these examples show how to display two different OBJs, so I guess we have to proceed one-by-one for the OBJs rendering.How to deal with SVGs (
basketball court,blackYellow,glass, note that the latest one is the only one using transparency), as they aren't supported as anImageFormat? Let's use JPG format after rasterizing SVGs, asglass.svgshouldn't exist. Don't forget to modify accordingly.mtlfiles (515.mtland528.mtlhere).Getting the following error when encountering a
.jpgthat is encoded as a PNG:The following Python script gives the textures incorrectly encoded, as their file extensions are accurate as they are more seen by the developer.
mogrify file.jpgencodesfile.jpgto an actual JPEG.Can't use spaces in texture names (notably
basketball court.jpgandiron bars.png), the list can be obtained thanks to the following Python script:Experiencing red borders with transparent texture such as
palm.png.