I was wondering how I could take a transparent object in the bge and give it a borderlands style edge outline so that the object is still transparent but has a black edge. Right now Im using a solidify modifier to add the outline but i cant get it to cooperate with the object transparency. Im thinking that this will probably involve some code which im totally fine with. Although i would prefer a solution without code. thanx for all your answers!
-
$\begingroup$ is the object round and organic or blocky and geometrical? $\endgroup$– ruckusCommented Oct 12, 2015 at 14:05
-
$\begingroup$ well id prefer any solution to work on any kind of object, anything from cubes to humans but in this case organic and round $\endgroup$– ZachariahRSCommented Oct 13, 2015 at 2:31
-
$\begingroup$ still looking for an answer thank you to the people who have taken the time to look over my question $\endgroup$– ZachariahRSCommented Oct 27, 2015 at 1:07
2 Answers
- You need 2 object, one with a wire transparent material the other with solid material.
- You can adjust the alpha in Transparency.
3 And can control with a script, also control the scale.
script.py (example)
from bge import logic
class ObjectsList():
def __init__(self, controller):
self.obj = [obj for obj in logic.getCurrentScene().objectsInactive if not obj.name[-1].isdigit()]
self.objLiner = [obj for obj in logic.getCurrentScene().objectsInactive if obj.name[-1].isdigit()]
def main(self):
print(self.obj)
if len(self.obj) > 0:
obj = self.obj.pop(0)
outliner = self.objLiner.pop(0)
##creating a solid obj
mainObj = logic.getCurrentScene().addObject(obj.name)
##creating outliner
outlinerObj = logic.getCurrentScene().addObject(outliner.name)
##scaling up
outlinerObj.localScale = [1.04]*3
##changing alpha
outlinerObj.meshes[0].materials[0].alpha = 0.3
outlinerObj.suspendDynamics(True)
outlinerObj.setParent(mainObj)
print('obj created...')
def main(controller ):
if not 'init' in controller.owner.getPropertyNames():
controller.owner['objHandler'] = ObjectsList(controller)
controller.owner['init'] = True
return
controller.owner['objHandler'].main()
Python API (bge object material)
bge.types.KX_BlenderMaterial.alpha
I couldnt found relate documentation about change material type: wire
You can do this in post processing, but it is not easy. Here's an image with a "grainy" effect on an outline:
And here's one with a more normal outline:
As you can see here, the outline is not blocked by other objects. This is just how I have it set up currently. With some more tweaking you can make it so that other objects block the outline.
How is this done? I create a renderpass of just the chair (by setting everything else invisible temporarily). Then I run an edge-detect on that and overlay it on the scene. This is done through render to texture to get the image into a texture, and a node shader. This is not trivial to explain how to set up, so here's a blend file for you to play with:
-
$\begingroup$ Does this apply to the game engine? Do we have game engine shading nodes? $\endgroup$– LeanderCommented May 9, 2017 at 8:40
-
$\begingroup$ This is in the game engine. You can convert the image from a not-currently-used camera into a texture. And then you can use that texture with the material nodes. $\endgroup$– sdfgeoffCommented May 9, 2017 at 19:01
-