Hello.
I saw in the cubemap shader the link to the texture index … can I change the textures that are already in the index using Python?
For when the cursor on the plane - the text has changed to “B”, outside the plane again “A”…
OK, but if through the shader you can assign textures (like the Cubеmap from Martins Upitis) - the diff, lightmap, normal … then you can reboot the shader and change the textures themselves.
If someone would help to do this - the shader “texture change” from the texture slot … It’s all real, but not for me.
to UPBGE yet do not want to go, I’m waiting for Blender 2.8
This code would do that would work independently - that’s all.
mesh = own.meshes[0]
for mat in mesh.materials:
shader = mat.getShader()
if shader != None:
if not shader.isValid():
shader.setSource(VertexShader, FragmentShader, 1)
shader.setAttrib(g.SHD_TANGENT)
shader.setSampler('envMap',2)
shader.setSampler('normalMap',0)
shader.setSampler('lightMap',1)
shader.setUniformDef('ModelMatrix', g.MODELMATRIX)
shader.setUniformDef('cameraPos', g.CAM_POS)
Here I tried to switch in real time between the two shader from Martins Upitis - everything works, even the eye does not notice the transition. So how can I throw out Cubemap from Cubemap shader?
And you do not know if hypothetically to create a texture shader, it did not work faster than simple (default) texturing?
So yes, if you use a custom GLSL shader then you can switch the uniform definitions. This doesn’t switch the texure slots, it switches the images sampled from the shader side. (Effectively).
So you can do this just by re-running the 'setSampler('uniformName, tex_slot) lines - changing the integer (which is the texslotid)
But in BFBGE you cannot do so for normal materials, and if i remember corectly, there were some odd thing when doing so in UPBGE.
OK, but I do not know how to do it. I saw how Goran Milovanovic wrote a parallax shader - custom parallax … here he was able to do this, for him it’s like a morning warm-up. And my brains is out:no:. And if solve such a question, is this the easiest way to switch between textures of different resolutions?
p.s. so you can do this just by re-running the 'setSampler('uniformName, tex_slot) lines - changing the integer (which is the texslotid) - are you sure that this is addressed to me?:eek:
Probably, then a lot of people will come to Holland, and they will all be long and tiring conversations, explain to one person that the BGE should be live - maybe using the legs …
Tone, do not do this … otherwise we will remember you. :no: And when I remember you, I’ll listen to Metallica - Unforgiven
Why do you want to change your texture resolution. If it’s to save RAM/VRAM, then you should load the needed one from disk using bge.texture.ImageFFMPEG(), and dump it in the correct texture slot. Having them in different texture slots means that both will be in RAM/VRAM all the time. The code to replace a texture with one from disk is:
def show_picture(obj, path, mat_id=0, tex_id=0):
'''Loads a picture into a texture'''
# The texture has to be stored in a place associated with other game data
# so we store it in a game property. This name inlucdes the mat ID's and
# tex ID's so that a single object with a complex setup does not have the
# textures overwrite each other.
# If a bge.texture object already exists for this object/mat_id/tex_id, then
# we retrieve that.
prop_name = 'SHOW_PICTURE{}:{}'.format(mat_id, tex_id)
if prop_name not in obj:
tex = bge.texture.Texture(obj, mat_id, tex_id)
obj[prop_name] = tex
else:
tex = obj[prop_name]
# Load the image from the path
raw = bge.texture.ImageFFmpeg(os.path.join(path))
# Check to see that it loaded
if raw.status == bge.texture.SOURCE_ERROR:
# Error in loading image
bge.log.error("Unable to load image at {}".format(path))
raise ValueError("Unable to load image at {}".format(path))
# Assign the new image to the texture and update the texture.
tex.source = raw
tex.refresh(True)
Be aware that this is slow (reading from disk) so it not suitable for doing at run-time.
If you want to do it at run-time, say, based on distance - you can use a node shader to fade between images based on camera distance. I don’t have a demo of this handy, but can make you one if you like.
this is to change the localization (texture) and texture quality in future games.
Here’s how I did it - simple multilanguage interface
But your code seems to me more relevant - then I’ll explore it, now there is no time. When I investigate and test your code, I will definitely subscribe.
Thank you for attention.
Be careful to end any custom textures that you load in python. BGE doesn’t always clean up after itself when you’re using the texture module to set textures and the result can be a hard crash of Blender when it tries to exit. (blender 2.7x)
The Ton is very strange, he’s like that girl on his first date - he wants to, then he does not. Or just loves intrigues … and then brazenly smiles, like - “here you are fools!”. This is a simple trolling, with the enjoyment of the public’s confusion. …God of Blender! Oh, huh.
well, you said it… dude! Delete, and return back … this is called an upgrade - one small word - upgrade! And how many scribbles … Are you by any chance a friend of Ton? You also take out the brains like he does :).