Sign in to follow this  
sdaq

total noob here, using GLSL and Blender

Recommended Posts

ok, I'm here in blender looking at a model I imported from an OBJ format. It has a head, and I want to write a GLSL shader to rotate it around the neck, just like that little girl from "the exorcist". is this even possible?? can someone please get me started or point me in the right direction? thanks alot in advance!!

Share this post


Link to post
Share on other sites
There are a two ways that you can do this and the choice is yours:

Use a model format with animation support.

Actually split the model into parts and rotate only the one part that you need.

Share this post


Link to post
Share on other sites
funny you say that... the new employees have been bemoaning the use of the OBJ format for precisely this reason. we have been talking about going to COLLADA but you know how management is about adopting new file formats... they need immediate results. anyways, we are using opengl performer and so far, the head is rotating on the cpu by an update function that belongs to a DCS right above the geometry. my goal is to write a shader in GLSL that rotates the head for me on the gpu. i've never done this before and i'm trying to pick this up as fast as possible to get some results. Thanks!

Share this post


Link to post
Share on other sites
If you just want to do it for that particular model.. and the head is for example everything with Y > 1000 or something, then you can just do an if-statement in your GLSL shader, if(coordinate.y > 1000) rotatePoint(); And then you'll need some variable with the rotation angle that you update from your program.
Look into beginner GLSL tutorials that explain how the vertex shader works. If you have some way to know which vertices belong to the head, like adding a vertex attribute, that's ofcourse better. And the best of all is to have it as separate geometry with it's own shader.

Share this post


Link to post
Share on other sites
hey Erik, thanks for your comment... i'm interested in what you are saying. what do you mean by "separate geometry with its own shader"? after i read in the OBJ file (containing all the geometry for the whole body) using performer, all the geodes for the head are under a group node called "head_pivot". is there some way to have a shader attached to the group node so that the rendering state is inherited to all the children geodes (head geometry)? is that what you mean? I was thinking i could have a uniform variable or something that has the pivot xyz location that I can access in the shader, to provide a point for all the head geometry to rotate around. does that make sense?

Share this post


Link to post
Share on other sites
Yes that's what I mean, separate that part of the geometry to it's own draw routine. I'm not familiar with the program you're using, so I can't say if it's possible to do there. You could always try to manually separate the head in the model editor if that's acceptable, but it seems strange if there isn't a way to use separate shaders for different parts of the model. Your method should work fine for the rotation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this