Light up objects question

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
Magnos
Posts: 7
Joined: Tue Dec 30, 2014 3:28 pm

Light up objects question

Post by Magnos »

Hello

Ihave a question, How do you get; for example a CubeMesh (3d object) brighter, to add some light?? I have a cube with a video texture bitmap on it and my idea was to make the texture brighter.. to glow.. And please can you explain where to add the components if there so? Example. App.Content.Model.OnRender etc
Thanks for the help :)
Regards
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Re: Light up objects question

Post by Kjell »

Hi Magnos,

You can't make a texture appear brighter than its texture(s) using just lighting. You either need to use a shader or additive blending. Here's a example that uses additive blending.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application">
  <OnLoaded>
    <SpawnModel Model="Box"/>
  </OnLoaded>
  <Content>
    <Model Name="Box" RotationVelocity="0.25 0.25 0">
      <OnUpdate>
        <ZExpression Expression="BrightnessMaterial.Color.A = sin(App.Time)*0.5+0.5;"/>
      </OnUpdate>
      <OnRender>
        <UseMaterial Material="BoxMaterial"/>
        <RenderMesh Mesh="BoxMesh"/>
        <UseMaterial Material="BrightnessMaterial"/>
        <RenderMesh Mesh="BoxMesh"/>
      </OnRender>
    </Model>
    <Mesh Name="BoxMesh">
      <Producers>
        <MeshBox/>
      </Producers>
    </Mesh>
    <Bitmap Name="BoxBitmap" Filter="1">
      <Producers>
        <BitmapCells RandomSeed="8" BorderPixels="1" PointCount="8"/>
      </Producers>
    </Bitmap>
    <Material Name="BoxMaterial">
      <Textures>
        <MaterialTexture Texture="BoxBitmap" TextureWrapMode="2" TexCoords="1"/>
      </Textures>
    </Material>
    <Material Name="BrightnessMaterial" Light="0" Blend="2"/>
  </Content>
</ZApplication>
Glow is ( generally considered ) something else entirely though.

K
Magnos
Posts: 7
Joined: Tue Dec 30, 2014 3:28 pm

Post by Magnos »

Hi Kjell
Thanks for your quick answer and help :)Your example was cool and I got a Material and Use material, also a new Rendermesh component, but the thing is that, when i apply it to my project I see that the video texture bitmap (my rendered video texture) gets whiter, that is making the videotexture to be replaced for a White global color, but i want to make the light of the texture brighter, I don´t know if I am expressing this correctly but I want the texture to have some bright from its own, like some feedback on its own colors, for example my video has 3 colors red, Green, and yellow, i want to up those colors, like in a shining way.

Hope you can help me and
Thanks for your help:)
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Magnos,

Hmm .. do you have Photoshop ( or something similar )? Perhaps you could create the result you're after in Photoshop and list the step(s) / effect(s) you've used. That would make it a lot easier to understand.

Anyway, here's a shader based example that multiplies the color values instead.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application">
  <OnLoaded>
    <SpawnModel Model="Box"/>
  </OnLoaded>
  <Content>
    <Model Name="Box" RotationVelocity="0.25 0.25 0">
      <OnUpdate>
        <ZExpression Expression="Brightness.Value = sin(App.Time)*2+2;"/>
      </OnUpdate>
      <OnRender>
        <UseMaterial Material="BoxMaterial"/>
        <RenderMesh Mesh="BoxMesh"/>
      </OnRender>
    </Model>
    <Mesh Name="BoxMesh">
      <Producers>
        <MeshBox/>
      </Producers>
    </Mesh>
    <Bitmap Name="BoxBitmap" Filter="1">
      <Producers>
        <BitmapCells RandomSeed="8" BorderPixels="1" PointCount="8"/>
      </Producers>
    </Bitmap>
    <Shader Name="BoxShader">
      <VertexShaderSource>
<![CDATA[void main()
{
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}]]>
      </VertexShaderSource>
      <FragmentShaderSource>
<![CDATA[uniform sampler2D tex1;
uniform float brightness;

void main()
{
  gl_FragColor = texture2D(tex1, gl_TexCoord[0].st) * brightness;
}]]>
      </FragmentShaderSource>
      <UniformVariables>
        <ShaderVariable Name="Brightness" VariableName="brightness" Value="3.2025"/>
      </UniformVariables>
    </Shader>
    <Material Name="BoxMaterial" Shader="BoxShader">
      <Textures>
        <MaterialTexture Texture="BoxBitmap" TextureWrapMode="2" TexCoords="1"/>
      </Textures>
    </Material>
  </Content>
</ZApplication>
K
Magnos
Posts: 7
Joined: Tue Dec 30, 2014 3:28 pm

Post by Magnos »

Hi Kjell

Thanks a lot that was i was looking for, Shader was a new component for me lol :) but I copied the

void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

and the other 2d sampler thing (I don´t really understand both) and in my ZExpression: Brightness.Value=Parameters[?]*5 and now the video texture colors highten, Now I want to detail one thing; I see that the color highten, but it respect the line, i want that the brightness to extend beyond the line i mean that the brihgtness extend to other pixels. Please
Thanks for your help :)
Regards
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Magnos,

Ah, you probably mean this* kind of effect? FL Studio has the "14. Blooming" clear effect for that, but perhaps you want to integrate it in your script?

*Don't bother with that example though, as it doesn't use the separate-axis approach .. which is what you want.

K
Magnos
Posts: 7
Joined: Tue Dec 30, 2014 3:28 pm

Post by Magnos »

Hi Kjell
Yes, that´s the type of blooming/glowing I want to make,The jpg link you sent looks really good, I like alot the Blooming Clear effect, but as you said I want to integrate it in my script:), How did you get that Gaussian Bright Effect? I mean to make it glow outside the projection perimeters?

Thanks For the help :)
Regards
User avatar
Kjell
Posts: 1883
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Magnos,
Magnos wrote:Yes, that´s the type of blooming/glowing I want to make
Alright, attached is a basic example. This is just one way ( of many ) to do this kind of effect .. aside from the fact that there are quite a few parameters / values that you can tweak.

And this is obviously a bit more advanced topic .. so don't feel discouraged if you don't understand what's going on.

K
Attachments
Bloom.zgeproj
(4.43 KiB) Downloaded 330 times
Magnos
Posts: 7
Joined: Tue Dec 30, 2014 3:28 pm

Post by Magnos »

Hi Kjell,
I liked a lot that Bloom vintage type of effect you created, i think that manipulating light isn´t a quite easy topic but with your help i already got some light on my scripts, i want to know more about it when i´ll be ready because right now i don´t understand quite good how does it works, i won´t be discouraged, but feel i need to learn a lot.
Post Reply