How to use Tuhopuu2. Simple sample?
Moderators: jesterKing, stiv
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
How to use Tuhopuu2. Simple sample?
I realize that you who are developing tuhopuu2 are very busy with
Important stuff but would be very thankful for some 'newbie' guidance.
I would like to get started with a very simple project.
Apply a pixel shader to a simple cube and render it.
It's not of any importance what the pixel shader actual do. I just want to know how to make it work.
I know that it has to be applied by Python-script, but how? I know how to write
very simple Python scripts.
Could any one be kind enough to show an example?
/roland
Important stuff but would be very thankful for some 'newbie' guidance.
I would like to get started with a very simple project.
Apply a pixel shader to a simple cube and render it.
It's not of any importance what the pixel shader actual do. I just want to know how to make it work.
I know that it has to be applied by Python-script, but how? I know how to write
very simple Python scripts.
Could any one be kind enough to show an example?
/roland
A Simple Example:
That is pretty much the simplest shader program you can do - it will turn every pixel in the attached object red.
You should set up the script to run once on game startup.
Also, check the console after game startup. It will print if your graphics card supports GLSL.
A more complex example is here:
http://projects.blender.org/viewcvs/vie ... &view=auto
Code: Select all
import GameLogic
mats = GameLogic.getCurrentController().getOwner().getMesh().materials
vs = """
// Vertex Shader:
void main ()
{
gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;
}
// End Vertex Shader
"""
fs = """
// Fragment Shader:
void main()
{
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}
// End Fragment Shader
"""
for mat in mats:
mat.loadShader(mat.VERTEX_SHADER, vs, "simple vertex shader")
mat.loadShader(mat.FRAGMENT_SHADER, fs, "simple fragment shader")
That is pretty much the simplest shader program you can do - it will turn every pixel in the attached object red.
You should set up the script to run once on game startup.
Also, check the console after game startup. It will print if your graphics card supports GLSL.
A more complex example is here:
http://projects.blender.org/viewcvs/vie ... &view=auto
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
Oh how wrong I was about the FX 5200 card. I supports GLSL using
nVidia ForceWare drivers from http://www.3dchipset.com.
nVidia ForceWare drivers from http://www.3dchipset.com.
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
Animating is fairly easy - do it like this:
And in the vertex shader:
Also, you've probably already found it, but The OpenGL Shading Language Reference is invaluable (especially the reference chapters 7 & 
ATI's RenderMonkey 1.5 supports GLSL, and has a ton of examples to get you going.
Code: Select all
own = GameLogic.getCurrentController().getOwner()
mats = own.getMesh().materials
for mat in mats:
mat.setUniform("time", own.time)
own.time = own.time + 0.2
Code: Select all
uniform float time;
// Texture animation velocity:
const vec4 tv = vec4(1.0, 0.0, 0.0, 0.0);
.
.
.
gl_TexCoord[0] = gl_MultiTexCoord0 + time*tv

ATI's RenderMonkey 1.5 supports GLSL, and has a ton of examples to get you going.
Does T2 also support PS 1.1 shaders for my poor, elderly geforce 3? 
edit: I think I found it
Still trying to get it to do something useful tho 

edit: I think I found it
Code: Select all
def loadProgram(source, name):
"""
Loads an assembly program into the material.
The type of program will be deduced from the source header:
1. !!ARBvp1.0Vertex Program (GL_ARB_vertex_program)
2. !!ARBfp1.0Fragment Program (GL_ARB_fragment_program)
@param source: The program to load. Can be either the source itself, or the name
of a text space.
@type source: string
@param name: (Optional) The name of the program. The name is printed to the console for debugging.
@type name: st

-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
I must be a real dummy but I can't get any shader
output using the sample provided in KX_PolygonMaterial.
I have described what I have done at http://www.rstralberg.com/t2start.htm.
Please! Could anyone give some advise or a hint of what
I'm doing wrong.
If I can make this work I could make a 'real nobody tutotial' of
how to do it and leave it on my website, so other 'dummies' can
learn also
Many thanks
/roland
output using the sample provided in KX_PolygonMaterial.
I have described what I have done at http://www.rstralberg.com/t2start.htm.
Please! Could anyone give some advise or a hint of what
I'm doing wrong.
If I can make this work I could make a 'real nobody tutotial' of
how to do it and leave it on my website, so other 'dummies' can
learn also

Many thanks
/roland
@dmao:
I think OpenGL vertex & fragment programs v1.0 are roughly the same as DirectX shaders 2.0. According to the hardware support list at delphi3d.net, it is GeforceFX and Radeon 9500 and up. Sorry.
@rstralberg:
Does your card support GLSL? (Check the console) You've said you have a Geforce FX, so you need drivers > 60.00
Have you loaded rfNormalMapping.frag and rfNormalMapping.vert into text spaces?
Have you UV mapped the object? Tangent space is in part derived from UV coordinates.
Is the lighting set up properly? (Looks to be correct)
That tangent space is a bit ugly... I should update the example.
I think OpenGL vertex & fragment programs v1.0 are roughly the same as DirectX shaders 2.0. According to the hardware support list at delphi3d.net, it is GeforceFX and Radeon 9500 and up. Sorry.
@rstralberg:
Does your card support GLSL? (Check the console) You've said you have a Geforce FX, so you need drivers > 60.00
Have you loaded rfNormalMapping.frag and rfNormalMapping.vert into text spaces?
Have you UV mapped the object? Tangent space is in part derived from UV coordinates.
Is the lighting set up properly? (Looks to be correct)
That tangent space is a bit ugly... I should update the example.
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
... for You!alien-xmp wrote:Animating is fairly easy


Next Steps are Testings with Alpha Textures. But Blender crashes each Time i try this. Also i fail to animate only the Second (Material) Texture. But i think i get this too!
I found the GLSlang Reference. Really cool, but hard to read for an english Zero like me.

Thanx a lot for this really cool hot spicy Feature! Please keep up this fantastic Work.
Doc
Oh, the Render Monkey Hint was useful too. I have an NVidia Card, so i've never thought about that. I found an other cool Tool for GLSL. The Shader Designer from http://www.typhoonlabs.com/ (It needs MS Dot Net to run.) I don't know how to use these Tools, but the Demos are realy cool!
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
I have uploadet the Example from the Tuhopuu Docu to my Webspace. You can download it here: *click me*
hmm...I thought bump mapping (no matter what kind) is a per-pixel fx that takes into account the direction of the light. However, in your example, the cube is not bump-mapped no matter how hard I sqink, the normal map only made the box purple-ish.
[edit] yeah i checked the console, errors, errors and more errors... I need some time to figure this out.
[edit] yeah i checked the console, errors, errors and more errors... I need some time to figure this out.
