Material settings for Texture2?

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Material settings for Texture2?

Post by jph_wacheski »

After Kj showed how texture2 can be used to effect texture(1) (see; viewtopic.php?t=493&postdays=0&postorder=asc&start=15 ) I have been testing some ideas for using this,. however it is a bit limited since the texture alignment values are for texture(1) only. Could we add to the material component;

TextureScale2
TextureX2
TextureY2
TextureRotate2
TextureWrapMode2

not sure if settings for texture3 would be usefull as well, probably for some stuff,. .
If this makes the Material component to too confusing,. perhaps brake it down into Material, and MaterialExtra or some such.

Also; I just found a bug testing this (latest beta, as always ;) ),. load the attached, then change Texture(1) on the m_one to 'None' notice that this effects m_two!
Attachments
material_tester.zgeproj
.zgeproj
(2.21 KiB) Downloaded 553 times
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi jph,

This is limitation I've ran into several times as well .. and is somewhat of a design flaw. However, most of the parameters you mention can be easily accessed and altered using a Shader .. apart from Rotate and especially WrapMode ( texture 2 & 3 always use Mirror ).

A solution could be to allow properties to be added to certain components ( Unity does exactly this ). So when you'd need 16 textures on one Material instead of 3, you could add 13 Texture Properties to the Material ( in a similar fashion to ModelStates for example ). This is not a easy task to implement though .. so I guess it's better to just work around it for now.

For example ( texture 1 scrolling horizontal, 2 vertical )

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Model Name="Model">
  <Definitions>
    <Bitmap Name="One">
      <Producers>
        <BitmapPixels NOfPoints="128" RandomSeed="0"/>
      </Producers>
    </Bitmap>
    <Bitmap Name="Two">
      <Producers>
        <BitmapCells RandomSeed="0" BorderPixels="0" PointCount="64"/>
      </Producers>
    </Bitmap>
    <Shader Name="Shader" UpdateVarsOnEachUse="255">
      <VertexShaderSource>
<![CDATA[//

uniform float time;

//

void main()
{
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[0][0] += time;
 
  gl_TexCoord[1] = gl_MultiTexCoord0;
  gl_TexCoord[1][1] += time;
 
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}]]>
      </VertexShaderSource>
      <FragmentShaderSource>
<![CDATA[//

uniform sampler2D tex1;
uniform sampler2D tex2;

//

void main()
{
  gl_FragColor = texture2D(tex1, gl_TexCoord[0].xy)+
                 texture2D(tex2, gl_TexCoord[1].xy);
}]]>
      </FragmentShaderSource>
      <UniformVariables>
        <ShaderVariable Name="Time" VariableName="time" Value="0.42"/>
      </UniformVariables>
    </Shader>
    <Material Name="Material" Texture="One" Texture2="Two" Shader="Shader"/>
  </Definitions>
  <OnRender>
    <ZExpression>
      <Expression>
<![CDATA[//

Time.Value += 0.005;]]>
      </Expression>
    </ZExpression>
    <UseMaterial Material="Material"/>
    <RenderSprite/>
  </OnRender>
</Model>
K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The current implementation is not adequate for multiple textures. We should have something like this:

Material
-- Textures
--- MaterialTexture Texture=Bitmap1 TextureX=0.5 ...
--- MaterialTexture Texture=Bitmap2 TextureX=0.75 ...

All the texture-related properties from Material are moved into a new MaterialTexture component which can be added as many as needed into a new property-list Textures on Material. It doesn't have to break compatibility with old zgeproj-files because code can be added that automatically translates to the new properties.

I believe this can be done with reasonable effort. What do you think, is it worth an attempt? And is the design sufficient?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Combining all texture-related properties in one Component is even better yes. And so is going all the way by removing all texture-related properties from the current Material Component, and "fixing" backwards compatibility by implementing a converter in the Editor .. which would be a first right? :wink:

So .. depends a little on how much effort ( your guess is probably best ), but it sounds good. Then I can finally stop splitting meshes / combining textures unnecessarily :roll:

K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Yes that does sound like a fine solution, often textures are not even used (flat, wire, etc) and the base material will have that covered,. and multi-texturing will be useage based and scalable,. often just one, some times more,. . I like it.

Possibly also an opportunity to add more of the standard gl lighting stuff to the base material;

GL_AMBIENT
GL_DIFFUSE (currently color?)
GL_SPECULAR
GL_EMISSION
GL_SHININESS

http://www.falloutsoftware.com/tutorials/gl/gl8.htm

if possible,. ? or is this stuff all being droped from gl in favour of straight shaders??
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

it is possible, but they ARE dropping it...
Expecially if we were going to move to OpenGL ES 2.0, it would be a pain to port that stuff without breaking compatibility! Those mad people completely removed the fixed pipeline... what the hell was wrong with that???? :(
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: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Francesco,

OpenGL ES would have to be a fork or a separate ( rendering ) mode. Standard OpenGL is the preferred platform for desktop deployment.

By the way, have you tried any Delphi for ARM ( Pandora ) development already?

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

Post by kattle87 »

:S don't speak about the pandora... it's still in production '-.-

The nice thing is that one of my friends is the one that is going to resell the pandoras in Italy... he is waiting too, of course :roll:

OpenGL ES could be good for PS3... but I have to admit that is the only one usefull situation I can think about actually.
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
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

current beta texture/material tests,. . nice ;)
Attachments
material_tester2.zgeproj
(2.79 KiB) Downloaded 558 times
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

Everybody uses LibGCM on PS3 instead of OpenGL ES. Besides .. dev-kits don't come cheap.

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

Post by kattle87 »

linux works on PS3 to a certain extent... and uses OpenGL ES ;)
That's the only feasible way for us to get something working on PS3 I guess... Provided that freepascal compiler works on PS3...
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
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Yeah I have all but given up on the consoles,. too corporate for me anyway. I just don't like working with those structures,. greed machines. PCs are still the largest installed base anyhow,. . win/mac/linux is a large audiance!

Here is a test with shaders,. I added a poem I like,. it is a sufi poem written a couple hundred years ago, recently translated by Coleman Barks. I found this due to this song by TV On The Radio - Staring At The Sun,. .

look here;
http://www.youtube.com/watch?v=oHrTOQ18yzU

the video captures some of the idea, with the waves of structure diverging and focusing, sweet stuff,. great tune too!
Attachments
level_changer_002.zip
.exe demo
(37.54 KiB) Downloaded 561 times
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

That's a very cool demo jph. I love how the patterns mix in a seemingly organic fashion and colors get increasingly intense as the poem progress.

How is it done? Multiple layers of geometry, each with a multi-textured shader?
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

This is basicly a mix of Kjell's duel texture shader (above, I did not realise how easy it is to blend textures in a shader, more simple shader examples please!) with that simple 2d fog shader I posted in tipsN'tricks for the color fading,. it just uses the nifty mix function ( mix( genType, genType, float ) in this case it takes colors as vec4) to mix the colors based on the gl_Position.z. Then it just paintes that tube geometry for my old tube shooter,. layerd 3X,. each scaled, and with z rotation offset by some noise,. . so a bunch of techniques I been playing around with all mashed together. :)

I was trying to emulate some of what Minter is doing with that Neon back drop in GRR,. think I got enouph working to do some cool bits with this system ;) I need to work on my geometry skills some as I still have only a vague understanding of how the 3d Expression generation works,. 3d math is though,. and I am getting a bit deeper into the shaders,. but also lots in there to figure out too.
iterationGAMES.com
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

This is basicly a mix of Kjell's duel texture shader (above, I did not realise how easy it is to blend textures in a shader, more simple shader examples please!) with that simple 2d fog shader I posted in tipsN'tricks for the color fading,. it just uses the nifty mix function ( mix( genType, genType, float ) in this case it takes colors as vec4) to mix the colors based on the gl_Position.z. Then it just paintes that tube geometry for my old tube shooter,. layerd 3X,. each scaled, and with z rotation offset by some noise,. . so a bunch of techniques I been playing around with all mashed together. :)

I was trying to emulate some of what Minter is doing with that Neon back drop in GRR,. think I got enouph working to do some cool bits with this system ;) I need to work on my geometry skills some as I still have only a vague understanding of how the 3d Expression generation works,. 3d math is though,. and I am getting a bit deeper into the shaders,. but also lots in there to figure out too.
iterationGAMES.com
Post Reply