Skip to content

Instantly share code, notes, and snippets.

@Utopiah
Created August 10, 2017 09:31
Show Gist options
  • Save Utopiah/976f09ed36be542ffeb42d74e22a9a8b to your computer and use it in GitHub Desktop.
Save Utopiah/976f09ed36be542ffeb42d74e22a9a8b to your computer and use it in GitHub Desktop.
Shading in Blender
import bpy
ob = bpy.context.object # get the active object
mesh = ob.data
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for space in area.spaces:
if space.type == 'VIEW_3D':
space.viewport_shade = 'MATERIAL'
bpy.context.scene.game_settings.material_mode = 'GLSL'
VertexShader = ""
FragmentShader = """
void main() {
gl_FragColor = vec4(0.6, 1.0, 0.0, 1.0);
}
"""
for mat in mesh.materials:
shader = mat.getShader()
shader.setSource(VertexShader, FragmentShader, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment