Skip to content

Instantly share code, notes, and snippets.

Created June 19, 2014 13:41
Show Gist options
  • Save anonymous/9352187819f11d3e169e to your computer and use it in GitHub Desktop.
Save anonymous/9352187819f11d3e169e to your computer and use it in GitHub Desktop.
# Simple render to texture
node = loader.loadModel("panda")
depthtex = Texture('depth')
colortex = Texture('color')
normaltex = Texture('normal')
colortarget = RenderTarget(T_color)
colortarget.set_clear((0, 0, 0, 1))
normaltarget = RenderTarget(T_color)
normaltarget.set_clear((0, 0, 0, 1))
depthtarget = RenderTarget(T_depth)
depthtarget.set_clear(0)
mainTarget = TargetCollection()
mainTarget.addTarget(colortarget)
mainTarget.addTarget(normaltarget)
mainTarget.addTarget(depthtarget)
node.set_render_target(mainTarget)
node.set_shader_input(mainTarget, "test", 1.0)
# Postprocessing
post_card = base.aspect2d.attach_new_node(myCardGeometry)
post_card.set_shader_input("colortex", colortex)
post_card.set_shader_input("normaltex", normaltex)
post_card.set_shader_input("depthttex", depthtex)
# Exclude some node from the normal buffer
# This target collection can be used multiple times
noNormalsTarget = TargetCollection(mainTarget)
noNormalsTarget.removeTarget(normaltarget)
noNormalsNode.set_render_target(noNormalsTarget)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment