Author Topic: Loading Shaders and objects from BSP (beta)  (Read 1597 times)

0 Members and 1 Guest are viewing this topic.

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Loading Shaders and objects from BSP (beta)
« on: November 04, 2015, 12:31:58 PM »
Thanks to Nikolas help, did try a beta test for load BSP entities and shaders, and this is the result:




IT'S GOOD!!!  :P

Goes to try it out in a big map, in order to look for errors (or not ;-) )


Edit:
another test, whith smoke or shinning from windows ;-)


 :P :P :P
« Last Edit: November 04, 2015, 12:58:25 PM by jepalza »

Offline Alec - WS3D Developer

  • Producer
  • Administrator
  • Marquess
  • *
  • Posts: 830
  • Reputation 31
  • Game making is my hobby for life!
Re: Loading Shaders and objects from BSP (beta)
« Reply #1 on: November 04, 2015, 02:55:09 PM »
Wow! It looks just super-duper!  :o
WorldSim3D = 3D + FreeBasic. Программируй в удовольствие, а не "в тягость"! Make your project with pleasure, not with strain!

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #2 on: November 04, 2015, 03:18:44 PM »
In short (this afternoon), try to probe this example with my "old" BSP_Viewer and my WOW Camera like style. It will be spectacular!!  :) (Like a Quake III Arena game, but written in FreeBasic)

Edit:
With a very, very big map like SIMPSONS , is very slow, only two frames per second, fails a little textures and error like picture
 
« Last Edit: November 04, 2015, 03:28:17 PM by jepalza »

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #3 on: November 04, 2015, 04:14:30 PM »
Good result!
Quote
Too many vertices for 16 bit....
The maximum value is approximately equal to
Code: [Select]
Dim verts(0 to 32667) as wVERTSee the theme: http://worldsim3d.com/Forum/index.php?topic=139.15
If not enough, you need to split the level into parts.
Or come up with another way to optimize (now)
« Last Edit: November 04, 2015, 04:16:11 PM by nikolas »
Под лежачий камень мы всегда успеем...

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #4 on: November 05, 2015, 08:41:18 AM »
With SIMPSONS map is not possible, is a very big map. But is the only big map, it's alone.

Another picture, with my WOW like style camera :D


It's very real feel, like a QUAKE3 Arena

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #5 on: November 05, 2015, 08:55:05 AM »
A little problem, if shaders is not in collision map:



But not at all must be in collision map:



Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #6 on: November 05, 2015, 02:14:39 PM »
Need a recognition system Shader nodes to be divided into two groups:
1) collisions (boxes, lamps, pools, large objects, glass, etc.)
2) no collisions (torches, sunlight, fire, etc.).

Can offer algorithm:
1) Looking for the right Shader nodes (I'll work on that)
2) Read his name
3) If you want, then create a node for the selector triangles.

Perhaps you have a different algorithm?
« Last Edit: November 05, 2015, 02:21:47 PM by nikolas »
Под лежачий камень мы всегда успеем...

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #7 on: November 05, 2015, 02:30:46 PM »
Perhaps you have a different algorithm?

At this moment, no, sorry. I'm look into BSP structure, in order to investigate it.

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #8 on: November 05, 2015, 02:39:20 PM »
Then I'll try to implement the above algorithm
Под лежачий камень мы всегда успеем...

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #9 on: November 05, 2015, 03:36:50 PM »
Look at this piece of code:
Code: [Select]
textures/sfx/beam_waterlight2
{
        qer_editorimage textures/sfx/beam_waterlight.tga
q3map_globaltexture
surfaceparm trans
        surfaceparm nomarks
        surfaceparm nonsolid // NONSOLID PARAMETER!!!!!
        surfaceparm nolightmap
q3map_surfacelight 50
        qer_trans 0.6
cull none
surfaceparm nomipmaps
        //nopicmip
{
map textures/sfx/beam_waterlight.tga
//tcMod scale 0.35 0.35
tcMod turb 0 0.015 0.5 0.07
tcMod Scroll .15 0
                blendFunc add
        }

}


Is part of shader "sfx.shader" from quake 3. It's used for my example of above (dracula map), for shinning dust throught windows.
If you read it, you see parameter "surfaceparm nonsolid" , it's same for beamlight shader, or for flames shader. Maybe is the best solution: read shader from "script" directory, and look for this parameter.
In other cases, like "pentagram" shader on the floor, this parameter is not exists. Mybe is only for light, flames, beams, shadows, etc
« Last Edit: November 05, 2015, 03:40:39 PM by jepalza »

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #10 on: November 05, 2015, 03:57:59 PM »
I understand your idea. It would be useful, if you load the nodes "by hand"
I think I need to try two solutions.
« Last Edit: November 05, 2015, 05:12:22 PM by nikolas »
Под лежачий камень мы всегда успеем...

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #11 on: November 05, 2015, 06:19:21 PM »
The problem is this:

When you create a Shader of nod all the SAME meshbuffer are attached to the SAME node.
This can be seen in screenshot 1.

I recompiled libIrrlicht.dlll, by changing the structure (highlighted in red).
The result is visible in the screenshot 2: each Shader node has an independent meshbuffer (included dimensional box).
struct Q3LevelLoadParameter
   {
      Q3LevelLoadParameter ()
         :defaultLightMapMaterial ( video::EMT_LIGHTMAP_M4 ),
         defaultModulate ( video::EMFN_MODULATE_4X ),
         defaultFilter ( video::EMF_BILINEAR_FILTER ),
         patchTesselation ( 8 ),
         verbose ( 0 ),
         startTime ( 0 ), endTime ( 0 ),
         mergeShaderBuffer ( 0 )(older value=1)
         cleanUnResolvedMeshes ( 1 ),
         loadAllShaders ( 0 ),
         loadSkyShader ( 0 ),
         alpharef ( 1 ),
         swapLump ( 0 ),
.....
To search for a node we can use this code:
Code: [Select]
Dim As wNode root=wGetRootSceneNode ( )
Dim As Any ptr position
Dim As wNode node= wGetNodeFirstChild ( root, position )
       Dim i As Integer
While wIsNodeLastChild ( root, position ) <>1
node=wGetNodeNextChild ( root,position )
If node<>0 Then
If wGetNodeType(node)=wSNT_Q3SHADER_SCENE_NODE Then
'Print *wGetNodeName(node)
Dim As String chortName=GetNoPathName(*wGetNodeName(node))
If chortName="timlamp" Then
Print "timlamp"
'wDebugDataVisible(node,value)
...............
collisions
...............
EndIf
EndIf
EndIf
        Wend

GetNoPathName- this my small  procedure:
Code: [Select]
Function GetNoPathName(ByVal tName As string) As String
Dim As Integer strLen=Len(tName)
Dim  i As Integer
Dim As Integer index
For i=1 To strLen
If Mid(tName,i,1)="/" Or Mid(tName,i,1)="\" Then
index=i
EndIf
Next
Dim As String newString=Right(tName,Len(tName)-index)
Return newString
End Function
So now we can work with each node as a separate object, including for possible collisions.

For collision (for example):

...
Dim As wSelector nodeSelector=wGetCollisionGroupFromBox(node )
wSetNodeTriangleSelector(node,nodeSelector)
wAddCollisionGroupToCombination (GLOBAL_SELECTOR, nodeSelector )

...


But, in screenshot 2 you can see the problem with the "liquid", as it was divided into several nodes.
« Last Edit: November 05, 2015, 08:25:34 PM by nikolas »
Под лежачий камень мы всегда успеем...

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #12 on: November 05, 2015, 06:50:15 PM »
PS: In BSP-map in map-20kdm2.pk3
1) old variant: Nodes count: 24, fps=60
2) new variant: Nodes count: 128, fps=30
Думаю, все ненужные для коллизий или другого шейдерные ноды придется объединять.
(I think all unnecessary collisions or other Shader nodes will be merged.)
Под лежачий камень мы всегда успеем...

Offline jepalza

  • Friends
  • Gentleman (Lady)
  • *
  • Posts: 42
  • Reputation 5
  • 3D Crazy
Re: Loading Shaders and objects from BSP (beta)
« Reply #13 on: November 05, 2015, 09:22:38 PM »
But, in screenshot 2 you can see the problem with the "liquid", as it was divided into several nodes.

Liquid is not a problem, is transparent, not necessary in collision map, but floor IS a problem. Several pieces of floor are shader, and if this shader is several nodes, we have a problem.  :(

Goes to probe your idea, in order to get another solution. Maybe, do can compile irrlitch code and help you.

2) new variant: Nodes count: 128, fps=30
:o and when the map is very big????

Example of BIG shader (several nodes?) in floor of "x3map06.bsp" (X3map_v1_final.pk3)
« Last Edit: November 05, 2015, 09:46:13 PM by jepalza »

Offline Nikolas - WS3D Developer

  • Programmer
  • Global Moderator
  • Viscount
  • *
  • Posts: 683
  • Reputation 45
Re: Loading Shaders and objects from BSP (beta)
« Reply #14 on: November 05, 2015, 10:14:29 PM »
Quote
Several pieces of floor are shader, and if this shader is several nodes, we have a problem.
Well, we will think over this problem.
For example,from Shader node to get the mesh (meshbuffer) using wGetNodeMesh, then apply the selector to a mesh of triangles

Quote
and when the map is very big?
I think all unnecessary collisions or other Shader nodes will be merged.

About Liquid: see screen.
« Last Edit: November 05, 2015, 10:31:54 PM by nikolas »
Под лежачий камень мы всегда успеем...