Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cguebert committed Dec 9, 2015
1 parent bd763ba commit 9adb97b
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 367 deletions.
80 changes: 80 additions & 0 deletions share/examples/Custom shader.pnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<Panda>
<Data name="render size" y="600" x="800"/>
<Data name="background color" b="1" g="1" r="1" a="1"/>
<Data name="timestep" real="0.01"/>
<Data name="use timer" int="0"/>
<Data name="use multithread" int="0"/>
<Object index="1" y="253" type="panda::ModifierShader_SetUniform" x="530">
<CreatedData type="real"/>
<Data name="name #1">time</Data>
</Object>
<Object index="2" y="287" type="panda::GeneratorNumber_AnimationTime" x="362"/>
<Object index="3" y="227" type="panda::GeneratorUser&lt;panda::types::Shader>" x="362">
<Data name="input" widgetData="Vertex;Fragment">
<Source type="1">#version 330

in vec2 vertex;
in vec2 texCoord;

uniform mat4 MVP;

out vec2 f_texCoord;

void main(void)
{
f_texCoord = texCoord;
gl_Position = MVP * vec4(vertex, 0, 1);
}</Source>
<Source type="2">#version 330

in vec2 f_texCoord;

uniform float time;

out vec4 fragColor;

const float pi = 3.1415926535897932384626433832795;

void main()
{
vec2 p = f_texCoord.st * 6.0;
vec3 col = vec3( 0.0, 0.0, 0.0 );
float ca = 0.0;
for( int j = 1; j &lt; 2; j++ )
{
float jj = float( j );

for( int i = 1; i &lt; 6; i++ )
{
vec2 newp = p * 0.9;
float ii = float( i );
newp.x += 1.2 / ( ii + jj) * cos( ii * p.y + time + 5 * ( jj / ii ) ) - 1;
newp.y += 1.2 / ( ii + jj ) * sin( ii * p.x + time + 5 * ( jj / ii ) ) + 1;
p=newp;
}

p *= 0.95;
col += vec3( 0.5 * sin( pi * p.x) + 0.5, 0.5 * sin( pi * p.y ) + 0.5, 0.5 * sin( pi * p.x ) * cos( pi * p.y ) + 0.5 );
ca += 0.8;
}
col /= ca;
fragColor = vec4( col * col, 1.0 );
}</Source>
</Data>
</Object>
<Object index="4" y="184.5" type="panda::GeneratorRect_RenderArea" x="530"/>
<Object index="5" y="223" type="panda::RenderFilledRect" x="676.5"/>
<Object dy="100" index="6" y="227.75" type="panda::Annotation" x="252.25" dx="200">
<Data name="text">Modified the fragment shader to render nice colors.</Data>
</Object>
<Object dy="100" index="7" y="367.75" type="panda::Annotation" x="332.25" dx="200">
<Data name="text">Use the time to animate the shader</Data>
</Object>
<Object dy="100" index="8" y="216.25" type="panda::Annotation" x="665.75" dx="200">
<Data name="text">Render the whole area with the custom shader</Data>
</Object>
<Link data1="input" object1="1" object2="3" data2="value"/>
<Link data1="value #1" object1="1" object2="2" data2="time"/>
<Link data1="rectangle" object1="5" object2="4" data2="area"/>
<Link data1="shader" object1="5" object2="1" data2="output"/>
</Panda>
File renamed without changes.
76 changes: 38 additions & 38 deletions share/examples/Layers.pnd
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
<Panda>
<Data x="300" y="300" name="render size"/>
<Data g="1" b="1" name="background color" a="1" r="1"/>
<Data real="0.1" name="timestep"/>
<Data int="1" name="use timer"/>
<Data int="0" name="use multithread"/>
<Object index="1" type="panda::Layer" x="-15.42105102539063" y="558.4210510253906">
<Data name="render size" y="300" x="300"/>
<Data name="background color" b="1" g="1" r="1" a="1"/>
<Data name="timestep" real="0.1"/>
<Data name="use timer" int="1"/>
<Data name="use multithread" int="0"/>
<Object index="1" y="558.4210205078125" type="panda::Layer" x="-15.42105102539063">
<Data name="name">Purple Rect</Data>
<Data int="0" name="composition mode"/>
<Data real="1" name="opacity"/>
<Data name="composition mode" int="0"/>
<Data name="opacity" real="1"/>
</Object>
<Object index="2" type="panda::Layer" x="132.5789489746094" y="558.4210510253906">
<Object index="7" y="364.0526428222656" type="panda::Layer" x="132.5789489746094">
<Data name="name">Red Disk</Data>
<Data name="opacity" real="1"/>
</Object>
<Object index="2" y="558.4210205078125" type="panda::Layer" x="132.5789489746094">
<Data name="name">Blue Rect</Data>
<Data real="1" name="opacity"/>
<Data name="opacity" real="1"/>
</Object>
<Object index="3" type="panda::Layer" x="-15.42105102539063" y="364.0526428222656">
<Object index="3" y="364.0526428222656" type="panda::Layer" x="-15.42105102539063">
<Data name="name">Orange Disk</Data>
<Data real="1" name="opacity"/>
<Data name="opacity" real="1"/>
</Object>
<Object index="6" type="panda::RenderDisk" x="-35.42105102539063" y="423.5526428222656">
<Object index="4" y="423.5526428222656" type="panda::RenderDisk" x="-35.42105102539063">
<Data name="center">
<Value x="125" y="125"/>
<Value y="125" x="125"/>
</Data>
<Data name="radius">
<Value real="35"/>
</Data>
<Data name="color">
<Value g="0.53" b="0" a="1" r="1"/>
<Value b="0" g="0.53" r="1" a="1"/>
</Data>
</Object>
<Object index="8" type="panda::RenderFilledRect" x="112.5789489746094" y="617.9210510253906">
<Object index="5" y="617.9210205078125" type="panda::RenderFilledRect" x="112.5789489746094">
<Data name="rectangle">
<Value t="50" b="150" l="50" r="150"/>
<Value l="50" b="150" t="50" r="150"/>
</Data>
<Data name="color">
<Value g="0" b="1" a="1" r="0"/>
<Value b="1" g="0" r="0" a="1"/>
</Data>
<Data name="shader">
<Source type="1">#version 440
<Source type="1">#version 330
in vec2 vertex;
uniform mat4 MVP;
void main(void)
{
gl_Position = MVP * vec4(vertex, 0, 1);
}</Source>
<Source type="2">#version 440
<Source type="2">#version 330
uniform vec4 color;
out vec4 fragColor;
void main(void)
Expand All @@ -52,22 +56,22 @@ void main(void)
}</Source>
</Data>
</Object>
<Object index="9" type="panda::RenderFilledRect" x="-35.42105102539063" y="617.9210510253906">
<Object index="6" y="617.9210205078125" type="panda::RenderFilledRect" x="-35.42105102539063">
<Data name="rectangle">
<Value t="125" b="200" l="125" r="200"/>
<Value l="125" b="200" t="125" r="200"/>
</Data>
<Data name="color">
<Value g="0" b="1" a="1" r="0.66"/>
<Value b="1" g="0" r="0.66" a="1"/>
</Data>
<Data name="shader">
<Source type="1">#version 440
<Source type="1">#version 330
in vec2 vertex;
uniform mat4 MVP;
void main(void)
{
gl_Position = MVP * vec4(vertex, 0, 1);
}</Source>
<Source type="2">#version 440
<Source type="2">#version 330
uniform vec4 color;
out vec4 fragColor;
void main(void)
Expand All @@ -76,27 +80,23 @@ void main(void)
}</Source>
</Data>
</Object>
<Object index="10" type="panda::Layer" x="132.5789489746094" y="364.0526428222656">
<Data name="name">Red Disk</Data>
<Data real="1" name="opacity"/>
</Object>
<Object index="12" type="panda::RenderDisk" x="112.5789489746094" y="424.0526428222656">
<Object index="8" y="424.0526428222656" type="panda::RenderDisk" x="112.5789489746094">
<Data name="center">
<Value x="200" y="200"/>
<Value y="200" x="200"/>
</Data>
<Data name="radius">
<Value real="35"/>
</Data>
<Data name="color">
<Value g="0" b="0" a="1" r="1"/>
<Value b="0" g="0" r="1" a="1"/>
</Data>
</Object>
<Object index="13" type="panda::Annotation" x="-22.42105102539063" y="326.2368469238281" dx="200" dy="100">
<Data name="text">Layers can be reordered using the "Layers" dock widget.
<Object dy="100" index="9" y="326.2368469238281" type="panda::Annotation" x="-22.42105102539063" dx="200">
<Data name="text">Layers can be reordered using the "Layers" dock widget.&#xd;
The blend mode and opacity of each can also be changed.</Data>
</Object>
<Dock docked="9" dock="1"/>
<Dock docked="8" dock="2"/>
<Dock docked="6" dock="3"/>
<Dock docked="12" dock="10"/>
<Dock dock="1" docked="6"/>
<Dock dock="7" docked="8"/>
<Dock dock="2" docked="5"/>
<Dock dock="3" docked="4"/>
</Panda>
File renamed without changes.
Loading

0 comments on commit 9adb97b

Please sign in to comment.