Git Product home page Git Product logo

Comments (6)

panzergame avatar panzergame commented on May 29, 2024 1

@axredneck : I was thinking of a python callback ran just before update object uniform of the custom shader. But it's only for custom shader not for blender material.
Else material switch will be targeted in 0.1.1.

from upbge.

youle31 avatar youle31 commented on May 29, 2024

@sdfgeoff: I don't know if changing material during runtime can be easy to implement... I think this is like light.type (we can't change it without to have to recompile the shader... But maybe Tristan has a better idea about that.
But what we could do is a function that copy all other material properties and apply it to our material.

  • Copy a material properties and assign it to our material can already be done (for the most part) with new KX_BlenderMaterial API:

KX_PYATTRIBUTE_RW_FUNCTION("alpha", KX_BlenderMaterial, pyattr_get_alpha, pyattr_set_alpha),
KX_PYATTRIBUTE_RW_FUNCTION("hardness", KX_BlenderMaterial, pyattr_get_hardness, pyattr_set_hardness),
KX_PYATTRIBUTE_RW_FUNCTION("specularIntensity", KX_BlenderMaterial, pyattr_get_specular_intensity, pyattr_set_specular_intensity),
KX_PYATTRIBUTE_RW_FUNCTION("specularColor", KX_BlenderMaterial, pyattr_get_specular_color, pyattr_set_specular_color),
KX_PYATTRIBUTE_RW_FUNCTION("diffuseIntensity", KX_BlenderMaterial, pyattr_get_diffuse_intensity, pyattr_set_diffuse_intensity),
KX_PYATTRIBUTE_RW_FUNCTION("diffuseColor", KX_BlenderMaterial, pyattr_get_diffuse_color, pyattr_set_diffuse_color),
KX_PYATTRIBUTE_RW_FUNCTION("emit", KX_BlenderMaterial, pyattr_get_emit, pyattr_set_emit),

RW means read and write.

from upbge.

panzergame avatar panzergame commented on May 29, 2024

@sdfgeoff : So you want to replace material for a RAS_MeshObject not per game object : RAS_MeshSlot ?
If yes i propose the following API:
KX_MeshProxy.replaceMaterial(matid, KX_BlenderMaterial)

But here we will get some trouble because there's no way to find a KX_BlenderMaterial other than found it in a mesh, so if we replace it, it's lost the the material.....
The solution shoudl be to expose a list of all material in a python proxy for the KX_BlenderSceneConverter.

from upbge.

sdfgeoff avatar sdfgeoff commented on May 29, 2024

Well I believe materials are associated with meshes, or at least, a texture slot in a mesh. As such it makes sense for the operation to be on a mesh.

If you replace it it's lost. That's fine by me.

from upbge.

axredneck avatar axredneck commented on May 29, 2024

Is it possible to implement tweaking the same material by passing some per-object "uniforms" to the shader, like "Object Color" already does? I know it's not exactly "switching of materials" but it can serve the same purpose, especially if passing these "uniforms" to node material.
edit: Excuse me for proposing yet another "feature request".

from upbge.

panzergame avatar panzergame commented on May 29, 2024

#244

from upbge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.