Page 1 of 1

Rare material pseudo-shadow

Posted: Thu Sep 05, 2019 5:55 pm
by Psychophanta
Have this.
As can see, there is not a natural way of the shadow: the material is in some way, auto-shadowed.
If do NormalizeMesh(1) before the entity is created (after mesh transformation), the issue get better, but still the shadow is not correct.

Any idea?

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u,RY.u
If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home+"examples/3D/Data/Textures",#PB_3DArchive_FileSystem)
Add3DArchive("media/",#PB_3DArchive_FileSystem)
Parse3DScripts()

CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,3,#PB_Absolute)

LoadMesh(1,"peg-toporiginal_3ds.mesh")
TransformMesh(1,0,0,0,1,1,1,270,0,0):UpdateMeshBoundingBox(1)
;GetScriptMaterial(2,"peg-toporiginal_3ds#2")

CreateEntity(0,MeshID(1),#PB_Material_None,0,0,0)
Repeat
  ExamineKeyboard()
  WindowEvent()
  rotateentity(0,0,1,0,#PB_Relative)
  TimeSinceLastFrame.i=RenderWorld(50)
  FlipBuffers()
  Delay(8)
Until KeyboardPushed(#PB_Key_Escape)
Needed data here:
https://file.io/z7LHWc

EDIT:
Damn ! :o
It is volatile. Those services (file.io) are not useful for this.

Take it from here:
https://mega.nz/#!B9gwzIyQ!ZPay9tie_lXi ... 9vHnI-I64Q
or:
http://s000.tinyupload.com/?file_id=319 ... 3489564400

Re: Rare material pseudo-shadow

Posted: Thu Sep 05, 2019 8:21 pm
by applePi
Psychophanta , https://file.io/z7LHWc not available
404
Page not found
it is possible you have uploaded the file as .mesh not zip or .rar
you may find this free service useful: http://s000.tinyupload.com/index.php

Re: Rare material pseudo-shadow

Posted: Fri Sep 06, 2019 12:55 pm
by Psychophanta
Edited,
Thanks applePi :)

Re: Rare material pseudo-shadow

Posted: Sun Sep 08, 2019 8:53 am
by applePi
Psychophanta, the following version is visually better and smoother, instead of loading the material from material peg-toporiginal_3ds#2
load it with CreateMaterial(2, LoadTexture(2, "madera2.jpg"))
and add the material to the entity CreateEntity(0,MeshID(1),MaterialID(2),0,0,0)
in your version it is possible the specular, diffuse, emmissive, ambient values needs adjustments
but what annoys me and the funny part of your mesh is the darker side of the "wooden Top" the right side of the "madera2.jpg" contribute to some of the dark, but the mesh itself have another reason, may be the normals, tangents, and even the clockwise or anticlockwise wise of the mesh triangle on either sides of the wooden Top. don't know until now.
note that if we do NormalizeMesh(1) the wooden Top will appears as old toy

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u,RY.u
If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home+"examples/3D/Data/Textures",#PB_3DArchive_FileSystem)
Add3DArchive("media/",#PB_3DArchive_FileSystem)
Parse3DScripts()

CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0,3,#PB_Absolute)

CreateMaterial(2, LoadTexture(2, "madera2.jpg"))
CreateMaterial(3, LoadTexture(3, "Geebee2.bmp"))

LoadMesh(1,"peg-toporiginal_3ds.mesh")
TransformMesh(1,0,0,0,1,1,1,270,0,0)
UpdateMeshBoundingBox(1)
;NormalizeMesh(1)

;GetScriptMaterial(2,"peg-toporiginal_3ds#2")

;CreateEntity(0,MeshID(1),#PB_Material_None,0,0,0)
CreateEntity(0,MeshID(1),MaterialID(2),0,0,0)
SetEntityMaterial(0, MaterialID(3), 1) 
SetEntityMaterial(0, MaterialID(3), 0)

Repeat
  ExamineKeyboard()
  WindowEvent()
  RotateEntity(0,0,1,0,#PB_Relative)
  TimeSinceLastFrame.i=RenderWorld(50)
  FlipBuffers()
  Delay(8)
Until KeyboardPushed(#PB_Key_Escape)

Re: Rare material pseudo-shadow

Posted: Sun Sep 08, 2019 2:55 pm
by Psychophanta
Thank you applePi, you're a 3D master :wink:

EDIT:
However, shadows at the surface are still strange in this mesh, with or without 'NormalizeMesh(1)'

Re: Rare material pseudo-shadow

Posted: Mon Sep 09, 2019 1:45 pm
by applePi
by chance i got a better "wooden top" shadow :
uniting all submeshes to one big mesh using the code in the last example in viewtopic.php?f=36&t=66068
then import it with deepmesh software viewtopic.php?f=14&t=46115&start=45#p456533
after changing its MeshSerializer_v1.8] to MeshSerializer_v1.40] by a hex-text editor like "emeditor" and export to *.ply use that *.ply file with OgreAssimpConverter.exe to provide again the *.mesh which are used for this demo. OgreAssimpConverter.exe is available at the OGRE tools thread at the top of the 3D forum
i have used also:
BuildMeshShadowVolume(1)
UpdateMeshBoundingBox(1)
WorldShadows(#PB_Shadow_Additive)

attached:
1-your mesh modified as one big mesh
2-top_ply.ply
3-top_ply_ply.mesh (this is what will be used)
http://www.filedropper.com/meshes

Image

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u,RY.u
If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home+"examples/3D/Data/Textures",#PB_3DArchive_FileSystem)
Add3DArchive("media/",#PB_3DArchive_FileSystem)
Parse3DScripts()

CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0.5,3,#PB_Absolute)
CameraLookAt(0,0,0,0)

CreateMaterial(2, LoadTexture(2, "madera2.jpg"))
CreateMaterial(3, LoadTexture(3, "Geebee2.bmp"))
CreateMaterial(4, LoadTexture(4, "snow_1024.jpg"))
CreatePlane(7, 100,100, 1,1,1,1)
CreateEntity(7, MeshID(7), MaterialID(4), 0,-1.1,0)

;LoadMesh(1,"peg-toporiginal_3ds.mesh")
LoadMesh(1,"top_ply_ply.mesh") ;*****

;TransformMesh(1,0,0,0,1,1,1,270,0,0)
BuildMeshShadowVolume(1)
UpdateMeshBoundingBox(1)
;NormalizeMesh(1)

;GetScriptMaterial(2,"peg-toporiginal_3ds#2")

;CreateEntity(0,MeshID(1),#PB_Material_None,0,0,0)
CreateEntity(0,MeshID(1),MaterialID(2),0,0,0)
;SetEntityMaterial(0, MaterialID(3), 1) 
;SetEntityMaterial(0, MaterialID(3), 0)
;WorldShadows(#PB_Shadow_Modulative)
WorldShadows(#PB_Shadow_Additive)
EntityRenderMode(0, #PB_Entity_CastShadow )


Repeat
  ExamineKeyboard()
  WindowEvent()
  RotateEntity(0,0,1,0,#PB_Relative)
  TimeSinceLastFrame.i=RenderWorld(50)
  FlipBuffers()
  Delay(8)
Until KeyboardPushed(#PB_Key_Escape)

Re: Rare material pseudo-shadow

Posted: Tue Sep 10, 2019 10:38 am
by Psychophanta
Nice, the texture is oriented in the correct way in the central part of the body (wood part).
However, there is not a good idea to joint the 3 submeshes, because each part has to have a differente material.

By the way, i already converted the original to .mesh format, via OgreAssimpConverter.
Here are the 3 original models i have:
http://www.filedropper.com/3meshespegtop3ds

Re: Rare material pseudo-shadow

Posted: Wed Sep 11, 2019 1:10 pm
by applePi
Thanks Psychophanta for the Meshes,
there is not a good idea to joint the 3 submeshes, because each part has to have a differente material
Thats right, but my reason is that DeepMesh software does not export the toy submeshes to *,ply correctly so i have tried to provide it as one mesh version.
for the one big mesh version there is a choice to color some parts with a different color, if we use "Ogre Meshy" viewer version 1.5 it show use that there is 3 submeshes with vertex counts 258, 257, 1066. in the following code version we color the bottom and top in red and green. but the color will not displayed until we use either worldshadow, or DisableMaterialLighting(2, #True) or the two together.

this code needs "top_ply_ply.mesh" posted above here posting.php?mode=reply&f=36&t=73562#pr541640

Code: Select all

InitEngine3D():InitSprite():InitKeyboard():InitMouse()
ExamineDesktops()
Global bitplanes.a=DesktopDepth(0),FRX.u=DesktopWidth(0),FRY.u=DesktopHeight(0),RX.u,RY.u
If FRX<1280 Or FRY<720:RX=FRX*2/3:RY=FRY*2/3:Else:RX=1280:RY=720:EndIf
OpenWindow(0,0,0,RX,RY,"switch screen size",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,1,0,0,#PB_Screen_WaitSynchronization)
Add3DArchive(#PB_Compiler_Home+"examples/3D/Data/Textures",#PB_3DArchive_FileSystem)
Add3DArchive("media/",#PB_3DArchive_FileSystem)
Parse3DScripts()

CreateLight(0,$EEEEEE,4,4,2,#PB_Light_Point)
CreateCamera(0,0,0,100,100)
MoveCamera(0,0,0.5,3,#PB_Absolute)
CameraLookAt(0,0,0,0)

CreateMaterial(2, LoadTexture(2, "madera2.jpg"))
CreateMaterial(3, LoadTexture(3, "Geebee2.bmp"))
CreateMaterial(4, LoadTexture(4, "snow_1024.jpg"))
;DisableMaterialLighting(2, #True)
CreatePlane(7, 100,100, 1,1,1,1)
CreateEntity(7, MeshID(7), MaterialID(4), 0,-1.1,0)

LoadMesh(1,"top_ply_ply.mesh")
Dim MeshData.PB_MeshVertex(0)
Dim MeshDataInd.PB_MeshFace(0)
GetMeshData(1,0, MeshData(), #PB_Mesh_Vertex | #PB_Mesh_UVCoordinate | #PB_Mesh_Normal | #PB_Mesh_Color, 0, MeshVertexCount(1)-1)
GetMeshData(1,0, MeshDataInd(), #PB_Mesh_Face, 0, MeshIndexCount(1, 0)-1)
FreeMesh(1)
CreateMesh(0, #PB_Mesh_TriangleList, #PB_Mesh_Dynamic)
ArrSize = ArraySize(MeshData())
  ;Debug ArrSize
  For c=0 To ArrSize
      
      x.f  = MeshData(c)\x 
      y.f  = MeshData(c)\y
      z.f  = MeshData(c)\z
      MeshVertexPosition(x,y,z)
      If c<=257
        MeshVertexColor(RGB(255,0,0))
      ElseIf c>257 And c<257+258
        MeshVertexColor(RGB(0,255,0))
      Else
        
        MeshVertexColor(RGB(255,255,255))
      EndIf
      
      MeshVertexNormal(MeshData(c)\NormalX, MeshData(c)\NormalY, MeshData(c)\NormalZ)
      MeshVertexTextureCoordinate(MeshData(c)\u, MeshData(c)\v) 
      
  Next 
    
   
   ArrSizeInd = ArraySize(MeshDataInd()) 
   For i=0 To ArrSizeInd Step 3
     MeshFace(MeshDataInd(i)\Index, MeshDataInd(i+1)\Index,MeshDataInd(i+2)\Index)
   Next
   
   
   FinishMesh(#True)
   SetMeshMaterial(0, MaterialID(2))
    
  CreateEntity(0, MeshID(0), MaterialID(2), 0,40,0)
  ScaleEntity(0, 40,40,40)
   

;*****************************************************************************
BuildMeshShadowVolume(0)
UpdateMeshBoundingBox(0)
;NormalizeMesh(1)


;CreateEntity(0,MeshID(0),#PB_Material_None,0,0,0)
CreateEntity(0,MeshID(0),MaterialID(2),0,0,0)

;WorldShadows(#PB_Shadow_Modulative)
WorldShadows(#PB_Shadow_Additive)
EntityRenderMode(0, #PB_Entity_CastShadow )

Repeat
  ExamineKeyboard()
  WindowEvent()
  RotateEntity(0,0,1,0,#PB_Relative)
  TimeSinceLastFrame.i=RenderWorld(50)
  FlipBuffers()
  Delay(8)
Until KeyboardPushed(#PB_Key_Escape)