Beta release 3.1b

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,
VilleK wrote:uniform vec4 globalColor; //The current color that is set using RenderSetColor or Material.Color
You're aware that OpenGL has / had ( deprecated since GLSL 1.3 ) the gl_MaterialParameters struct for those parameters, right? I think it would be better to follow that convention .. even though the Color property of the Material component isn't ( but should have been ) called Diffuse :?

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

Post by VilleK »

Sure, but I think it is nice to still be able to use RenderSetColor and Material.Color and it only required a few lines of code in the engine to support it.

Btw, which more variables do you think will be needed?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej,
VilleK wrote:Sure, but I think it is nice to still be able to use RenderSetColor and Material.Color and it only required a few lines of code in the engine to support it.
I simply mean "pushing" a uniform gl_MaterialParameters struct named material or frontMaterial which has a property called diffuse that is determined by GLDriver.SetColor, instead of a uniform vec4 named globalColor. That doesn't change how the RenderSetColor or Material components currently work.
VilleK wrote:Btw, which more variables do you think will be needed?
I'd limit it to fixed-function features that are build-in ZGameEditor. So for example, that would include a gl_LightSourceParameters array containing all light values, but not any of the fog properties since those don't have a component-based equivalent ( you can only access those using direct OpenGL calls ) ... at the moment at least :roll:

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

Post by VilleK »

Update:
- ShaderVariable.ArrayKind - new property. Default is Texture1D (like before) but you can also select Mat4 to map to a glsl mat4 type.
- Shader.Handle - new property. This is the GL handle of the shader. Use this when you want to make direct OpenGL calls.

New/renamed glsl-variables:

Code: Select all

uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
See example project GLES2Demo.zgeproj.

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Just one detail: Ville, can you please update the embedded ZGESensor library to the latest version? It is included eg. in this demo project. Thanks.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Rado1: Sure, I thought I already done that but I notice it wasn't. It will be in next update which I'm sure will be soon.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,
VilleK wrote:- ShaderVariable.ArrayKind - new property. Default is Texture1D (like before) but you can also select Mat4 to map to a glsl mat4 type.
Could you change the count argument of glUniformMatrix4fv into the size of the array divided by 16 ( or shifted right 4 bits )? That way you could also pass a array of mat4's.

K
jazz
Posts: 16
Joined: Sun Mar 24, 2013 2:46 am

Post by jazz »

VilleK wrote:Update:
- ShaderVariable.ArrayKind - new property. Default is Texture1D (like before) but you can also select Mat4 to map to a glsl mat4 type.
- Shader.Handle - new property. This is the GL handle of the shader. Use this when you want to make direct OpenGL calls.

New/renamed glsl-variables:

Code: Select all

uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
See example project GLES2Demo.zgeproj.

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
Awesome!!! :D

Edit: Was thinking in the wrong space. Thanks for doing this Ville.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Fixed:
- Crash when adding a model in project tree
- ShaderVariable can hold a array of mat4 (array length is divided with 16)
- Updated Android Sensor library

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Following up the GLES support with scripting functions necessary for 3d math:

- "mat4" and "vec3" types in scripting

- Multiply matrices

Code: Select all

mat4 m1,m2; 
m1=m1*m2;
- Transform a point

Code: Select all

mat4 m1; 
vec3 v1;
v1=transformPoint(m1,v1);
- Access matrix/vector elements

Code: Select all

mat4 m1;
vec3 v1;
m1[0, 0] = 1.0;
v1[0] = 1.0;
- mat4 and vec3 is also supported in Variable and Array components (including local arrays)

- mat4, vec3 are automatically garbaged collected values (just like strings). This allows you to create functions which return these values.

- Get and set current matrix.

Code: Select all

mat4 m1;
getMatrix(0,m1);  //0 = Model view, 1 = Projection, 2 = Texture
m1[0,0]=2.5;
setMatrix(0,m1);
- Local arrays are now also garbaged collected. So you can write functions that return local arrays (not possible before): "int[] getArray() { ... }"

- Variable and Array components now show their data type in the project tree (e.g. "I1 : Variable <int>" etc).

http://www.zgameeditor.org/files/ZGameEditor_beta.zip
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:shock:

Best update in 5 years!

Would it be possible that the properties panel of the Variable component changes depending on what Type is chosen ( see attached mock-ups )? Right now only floats can be modified, and the type-specific read-only properties might confuse beginners.

K
Attachments
Variable.png
Variable.png (13.19 KiB) Viewed 16321 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Really, great update! What about to add also vec4 for quaternions?

Do you recommend to implement own ZLibrary for scalar multiplication/division of matrices and vectors, vector addition, inverse matrix, vector cross and dot products, and quaternion operations (addition, normalization, conjugation, multiplication, ...). Or can some of them become standard built-in functions (which are faster than functions from ZLibrary)? BTW I have such a library which uses global arrays and will be rewritten to mat4 and vec3 from this recent update. Also would be glad if some functions became built-in, if possible.

How the getMatrix and setMatrix functions exactly work? Could you please provide some pointers to reading and/or some examples?
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Ville, how to access elements of vec3 and mat4 from arrays? For example, the following code is incorrect:

Code: Select all

vec3[2,2] arr;

float f1 = arr[0,0,0]; // invalid conversion error

float f2 = arr[0,0][0]; // assertion failure error
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hmm, seems to be a bug in the parser there. I'll try to fix it.

You can do this in the meantime:

Code: Select all

vec3 v;
vec3[2,2] arr;
v=arr[0,0];  //get a reference to the vec3
v[0]=1;  //modify it
This will modify the array because vec3 and mat4 are reference types, i.e. assigning v=arr[0,0] will make a reference (instead of copy) to the vec3.

About adding more built-in functions: I'm all for that, at least for "core" functions. However I see little point in copying all types and functions from GLSL since they can be used (with much higher performance) in GLSL instead.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

VilleK wrote:You can do this in the meantime:

Code: Select all

vec3 v;
vec3[2,2] arr;
v=arr[0,0];  //get a reference to the vec3
v[0]=1;  //modify it
That's exactly the way I'm using vectors for now. Not so pretty.

Just a consideration: which notation are you going to use then, arr[0,0,0] or arr[0,0][0]? In the first variant it would be possible to write arr[0,0,0,0,0] for 3d array of matrices. For now, this throws "Too many array dimensions" exception.
Post Reply