Beta release 1.9.9b

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

Post Reply
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Beta release 1.9.9b

Post by VilleK »

Hi everyone, it's time again for a new beta phase. Updated March 4.

Major new features:

- Render to texture (FBOs)
- Multiple render passes
- String support in expressions
- Using external DLL-files

1. Render to texture
New component RenderTarget defines a render target.
New component SetRenderTarget makes a render target active. To go back to render to the main framebuffer use SetRenderTarget with no rendertarget set.
To use the texture that is the result of a rendertarget, use the new property RenderTarget on MaterialTexture.

See the included project RenderTexture.zgeproj for a demo. The demo renders a sphere on a RenderTarget then use the generated texture as draw a box on the main framebuffer.

Note: This feature needs a graphic card that supports FBOs (GL_EXT_framebuffer_object OpenGL extension). If you card does not support this then ZGE designer will display a message in the log on start up. Also note that each RenderTarget takes up a fair amount of video memory so don't use too many instances.

2. Multiple render passes
New property RenderPasses on Application defines the number of passes. The default is 1.
New property CurrentRenderPass on Application can be used to define different behaviour on render passes.
New event-list OnBeginRenderPass on Application. Here you define actions that should happen before each render pass (such as set rendertarget, clearcolor and clearscreenmode).

Possible uses:

- Use multiple passes to draw your models a little differently each pass for interesting effects. For this to work you need to set App.ClearScreenMode=1 (disable clear screen) when App.CurrentRenderPass>1 and App.ClearScreenMode=0 on the first render pass (App.CurrentRenderPass==0).

- Use the first pass to render to a texture, then use the generated texture on the next pass.

- Render to a texture then use this texture as an input to the next frame for feedback effects.

See the included project RenderPass.zgeproj for a demo.

3. String support in expressions

The new datatype "string" allows you to use string (8-bit ansi) values in expressions.

There are new built-in functions for strings:

//length : returns length of string
int i = length("1234"); //4

//indexOf(substr,str,startpos) : returns position of substring in string from a start position. Startpos must be less than length of string.
int i = indexOf("lo","hello",0); //3

//convert from/to integer
string s = intToStr(42); //"42"
int i = strToInt("42"); //42

//subStr(source,startpos,length) : return substring. Startpos and length must be within source-string bounds.
string s = subStr("hello",0,2); //"he"

//chr(charcode) : return character from ansi-code
string s = chr(65); //"A"

//ord(string) : return ansi-code from character
int i=ord("A"); //65

Special characters in string literals:
"\"" : double quote character
"\n" : newline character
"\\" : backslash character

With the string functions it makes life much easier when dealing with string properties on components, for instance just do this to display score in a game (instead of the old technique of using the TextFloatRef-property):
RenderText1.Text="Score: " + intToStr(Score);

The strings are automatically memory manged using a simple garbage collector. There is a bit of cpu-pressure involved, so be careful about doing complex string manipulation in the middle of your game because it might affect performance.

4. Using external DLL-files

I'm very pleased to announce it is now possible to call DLL-files from ZGE-scripts! This can be achieved with the new component ZExternalLibrary. The limitation is that you can only call functions which use simple parameters such as integers and floats, there is no support for complex parameters such as STRUCTS.

Here is a little list on how to convert DLL-parameter types to ZGE-types:
- int,byte,bool : int
- float : float
- LPCTSTR : string
- QWORD,INT64 : define two int-parameters

See the new included demo project ModPlay for an example on how to import bass.dll for music playback.

When calling DLL-functions there are often need for bit-manipulation operators so that has now been added to ZGE-scripting:

Hex-values: int x=0x0f; //15
Binary AND: int x=0xff & 0x0f; //0xf (15)
Binary OR: int x=1 | 2 | 4; //7
Binary Shift left: int x=1 << 1; //2
Binary Shift right: int x=2 >> 1; //1

It is also useful to be able to use the ZGE Window-handle as a parameter to Windows API-functions so this can be accessed using the new property:

App.WindowHandle //readonly

Other updates:
- GLSL-compilation now displays error messages which makes Shader-debugging easier.
- Help-file by yoffset is now included.
- Code completion in expression editor is improved.
- TexCoord on MeshExpression to create/modify texture coordinates.
- WebOpen-component to access web-pages.
- getSystemTime() function returns system time in number of seconds passed since midnight.
- while-loop in scripts supported
- not-syntax in scripts ("!(lives==0)", "!finished" etc)
- DefineConstant-component now has a type-property so you can define string and integer constants.
-Charcode-dropdown now displays 255 items.
-Fixed charcodes so that keypress of numeric keypad can be detected.
-Application.OnClose for actions that will be executed when the application closes
-AutoPowerOfTwo-property to RenderTarget for automatically set the rendertarget size to next higher power of two. The gl viewport is set to the chosen size.
-Updated Library.xml with components from diki and also external libraries.
-Fixed bug when inserting a component with nested components from library.
-Help-file from yoffset.
-ViewportX/Y/Width/Height properties can now be read on ZApplication component.
-FixedFrameRate can be changed in runtime.
-CallingConvention can be set on ExternalLibrary to stdcall or cdecl.
-ExternalLibrary works on Linux.
-More scripting enhancements:
--Switch-statements
--Conditional statement (x ? value1 : value2)
--Break and continue in loops

Download the beta here:

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
Attachments
renderpasses.png
renderpasses.png (60.77 KiB) Viewed 41388 times
rendertexture.png
rendertexture.png (25.42 KiB) Viewed 41388 times
Last edited by VilleK on Thu Mar 04, 2010 1:07 pm, edited 13 times in total.
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:shock:

Holy moly, it's on now! Only played around with it a little and already loving it ~ Thanks for making my weekend :wink:

* A over-the-top fish-eye effect using the new features :)

Image

K
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Oh, no! :D Now I have to find some time to spend on ZGE again :D

AMAZING one Ville! =)
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

Here is a loose remake of Hexadrive's ( Rez HD ) Fish-eye demo. Some notable differences ..

- Closed source, so the camera settings are slightly different
- They use a 1024x1024 FBO scaled down to 512x512
- ZGE has some ambient light by default
- Their camera looks slightly down
- Smaller file size :wink:

Use left mouse button + mouse to control. Thanks to Shviller for the debugging help ~

+ First real-time shadow testing

Image

K

*Updates Fish-Eye demo in new post
Last edited by Kjell on Sat Nov 28, 2009 11:33 am, edited 1 time in total.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Well this is interesting indeed! I will see what I can come up with using these new features,. .

The shadows look great Kjell!

We should work up some general/usable systems for use with these new rendering methods,. I shall explore the motion blur stuff that interests me,. .
iterationGAMES.com
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

8)

More FBO-fun .. a hypsometric ( + outline ) shader in overdrive. Useful for sonar effects?

K
Attachments
Hypsometric.gif
Hypsometric.gif (8.59 KiB) Viewed 41312 times
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

It's great to see you got some cool stuff going with it already Kjell :). Found any problems yet?

It's funny because until last week I had no idea on how to implement FBOs in ZGE and then suddenly it hit me and I wrote both these features in 3 hours. Sometimes you just have to wait for the right inspiration to come I guess.

The fisheye effect is a shader that takes a generated texture as an input and then calculates texture coordinates? What about the shadow, is it a render pass that generates a texture by setting the camera to the light source position?
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

The only problem I've encountered so far is that when the viewport ratio isn't identical to the window ratio, some issues ( stretching / clipping ) seem to occur. I'll have to look into it more carefully to find out what goes wrong exactly ...

Some smaller remarks, would it be possible to add resolution settings to the RenderTarget Component .. and wouldn't just OnPass be descriptive enough for the OnBeginRenderPass event? :roll:

Indeed, the fish-eye demo first renders the scene to a FBO, and then renders it to the screen using processed texture coordinates. My shadow setup first renders all shadow casters from the light perspective to a FBO, and then applies the mapping coordinates from that same matrix to the receivers.

K
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

OnBeginRenderPass : Yes I'm not too happy about this name either. But just OnPass feels a bit vague to me, unless you are familiar with render-passes it won't be obvious that it's got something to do with rendering. And I want to have "begin/start/before" in the name to imply that it is occurring just before a render pass begins. Then we can add "OnAfterRenderPass" later if needed. I'm open to any suggestions for a better name.

Ah yes, the viewport is not properly updated when switching target I think. I will need to fix that.

Resolution: How should it be selected? A drop-down with fixed resolutions such as: "Screen size, 1/2 screen size, 1/4 screen size, 128x128, 256x256, 512x512". Or separate Width/Height integer properties that can be set freely? Perhaps a combination of fixed and free just like the screen resolution properties on Application-component. I want to to default to the screen resolution because I believe that's the most common use.

And currently a FBO is always cleared when set. How should this be controlled? Depend on the App.ClearScreenMode or a separate SetRenderTarget.Clear property?
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

Wonder why you'd need a OnAfterRenderPass .. but I understand where you're coming from regarding the naming convention. Those things are always quite tricky to nail.

On the other hand .. anybody that has used 3d modeling software in the last couple of years should be familiar with the concept of Passes.

The resolution thing is not easy to decide on either. Having half / double ( one of the benefits of FBO's is that you can render to targets that are larger then your screen / window resolution ) is convenient for fullscreen / split-screen use, but rendering textures is usually done resolution independent so you'd want to set a specific size. A combination like the App Component has for setting resolution is probably best yes.

And either clear method you mention is fine :)

+ Attached two more .. planar reflection and chromatic aberration.

K
Attachments
FBO.jpg
FBO.jpg (42.87 KiB) Viewed 41223 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Resolution settings sounds like a good idea.

I have been messing around with this a bit, not gotten as far as Kjell.., down to shoddy math skills I suppose. Trying to work out how to keep the output matched to the screen size is hindering my feedback tests,. perhaps a modifided renderTansformGroup/renderSprite component that is fixed to render at the screen size would be usefull to many ppl, for full screen effects.

Did a quick test of shadow rendereing, just a simple top down light to generate a drop shadow, however it is also tough to get the size to lineup correctly (registration),. . is seems like my camera placments should be reversed, however it does not work that way,. can anyone explain that to me? I don't think my mental conception of this is quite right yet.
Attachments
ShadowCaster_000.zgeproj
.zgeproj of shadows with no shaders used.
(3.69 KiB) Downloaded 1150 times
iterationGAMES.com
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi jph,

For a full-screen sprite just use the following vertex shader in combination with the RenderSprite Component.

Code: Select all

void main()
{
  vec4 vertex = gl_Vertex;
  vertex.xy *= 2.0;
  gl_Position = vertex;
}
Or you could create a Mesh that is 2 units wide and high ( instead of 1 ) in which case you can simply use "gl_Position = gl_Vertex".

Not exactly sure what you're confused by concerning the light perspective / camera ( you're using Z as up which is confusing in itself for me :wink: ) .. but you really want to use shaders to calculate the texture coordinates. A decent tutorial on one of the approaches can be found here.

K
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Beta updated today:
- GLSL-compilation now displays error messages which makes Shader-debugging easier.
- Help-file by yoffset is now included.
- RenderTexture and RenderPass-projects are now included in the zip so I've removed them from the first post.
- RenderTarget has properties for choosing size and clear-screen behavior.
- SetRenderTarget uses Applications ViewportRatio.
User avatar
Kjell
Posts: 1910
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

Great to finally have the Help file available from the Editor ~ All features seem to be working just fine over here 8)

+ Had to try out the classic feedback effect :wink:

K
Attachments
Feedback.jpg
Feedback.jpg (32.87 KiB) Viewed 41161 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Could I see one working example (.zgeproj) of a fullscreen setup, I have not been able to get that to work here,. . thanks ;)
iterationGAMES.com
Post Reply