I am trying to draw a procedural image but it results in blurred image.
from bge.texture import ImageBuff,Texture,materialID, ImageFFmpegfrom bge import logic
from random import randint
import array
from bge import render
render.setMipmapping(render.RAS_MIPMAP_NONE)
scene = logic.getCurrentScene()
cont = logic.getCurrentController()
own = cont.owner
SIZE = 2 ** 6
def generatePattern(source, width, height):
pattern_buffer = array.array('B')
for y in range(height):
for x in range(width):
r,g,b = (randint(0,255) for i in range(3))
pattern_buffer.append(r)
pattern_buffer.append(g)
pattern_buffer.append(b)
source.load(pattern_buffer, width, height)
return source
def main():
if cont.sensors['Keyboard'].positive:
obj = scene.addObject('Plane',own)
obj.worldPosition = own.worldPosition
if not "texture" in obj:
for matID in range(len(obj.meshes[0].materials)):
renderToTexture = Texture(obj, matID)
renderToTexture.source = generatePattern(ImageBuff(),SIZE,SIZE)
# renderToTexture.mipmap = False
renderToTexture.refresh(True)
obj["texture"] = renderToTexture
main()
This is weird as the other textures in the scene (that are not edited) stay sharp.
Also, apparently ‘renderToTexture.mipmap = False’ does nothing in this case.
EDIT: pqftgs told me a faster way than itertools.chain … I have to find it. I think it was bge.pixels = list(chain.from_iterable(pixels))
EDIT2: As my code snippet didn’t worked in multitexture I tried several things and I replaced glTexParamateri with glTexParamaterf… I don’t know exactly what it means but normally I use glTextParamereri.
It works for this example and one of my computers.
But considering the abuse I am doing do blender, I guess i can’t ask for too much.
(lib load is magic)
I will open an another thread on what I am actually doing before I investigate this further.
So its a something I guess… :spin::spin::spin::spin::spin: