
How to use Tuhopuu2. Simple sample?
Moderators: jesterKing, stiv
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
I tried the Modifications on the Shader. Still looking fantastic and working fine on my NVidia Card.
But i have some (maybe stupid) Questions: While trying coding i see, it's very hard to find Bugs and Errors. Is there a Way to print out the Content of an Variable and other Stuff? Maybe: vec3 vv = normalize(viewvec); How can i print out the Content of vv now? Or: gl_TexCoord[0] = gl_MultiTexCoord0; What is the Content of gl_MultiTexCoord0; Does anybody now how this can be done?
Also: What can i do if i receive Messages like this in the Dos Box:This is coming directly from the GPU, right? Anyway, there is no Line Number or an other Hint where to find the Reason.
What can i do here.
Thanks for Help.
Doc
Edit -----------------------
Here is a Page with some cool OpenGL Demos. http://www.paulsprojects.net/opengl/projects1.html I can't wait to see such FX in Blender!

But i have some (maybe stupid) Questions: While trying coding i see, it's very hard to find Bugs and Errors. Is there a Way to print out the Content of an Variable and other Stuff? Maybe: vec3 vv = normalize(viewvec); How can i print out the Content of vv now? Or: gl_TexCoord[0] = gl_MultiTexCoord0; What is the Content of gl_MultiTexCoord0; Does anybody now how this can be done?
Also: What can i do if i receive Messages like this in the Dos Box:
Code: Select all
098D3440098ABE40:
(22) : warning C7011: implicit cast from "float4" to "float3"

Thanks for Help.
Doc
Edit -----------------------
Here is a Page with some cool OpenGL Demos. http://www.paulsprojects.net/opengl/projects1.html I can't wait to see such FX in Blender!

No. The shader is running on your graphics card. DirectX can do it when the software reference shader is running.While trying coding i see, it's very hard to find Bugs and Errors. Is there a Way to print out the Content of an Variable and other Stuff? Maybe: vec3 vv = normalize(viewvec);
The way I do it, is to set gl_FragColor to the variable you are trying to debug at the end of main(): ie
Code: Select all
void main()
{
vec3 vv = normalize(viewvec);
.
.
.
gl_FragColor = diffuse;
gl_FragColor.rgb = vv; // You don't need to comment out the rest
// of the shader code above.
}
Code: Select all
gl_FragColor.rgb = 0.5*vv + 1.0; // vv is expected to be 0.0 < vv < 1.0
That means you are converting a 4 component vector to a 3 component vector - something like this:Also: What can i do if i receive Messages like this in the Dos Box:
This is coming directly from the GPU, right? Anyway, there is no Line Number or an other Hint where to find the Reason. What can i do here.Code: Select all
098D3440098ABE40: (22) : warning C7011: implicit cast from "float4" to "float3"
Code: Select all
vec4 foo; // float4
vec3 bar; // float3
bar = foo; // implicit cast
bar = foo.xyz; // correct
22 in the error you posted is allegedly the line number - Alt-J in the text window will jump to it.
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
Hi
I have written a 'newbie' tutorial on how to apply a shader in T2
and placed it on my website. I'm self a newbie
.
Could any of you experts check it and tell me if there are
any errors of faults. Dont want to misslead others by publishing
any errors.
The address is http://www.rstralberg.com/t2.html
/roland
I have written a 'newbie' tutorial on how to apply a shader in T2
and placed it on my website. I'm self a newbie

Could any of you experts check it and tell me if there are
any errors of faults. Dont want to misslead others by publishing
any errors.
The address is http://www.rstralberg.com/t2.html
/roland
Last edited by rstralberg on Thu Aug 11, 2005 2:46 pm, edited 3 times in total.
Looks good:
1. You don't need to copy tuhopuu2\source\gameengine\PyDoc to .blender/scripts. tuhopuu2\source\gameengine\PyDoc contains the source for the game engine python reference. If you have epydoc installed, you can generate the html documentation as seen in the documentation section. (You can also generate the rest of the Blender Python documentation in tuhopuu2/source/blender/python/api2_2x/doc)
2. In "applying the shader" you should disable pulse mode for the always sensor, so you don't compile the shader every frame. This should give you better performance.
3. It's just a stylistic thing, but you can put the vertex & fragment shaders in their own text spaces, and mat.loadShader(shaderType, name_of_text_space, name_of_shader)
4. In tuhopuu2\source\gameengine\Ketsji\Shaders, there are utility functions that you can copy and paste into your own shaders - tangent space functions, lighting, shading etc. Some of these are still quite buggy, so patches are gratefully accepted.
5. In "Adding a shader" gl_TexCoord[0] should be gl_TexCoord[0].st
6. Use the new tangent transform. tangent[0..2].w is not written in the old one, which causes weird triangle flickering on ATIs.
1. You don't need to copy tuhopuu2\source\gameengine\PyDoc to .blender/scripts. tuhopuu2\source\gameengine\PyDoc contains the source for the game engine python reference. If you have epydoc installed, you can generate the html documentation as seen in the documentation section. (You can also generate the rest of the Blender Python documentation in tuhopuu2/source/blender/python/api2_2x/doc)
2. In "applying the shader" you should disable pulse mode for the always sensor, so you don't compile the shader every frame. This should give you better performance.
3. It's just a stylistic thing, but you can put the vertex & fragment shaders in their own text spaces, and mat.loadShader(shaderType, name_of_text_space, name_of_shader)
4. In tuhopuu2\source\gameengine\Ketsji\Shaders, there are utility functions that you can copy and paste into your own shaders - tangent space functions, lighting, shading etc. Some of these are still quite buggy, so patches are gratefully accepted.
5. In "Adding a shader" gl_TexCoord[0] should be gl_TexCoord[0].st
6. Use the new tangent transform. tangent[0..2].w is not written in the old one, which causes weird triangle flickering on ATIs.
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
Here is a little Python Code to load the Shaders from external Files. You just have to insert the Shader Name into the Script. Maybe "BumpMap". In that Case, You need a "BumpMap.vert" and a "BumpMap.frag" File, containing the Vertex and the Fragment Shaders. It seems, that the "running blend-File Path" can't get from Tuhopuu2. So You has to insert the Path where these Files are located manually. But that's a temporary Solution an will be change in Future. It's also possible to store the ShaderName and Path in Properties. Maybe You find it useful. 
Doc

Doc
Code: Select all
import GameLogic
import sys
ShaderName = "BumpMap" # <---------------------- Enter Shader here!
Path = "c:\\blender\\tuhopuu2\\shaders\\"
try:
# Try loading Shader Files
# ~~~~~~~~~~~~~~~~~~~~~~~~
FragFile = open(Path+ShaderName+".frag","r")
VertFile = open(Path+ShaderName+".vert","r")
FragShader = FragFile.read()
VertShader = VertFile.read()
FragFile.close()
VertFile.close()
except:
# Loading failed
# ~~~~~~~~~~~~~~
print "\n **** Problem while loading Shader Files! ****\n"
else:
# All fine, go Ahead!
# ~~~~~~~~~~~~~~~~~~
mats = GameLogic.getCurrentController().getOwner().getMesh().materials
shaders = [(mats[0].VERTEX_SHADER, VertShader, "vertex.vs"),
(mats[0].FRAGMENT_SHADER, FragShader, "fragment.fs")]
for mat in mats:
for shader in shaders:
mat.loadShader(shader[0], shader[1], shader[2])
# more Code here ...
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
@alien-xmp:
@Doc_Holiday:
Many thanks for your help.
I have updated the tutorial according
to your good advices.
And 'Doc_Holidays' code snippet
on loading from external files was
just awesome. Thanks.
The tut is still out there http://www.rstralberg.com/t2.html
/roland
@Doc_Holiday:
Many thanks for your help.
I have updated the tutorial according
to your good advices.
And 'Doc_Holidays' code snippet
on loading from external files was
just awesome. Thanks.
The tut is still out there http://www.rstralberg.com/t2.html
/roland
Last edited by rstralberg on Thu Aug 11, 2005 2:48 pm, edited 1 time in total.
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
Hm... I tried it but I guess my g-card does work with it =_=
Code: Select all
'import site' failed; use -v for traceback
GLEW: 1.2.3
RAS_OpenGLRasterizer:
GL Vendor : NVIDIA Corporation
GL Renderer: GeForce2 MX/PCI/SSE2
GL Version : 1.5.1
Colour : 24 bits (8/8/8/0)
Accum : 64 bits (16/16/16/16)
Depth : 16 bits
Stencil : 0 bits
Multisample: Not supported
Stereo : Disabled
Shadow maps: Not supported
GLSL : Supported
Vertex uniforms : 256
varyings : 32
attribs : 16
Fragment uniforms : 256
Programs : Vertex programs supported
Vertex Instructions (native): 128 (128)
TEMPs (native) : 12 (12)
PARAMs (native) : 96 (96)
ATTRIBs (native) : 16 (16)
Texunits : 2
WARNING: Light "Spot" ShadowBufferSize is evil.
Forcing to good value: 2048
Compiling Shader: vertex.vs:
(28) : warning C7011: implicit cast from "float4" to "float3"
(28) : warning C7011: implicit cast from "float4" to "float3"
(28) : warning C7011: implicit cast from "float4" to "float3"
(28) : warning C7011: implicit cast from "float4" to "float3"
39 lines, 8 warnings, 0 errors.
SM_Scene::~SM_Scene: There are still objects in the Sumo scene!
sys_init:warning - no sitedirs added from site module.
-
- Posts: 0
- Joined: Wed Jul 21, 2004 4:48 pm
- Location: Sweden
@sutabi
I also think your card is not supporting it
Here is my card
I notice that your card does only support vertex programs
and not fragment program. So that may be the problem.
/roland
I also think your card is not supporting it
Here is my card
Code: Select all
GLEW: 1.2.3
RAS_OpenGLRasterizer:
GL Vendor : NVIDIA Corporation
GL Renderer: GeForce FX 5200/AGP/SSE2
GL Version : 1.5.1
Colour : 24 bits (8/8/8/0)
Accum : 64 bits (16/16/16/16)
Depth : 24 bits
Stencil : 0 bits
Multisample: Disabled
Stereo : Disabled
Shadow maps: Supported
GLSL : Supported
Vertex uniforms : 256
varyings : 32
attribs : 16
Fragment uniforms : 128
Programs : Vertex & Fragment programs supported
Vertex Instructions (native): 256 (256)
TEMPs (native) : 16 (16)
PARAMs (native) : 256 (256)
ATTRIBs (native) : 16 (16)
Fragment Instructions (native): 1024 (1024)
ALU Instructions (native): 1024 (1024)
TEX Instructions (native): 1024 (1024)
TEX Indirections (native): 1024 (1024)
TEMPs (native) : 32 (32)
PARAMs (native) : 1024 (1024)
ATTRIBs (native) : 16 (16)
Texunits : 16
and not fragment program. So that may be the problem.
/roland
-
- Posts: 2
- Joined: Sat Jul 05, 2003 1:03 am
- Contact:
I found a nice, small and free OpenGL Analysis-Tool for Win and Mac. If You want to know what Your Card can do? Check this out: *here*.
Doc
Doc