Lost Light Effect on Created Meshes

Blitz3D Forums/Blitz3D Beginners Area/Lost Light Effect on Created Meshes

Volturna(Posted 2015) [#1]
Hi everyone!

I've read some posts with the same topic subject, and light effect is restored with UpdateNormals or with Calculate_Normals (function by sswift)...

...but still cant see the light :D

I've a huge code so i will try to resume it step by step:

1) load 6 faces of a cube from a .b3d file (face1, face2,..., face6)

2) paint every mesh with a different brush

3) create a new mesh called 'CubeN'

4) add every face mesh to 'CubeN'

5) free every face entity

6) repeat steps 1 to 5 so i have Cube1, Cube2, Cube3.....

6) create a new mesh called 'MainMesh'

7) add every cube to 'MainMesh'

8) free every cube entity


So now i have a single mesh made of several meshes, but no light effect on it

Where do i use UpdateNormals? It should work using it after step 8?!


Best regards


RemiD(Posted 2015) [#2]
You can use updatenormals or your own procedure/function to calculate the normal of each vertex depending on the kind of lighting you want (flat shading, "progressive shading", "realistic shading")
Usually the procedure/function must be used after the surface has been modified.

But if you add prebuilt shapes to one surface, you can calculate the normal of each vertex of the prebuilt shape, and then when you add the surface of the shape to another surface, you don't need to recalculate the normal of each vertex if the procedure/function to add the surface to another surface takes into account the vertices normals.

Here is an example to add one surface to another surface (similar to addmesh()) : (post#1)
http://www.blitzbasic.com/Community/posts.php?topic=102895


Matty(Posted 2015) [#3]
Sometimes blitz sets the vertices colors to full bright meaning you have to manually reset them to rgb 0 by looping through all the vertices.


RemiD(Posted 2015) [#4]

Sometimes blitz sets the vertices colors to full bright meaning you have to manually reset them to rgb 0 by looping through all the vertices. 


What do you mean ? From what i understand fullbright is a property of a material/brush and thus of a surface, not of a vertex...
http://www.blitzbasic.com/b3ddocs/command.php?name=BrushFX&ref=3d_a-z


Volturna(Posted 2015) [#5]
.... i forgot to say that my brush is made of 4 blended textures like this:

tex0=LoadTexture("0.bmp",1+8)
tex1=LoadTexture("1.bmp",4):
tex2=LoadTexture("2.bmp",1+8)
tex3=LoadTexture("3.png",2+16+32):

TextureBlend tex0,1
TextureBlend tex1,1
TextureBlend tex2,2
TextureBlend tex3,1

brush=CreateBrush()

BrushTexture brush,tex0,0,0
BrushTexture brush,tex1,0,1
BrushTexture brush,tex2,0,2
BrushTexture brush,tex3,0,3


Removing blend my light effect can be seen


RemiD(Posted 2015) [#6]
If you blend too many textures and depending on the blendmode, a texel may have the maximum color (R,G,B) that a texel can have (up to 255 for R, for G, for B), so a directx light will not light it more...


Matty(Posted 2015) [#7]
Yes that is right RemiD...but lighting in blitz is vertex lighting and simply changes the vertex colours....sometimes meshes have all their vertex colours set to 255,255,255 which means that vertex lighting does nothing unless the vertex colours are reset to 0 first.

I thought he was referring to vertex lighting though...i didn't see a reference to 'full bright'...


Volturna(Posted 2015) [#8]
I just set all vertex color to RGB 0,0,0 but still no light...

....so i supose the effect i want is a lost fight.

thank you for the support!


RemiD(Posted 2015) [#9]

sometimes meshes have all their vertex colours set to 255,255,255 which means that vertex lighting does nothing unless the vertex colours are reset to 0 first.


Matty>>I don't think this is true... I think you can use vertex colors to color a surface and still have a directx light affect it...
I will do a test just to be sure...

Volturna>>Maybe post a simple code example with your mesh and textures so that we can take a look...


RemiD(Posted 2015) [#10]
I confirm that you can color a surface with vertex colors and still have a directx light affect it.
See :

as you can see, even if the color of each vertex is 255,255,255, the surface is still affected by the directx light.


Stevie G(Posted 2015) [#11]
It makes it pretty clear in the docs that textureblend 1 is not recommended for multi texturing.

http://www.blitzbasic.com/b3ddocs/command.php?name=TextureBlend&ref=3d_a-z

What exactly is the effect you are after and can you post a picture showing this effect? I'm sure there will be someone here who can advise on the best way to achieve it.


Volturna(Posted 2015) [#12]
RemiD - I lost my light effect when i create a brush made of more than 1 blended texture.

Stevie G - i'm trying to achive ambient occlusion in a spaceship so my first move was to change vertex colors... but vertex color didnt work so now i'm trying do get some light effect so model wont be so flat... but same problem.

If i use a single texture there is no problem, but i need mutitexturing on this!


Volturna(Posted 2015) [#13]
I'm now using another texture 'layer' in the same brush to simulate ambient occlusion.

(no need to explain the pain in the ass i'm feeling right now)



Not perfect but... :)