Demomaster application framework with wxpython navigator


#101

Sorry about the double post I just thought this would be a good piece of code to put here. I modified the reflection shader to accept the model’s own texture and blend the two together. I have to say that realtime this thing is a lot more impressive but even so- Here’s my results.

Youtube video: youtube.com/watch?v=dN1e9G9V7yo

Here’s the code.

//Cg
//Cg profile arbvp1 arbfp1
//clcheung Mar 2009, base on The Cg Tutorial
//modified by mavasher 
void vshader(
    in float4 vtx_position : POSITION,
	in float2 vtx_texcoord0 : TEXCOORD0,
	in float4 vtx_color : COLOR0, 
	in float3 vtx_normal: NORMAL,
	in uniform float4 k_eyePositionW,
    uniform float4x4 mat_modelproj,
	uniform in float4x4 trans_model_to_world,
    out float4 l_position : POSITION,
	out float2 l_texcoord0 : TEXCOORD0,
	out float4 l_color : COLOR0, 
	out float3 l_R : TEXCOORD1)
	
{
    l_position = mul(mat_modelproj, vtx_position);
	l_texcoord0 = vtx_texcoord0;
	l_color = vtx_color; 
	float3 positionW = mul(trans_model_to_world,vtx_position).xyz; 
	float3 N = mul((float3x3)trans_model_to_world, vtx_normal);
	N=normalize(N); 
	float3 I = positionW - k_eyePositionW; 	
	l_R = reflect(I, N);
}

void fshader(
	in uniform float4 k_param1,
    in float3 l_R : TEXCOORD1,
	in uniform samplerCUBE k_texcube : TEXUNIT1,   //UNIT0
    in float2 l_texcoord0: TEXCOORD0,
	in float4 l_color        : COLOR0,
    in sampler2D tex_0 : TEXUNIT0,
	out float4 o_color: COLOR0
    )
{
	float4 r;
	r.xyz = l_R;
	r.w = k_param1.y; // reflection blur
    
	
	float4 tex = tex2D(tex_0, l_texcoord0);
	
	
	float4 reflectedColor = texCUBEbias(k_texcube, r);
	float4 partcolor = lerp(l_color, reflectedColor, 1) ;
	o_color = lerp(tex, partcolor, k_param1.x);
}                             

#102

Thank your for sharing this shader.

Yes, the original code has a missing set texture call on the virus egg. I found it also recently.


#103

(to admins and everybody) how about to stick a page with a collection of the best shaders around everybody could pick a-la-carte?


#104

I agree with astelix.

One suggestion: All the shaders should include a screenshot and the shader inputs from the python script.


#105

Is anyone not able to run demomaster because of a missing wx.aui module? I’m running on Kubuntu 9.04, and I have wxPython installed, but I get the following error:

Traceback (most recent call last):
  File "demomaster.py", line 36, in <module>
    import demomain
  File "/home/matt/Development/Games/Panda3D/demomaster-0.7/demomain.py", line 28, in <module>
    import wxDemoControl
  File "/home/matt/Development/Games/Panda3D/demomaster-0.7/wxDemoControl.py", line 2, in <module>
    import wxPanelControl
  File "/home/matt/Development/Games/Panda3D/demomaster-0.7/wxPanelControl.py", line 6, in <module>
    import wx, wx.aui
ImportError: No module named aui

Is there some obscure (K)ubuntu package I could be missing? I have python-wxgtk2.6, python-wxgtk2.8, python-wxaddons, python-wxglade, python-wxtools, and python-wxversion installed.


#106

@Arkaein: Yup I think everyone has that problem. The issue I think is with the install package, it doesn’t load up the wx.aui module. I just had to reinstall and I got it to work. I think other people on the forum had the same issue.

@everyone:

I built a crystal shader.

youtube.com/watch?v=UBAoU9TCl9U

//Cg
//Cg profile arbvp1 arbfp1

//by mavasher - based on some code by clcheung and ynjh_jo
void vshader(
    in float4 vtx_position : POSITION,
	in float4 vtx_color : COLOR0, 
	in float3 vtx_normal: NORMAL,
	in uniform float4 k_eyePositionW,
    uniform float4x4 mat_modelproj,
	uniform float4 mspos_cam,
	uniform in float4x4 trans_model_to_world,
	out float  l_smooth,
	out float  l_facingRatio,
	out float4 l_position : POSITION,
	out float4 l_color : COLOR0, 
	out float3 l_R : TEXCOORD1)
	
{
    l_smooth = smoothstep( -1.5,1,dot(vtx_normal, normalize(vtx_position)) );
    l_facingRatio = pow( 1.0-saturate( dot(vtx_normal, normalize(mspos_cam-vtx_position)) ), 2 );
	l_position = mul(mat_modelproj, vtx_position);
	l_color = vtx_color; 
	float3 positionW = mul(trans_model_to_world,vtx_position).xyz; 
	float3 N = mul((float3x3)trans_model_to_world, vtx_normal);
	N=normalize(N); 
	float3 I = positionW - k_eyePositionW; 	
	l_R = reflect(I, N);
}

void fshader(
	in uniform float4 k_param1,
	in float  l_smooth,
	in float  l_facingRatio,
	in float3 l_R : TEXCOORD1,
	in uniform samplerCUBE k_texcube : TEXUNIT1,   //UNIT0
    out float4 o_color: COLOR0
    )
{
	float4 r;
	r.xyz = l_R;
	r.w = k_param1.y; // reflection blur
    
	float4 reflectedColor = texCUBEbias(k_texcube, r);

	o_color = float4(lerp(reflectedColor.rgb*l_smooth, reflectedColor.rgb*l_smooth, k_param1.x),l_facingRatio*2.5);
}                             

#107

What exactly did you reinstall? I tried reinstalling the python-wxgtk2.8 Ubuntu package, but that had no effect. I then went to wxpython.org, found the instructions (at wiki.wxpython.org/InstallingOnUbuntuOrDebian) for upgrading to newer versions through an extra repository, installed most of the options (python-wxgtx2.8 conflicted with python-wxgtk2.8-ansi, but neither worked), but still could not get demomaster to run.

Any more clues?


#108

@Arkaein

I have no Linux installed and can’t help much. I search around and the problem seems like a multiple pythons with incomplete wxpython installation issue.

@others about shader collections
It is a good idea. But it might be complicated to make working demos to show / experiment shaders in Panda environment.

I have rewritten some code in demomaster for easy creation of some demo scenes and one can add little applications with new shaders by inheriting from the demo scenes quickly. But it is bounded to demomaster’s framework.


#109

Okay, I was able to get demos running (without wx) by doing a few things. First I tried using the instructions to run without wx controls enabled, however the command line syntex has to be updated from what is in the top post, since the wx enable flag is now the fourth parameter, so I used a line like:

python demomaster.py f f Ocean2Demo f

However this still gave the import error. To fix this issue I commented out the

import wxDemoControl

in demomain.py. Clcheung, it might be nice if you could only conditionally import this when wx controls are enabled. That would let people with these wx errors run the demos.

One more suggestion: it would be nice if the software printed out a list of available demo names, since without a GUI the only way to determine the valid demo names is to open every demo source file.

Running the demos this way I noticed that several (e.e., the ODE demos) lacked any sort of action. Is it necessary to run using the wx GUI to trigger the actions in these demos?


#110

Arkaein, the main purpose of demomaster to allow quick and easy ways to change parameters in the demos, mainly for testing and experiment purpose. Currently there is no way to use the actions and attributes if the wx framework is not available. Quite a lot of demos requires the wx framework I am afraid.

I’ve thought about enabling a panda gui if wx is not available. But currently have no time to work on it yet.


#111

Ok, I will take a look and implement a non-wx version in the coming one.


#112

While that would be very nice, I didn’t mean to suggest that an additional GUI would necessarily be worth the effort. I was mostly curious to see if I was missing anything, and was actually able to see the main effects of most demos by running from the command line.


#113

That’s fine. I want to write a gui system anyway.

Without wx gui, probably you can run 50-70% of demomaster. If I add a simple menu system, likely 70-90% functions can be examined.


#114

June 25, 2009
Version 0.8

  1. “Shaders – Hatching *” demos added for hatching effects
  2. “Shaders – Compositor”
    add “Hatching” screen effects


    add “Multiple” screen effect
  3. Performance tuning for ODE demos
  4. “Shaders – Advance Demo 1”
    Velvet shader added (seems not working well ?)
    Mario, Crystal shader from mavasher added.
  5. “Misc - Lens flare” demo added
    From Legion - discourse.panda3d.org/viewtopic.php?t=3044
  6. Panda GUI option support (now demomaster can run with no wxpython installed).

Run “demomaster.py f f f” if you don’t want wxpython.


#115

yikes! you finally trashed wx! :slight_smile:
very less hassle for sure - I’m terribly curious to see the new demomaster edition but where is it? there is no 0.9 in the usual page…


#116

Hi,
I have a problem with this demomaster-program.
When I start it by “python2.5 demomaster.py” the program starts, but I can’t press any buttons or scroll-down, so it hangs up.

Is this program usable on linux?

Do someone had this problem?

Thx, blenderkid


#117

@astelix

my mistake. it is version 0.8

@blenderkid

This is a good question. I have only tested it on Windows. The GUI is based on treegui, but with some modifications on top. I am not yet sure if I need to fix anything on Linux. Can astelix and other Linux users give some feedback after using it ?


#118

Man, you’ve been up to a lot of work here.

The new additions are great. I noticed on the crystal and mario shaders that the results don’t look very good with the monkey model. Maybe another model would look better.

Also, your velvet shader is interesting.


#119

yeah thankyou Cheung - I already got it watching closer the file dates on your repository.
By the way I’d to say that my actual work PC (rig1 in my signature) is going out of business regarding the demomaster 'cos it almost die under the weight of the power computing demand of the new stuff. I’m starting to think it’s time to switch to the rig nr2, expecially after the new ati linux drivers update that fixed a lot of issues. Let see…


#120

wohaa! :smiley:
without wx it runs like a charm and nearly everything runs fine. there’s so much usable code in this package, you could easily make a whole, well looking game with it!

thank you very much for this!

EDIT:

yupp. didn’t work with wx for me either. try starting it with

python demomaster.py f f f