Created
August 10, 2017 09:31
-
-
Save Utopiah/976f09ed36be542ffeb42d74e22a9a8b to your computer and use it in GitHub Desktop.
Shading in Blender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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