thelivewire / unityHalf-life

open half-life bsp in Unity3d
29 stars 8 forks source link

PVS not work correctly #2

Open friuns2 opened 6 years ago

friuns2 commented 6 years ago

PVS not work correctly, if i enable it some objects missing image image

thelivewire commented 6 years ago

Are the missing objects brush entities? Those textures also look pixelated

friuns2 commented 6 years ago

i just disabled mipmap generation in unity so textures load faster.

friuns2 commented 6 years ago

what do you mean by brush entities? missing objects are bridge and some boxes, they are like seperate small objects on map

here is example map de_aztec.zip

thelivewire commented 6 years ago

https://developer.valvesoftware.com/wiki/Brush_entity https://developer.valvesoftware.com/wiki/Category:Brush_Entities

Brush entities are brushes tide to an entity for things like doors, transparent objects, buttons, water, ect. They are also used to optimize maps as they don`t cut up other faces during compile as they are treated as a mini bsp.

http://hlbsp.sourceforge.net/index.php?content=bspdef#models

A model is kind of a mini BSP tree. Its size is determinded by the bounding box spaned by the first to members of this struct. The major difference between a model and the BSP tree holding the scene is that the models use a local coordinate system for their vertexes and just state its origin in world coordinates. During rendering the coordinate system is translated to the origin of the model (glTranslate()) and moved back after the models BSP tree has been traversed. Furthermore their are 4 indexes into node arrays. The first one has proofed to index the root node of the mini BSP tree used for rendering. The other three indexes could probably be used for collision detection, meaning they point into the clipnodes, but I am not sure about this. The meaning of the next value is also somehow unclear to me. Finally their are direct indexes into the faces array, not taking the redirecting by the marksurfaces

It might be worth looking though Xash3D to see how they handle entities

friuns2 commented 6 years ago

thanks for info, btw do you happen to have https://www.codeproject.com/Articles/32751/Half-Life-Game-Level-Viewer compiled version? i could check if that project have same issue if not i could use its code to cross check and fix pvs in your code.

I cannot compile it myself i dont have visual studio 2003 with dx9 sdk, and microsoft changed a lot things to mcvs so it hard to migrate code.

friuns2 commented 6 years ago

i got printed out some info, seems vislist is -1 on those faces, any idea why is that? Well easy fix would be just render them always :)

image


private void ReadLeafs()
        {
            int leafCount = header.directory[10].length / 28;

            leafs = new Leaf[leafCount];
            br.BaseStream.Position = header.directory[10].offset;
            for (int i = 0; i < leafCount; i++)
                leafs[i] = new Leaf(br.ReadInt32(), /*vislist */ br.ReadInt32(), br.ReadBBoxshort(), br.ReadBBoxshort(),
                                     br.ReadUInt16(), br.ReadUInt16(), br.ReadBytes(4));
        }
thelivewire commented 6 years ago

No don't have a compiled version, might be worth looking at these projects as they are full engines.

Trinity rendering engine Xash3D https://github.com/everbuild/eresys/blob/master/src/Extra/HLBSPMap.cs

https://github.com/mikezila/uQuake1

If you read this he seems to think there is no need to use PVS, the code is based on an older version of this so might be worth going though it to see what hes changed.

""vis" data is not used in any way. I had originally meant to use the visible sets data in the .bsp to cull geometry to boost performance, but it proved to be a worthless effort"

http://hlbsp.sourceforge.net/index.php?content=bspdef#leaves

define CONTENTS_EMPTY -1

define CONTENTS_SOLID -2

define CONTENTS_WATER -3

define CONTENTS_SLIME -4

define CONTENTS_LAVA -5

define CONTENTS_SKY -6

define CONTENTS_ORIGIN -7

define CONTENTS_CLIP -8

define CONTENTS_CURRENT_0 -9

define CONTENTS_CURRENT_90 -10

define CONTENTS_CURRENT_180 -11

define CONTENTS_CURRENT_270 -12

define CONTENTS_CURRENT_UP -13

define CONTENTS_CURRENT_DOWN -14

define CONTENTS_TRANSLUCENT -15

Those brush based entities like doors water come from LUMP_MODELS and LUMP_ENTITIES (Use bspedit or nems bsp viewer) so for example here is water entity, its and index into the LUMP_MODELS array is number 221

{ "model" "*221" "renderamt" "175" "WaveHeight" ".2" "skin" "-3" "wait" "4" "speed" "100" "angles" "0 0 0" "rendermode" "2" "rendercolor" "0 0 0" "classname" "func_water" }

ghost commented 5 years ago

Perhaps the confussion was in "lighmap code from Paul Higinbotham" Hoping that meant something like below https://github.com/m-x-d/ericw-tools Included utilities:

qbsp - Used for turning a .map file into a playable .bsp file.

light - Used for lighting a level after the bsp stage. This util was previously known as TyrLite

vis - Creates the potentially visible set (PVS) for a bsp.

bspinfo - Print stats about the data contained in a bsp file.

bsputil - Simple tool for manipulation of bsp file data
thelivewire commented 5 years ago

Hi its the lightmap code in this project https://www.codeproject.com/KB/directx/HLViewer/HLViewer_2.zip

You might a word with this friuns2, they started working on a project using this code https://github.com/friuns2