Simple LEvel Editor for Panda3D (WORKING!)

the lighting is dark and i am getting errors with the shaders
python main.py
Known pipe types:
CocoaGraphicsPipe
(all display modules loaded.)
:display(warning): FrameBufferProperties available less than requested.
:display:gsg:glgsg(error): An error occurred while compiling GLSL shader shaders/grass_lights_v.glsl:
WARNING: shaders/grass_lights_v.glsl:4: extension ‘GL_EXT_draw_instanced’ is not supported
ERROR: shaders/grass_lights_v.glsl:28: Use of undeclared identifier ‘gl_InstanceID’
ERROR: shaders/grass_lights_v.glsl:28: Use of undeclared identifier ‘gl_InstanceID’
ERROR: shaders/grass_lights_v.glsl:29: Use of undeclared identifier ‘offset’
ERROR: shaders/grass_lights_v.glsl:30: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:30: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:31: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:33: Use of undeclared identifier ‘gl_InstanceID’
ERROR: shaders/grass_lights_v.glsl:33: Use of undeclared identifier ‘gl_InstanceID’
ERROR: shaders/grass_lights_v.glsl:34: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:34: Use of undeclared identifier ‘animation’
ERROR: shaders/grass_lights_v.glsl:35: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:36: Use of undeclared identifier ‘v’
ERROR: shaders/grass_lights_v.glsl:38: Use of undeclared identifier ‘distToEdge’
ERROR: shaders/grass_lights_v.glsl:40: Use of undeclared identifier ‘v’
:display:gsg:glgsg(error): An error occurred while linking GLSL shader program!
ERROR: Input of fragment shader ‘uv’ not written by previous stage
ERROR: Input of fragment shader ‘normal’ not written by previous stage
ERROR: Input of fragment shader ‘vpos’ not written by previous stage
ERROR: Input of fragment shader ‘fog_factor’ not written by previous stage

It may be that your gpu or driver has no support for hardware instancing or the driver is a bit strict.
You may try changing gl_InstanceID to gl_InstanceIDEXT.

I was putting off comits till I had a version working good, but I don’t think I can get it to render at more then 20-30 fps on my target hardware anymore so I’ll just send what I have to the git tomorrow.

I’ve kicked out the directional light for the sun, it looks better with a distant point light. The color of the sky, fog, clouds and sun are read from a file and change over time, all you need to set now it’s the time of day. The water looks a bit better, terrain scale and texture tile are customizable and seting light colors is a bit more sane.
Particle effect still look bad or slow things down. Zoom on lit grass kills framerate.

This is really a nice tool!! Thanks wezu for sharing. :smiley: My main concern also is regarding configuration for larger heightmap sizes to 1024 - 4096? Will this be possible?

Thx.
You can set the size of the maps in the config file (cfg.prc). I think it’s mentioned in the manual.

But I don’t think it will improve the look of the map much, the mesh used for the terrain is always the same, a tessellation shader would be needed (and a gpu with ogl 4.0+).

BTW: there is something wrong with the AI in the demo. When I was running it on winxp it was almost ok, but now I moved to (x)ubuntu and there is some sort of memory leak. Can’t say if it’s my fault, the os or pandai, but when it happens the performance drops by 50% until I reboot.
I’ll make a new topic with the bug or try to catch rdb on irc.

BTW 2: if anyone has nice screenshots of the editor in action - do share, I’d like to get some screens of the Koparka into the Panda3D gallery.

This is great, I hope there will be more improvements. :smiley:

Some issues I just noticed:

  • the dynamic shadows are too light, is there any way to adjust and make it darker?
  • What is the terrain texture limit count, is it already max to 6?

Wow, I didn’t even know there’s AI feature built-in? How do you activate it? :smiley:

Thanks again.

I used Screen Space Soft Shadows, so the shadows are blurred as a pos-process step and then composed back to the scene, the thing is they are blurred all over, and some of the edges are wrong. I made the shadows grayish so it won’t show that much. To change that - grab the shader that composes the scene: shaders/compose_f.glsl
Line 18 looks like this:

    float shadow=blured_aux.g*0.4+0.6;

changing it to:

    float shadow=blured_aux.g*0.6+0.4;

will make the shadows darker, but also the wrong/blurred edges more apparent, float shadow=blured_aux.g; will make the shadows all black.

The texture limit is 6, that is to say 6 diffuse textures, +6 normal/gloss textures + shadow map, (or walkmap visualization) +heightmap +2 attribute map (what texture goes where), in total the terrain shader uses 16 textures, and opengl3.x guaranties only 16 textures (most ati/amd offer much more, but not nvidia). It’s not hard to add another canvas/buffer/attribute map and get 9 textures. Transparency is used when drawing the maps, and it was hard for me to make use of the alpha channel, but with some shader magic the alpha channel could also be used so you’d get 4 textures per attribute map, so with 3 attribute maps that could be 12 textures - but then you’d need hardware that can use 29 textures - ogl 4.0+. At this point in time - I’d say 6 should be enough, the Neverwinter Nights 2 editor offered 6 textures and that’s something I’ve been aiming at when I started years ago :wink:

The AI in the demo is just the PandAI pathfinding that ships with Panda3D, nothing new. You can paint a “walk map” - areas of the level that are unwalkable and the editor can generate a “navmesh” that the PandAI system can use. But as I said - at this point it randomly fails in a really bad way :cry:

Thanks for the details wezu. :smiley: Now I understand why you got this setup. I also noticed that the player and other objects are not receiving shadows and the bloom shader is showing weird with the shadows darkened… :open_mouth:

Moving on, can I suggest some improvements? and some issues that I have encountered…

  • There’s a weird fog transition between sky and terrain. Not sure if this is related to shaders or the pipeline.
  • Add a static skybox or could be mixed with the dynamic sky?
  • Maybe a terrain lightmap texture, but I guess the texture limit is already maxed out as you mentioned. :unamused:

cheers.

What is the license on the models shaders and textures?

Here occurred an error with lastest version:

[leonardo@localhost koparka-master]$ python main.py
Known pipe types:
glxGraphicsPipe
(all display modules loaded.)
:display(warning): FrameBufferProperties available less than requested.
2
Falha de segmentação (imagem do núcleo gravada) [Translated]: Segmentation fault (recorded image of the core)

Could you run gdb on the generated core file? Like, in the directory in which the “core” file is located, type:

gdb python core

And once it loads, type “bt” to get a traceback.

I didn’t put shadows on objects and the player because it didn’t look good, but I can try again, the shadow setup changed a bit from the last time I tried that.
Shadows and grass is another thing, I got really bad performance with the grass so I’ve turned all the goodies for the grass off (no normal maps, no gloss, no water reflections, no shadows, binary alpha).

The bloom (glare) shader is taking samples from the shadowed areas, that’s my mistake, will fix.

I know about the sky/terrain transition, but I couldn’t find a good solution for that. If I make the fog go higher the sun hides behind the fog at some 45 deg (14-15 o’clock). I’ll try to blend the fog and sky color in a more interesting way.

You can replace my skydome with anything you like, I’ve made a config variable called ‘koparka-default-skydome-mesh’ you can replace that with your own model… but now that I think of it, the editor will try to use my default sky shaders on a custom sky, so I think I need to add another config var for the shaders.

Lightmaps. Wouldn’t know how to make one :smiley:

The shaders are on the same license as the editor - but the fxaa shader is based on the geeks3d, and that is based on a nvidia paper. To be honest I can’t really say what’s the legal status of that. I use it in good faith.

The models are licensed the same as the editor - but some of the rock models are adapted from downloaded models (with a cc0 license), trees where made with treed (license says I’m free to use the models -commercial or free- as long as I’m not making another tree-generator or model pack with it). The rest is hand made by myself.

The ‘demo models’ (the bold warrior character) are from my own game and had a different license at first, but since I didn’t put that license file in the git, let them be beerware as well. The warrior model started as a MakeHuman model.

Most of the textures are from the Internet, FilterForge, MapZone2, some normal maps I made with the Gimp. I downloaded the textures as cc0, but this is the internet we are talking about, I had a FilterForge subscription and I think I can share these textures, the MapZone2 textures should be free to use. I would be cautious using the textures in a big, commercial project, but as far as I’m concerned it’s all Beerware license.

Segmentation fault ? I don’t think it’s my editors fault. Do as adb says, the man knows what he’s doing :wink:

I can help you with this one and there are lots of free terrain editors that produce lightmaps, one of them is L3DT Standard from Bundysoft.

bundysoft.com/L3DT/downloads/standard.php

Of course, a direct editor like koparka is really nice but a little help from outside would be even better, right? :smiley:

Can’t wait for more of your updates, you rock!

Hey wezu,

I have created a lightmap texture for your default1 level. Maybe you can do some experiments with it, it is really easy to produce in L3DT. :slight_smile:

Basically, if you’ll be supporting realtime Global Illumination like what Tobias created with Renderpipeline, I guess lightmaps won’t be needed unless for optimization purposes.


That looks interesting, but I think it would look strange if the terrain was lit using that but the objects placed on it would not be.

At the moment I’m having performance/compatibility problems (cursed pc - won’t run p3d on windows, drops 50% performance after 10 minutes on linux, refuses to run win 7, I don’t have a win 8 copy) and I don’t think I’ll be able to make any AO or GI, but a small patch with the things I wrote about in the previous post should hit the git today.

I guess it will look funny without lightmapping the props as well. I don’t mean to suggest to go to static pipeline or methods, but the editor looks really complete and easy to use :smiley: It just needs some fine tuning and some cool upgrades! :smiley:

I love the editor. It’s snappy and the controls are smooth. I just have a major issue with the heightmap editor: when you point the mouse it actually points at a location on the ground plane, and not on the terrain. This makes it hard to see where I’m actually going to be painting, which is especially awkward when using a drawing pad, since I don’t end up drawing where my pen actually is.

Of course, this is a tricky problem since it requires an intersection test with the heightmap. It could probably be done fairly efficiently by sampling the pixels of the heightmap along a line. (Hmm, maybe we should introduce a CollisionHeightfield at some point to make this kind of thing easier.)

Also, a minor quirk: It’d also be nice if there was a mouse-based way to adjust the brush radius for those using the mouse. Such as Ctrl+Scroll or maybe scrolling the mouse while hovering over the brush icon, or having a visual slider pop up.

Is there an easy way to change the default fog density?

Thx.
It is tricky to paint the height based on the height you are painting that just changed when you where painting it. I don’t know how to do it right (and fast) a height-map-shape would be nice.

A pop-up slider for the brush is a good idea and I’ll add that as soon as I’ll have a moment.

The fog… I find it anoying myself. I’ll add to the config panel something to overrie the fog value.
The fog color and volume is read from a png (just like the sky, clouds and sun color) and send to the shaders. I don’t have the code before me as I write this post but the fog volume is in a shader input called ‘fog’ (in the alpha channel).

Sorry for the serial posts…

I’ve added sliders for controlling the brush/object size/strength/rotation. Just click on the icon and a slider will pop up (click the icon again to hide it). The sliders misbehave a bit in the object paint mode, but I don’t think I can do anything about it without rewriting the whole thing.

The fog can be scale in the config menu.

I was also trying to get the painter to use the shape of the terrain not the flat plane, but so far it didn’t work.

The option to paint the height on the actual terrain shape is now available (well it was so for some time now). To use it you need to set a confing var named ‘koparka-gl-select’ to True (the default is False). It’s not much slower, but it also has it’s quirks. Use what you like.

I’ve also just made a commit that allows to store the levels in a SQLite database (not the heightmap and other maps, just the placement of objects and data about the sky, sea, terrain scale and used textures). This was for a personal project of mine, but if you want to use it, just replace

from jsonloader import SaveScene, LoadScene

with

from sqliteloader import SaveScene, LoadScene

near the top in main.py

I’ve packed all the models (or at least most of them) into egg.pz files and also made the editor accept egg.pz files.

When saving the extensions are also skipped, so that should also help when shipping if egg (or egg.pz) files became bam files.

I’ve also added a few tiles for building interiors (10 variations of floor, 46 walls, but some 50 more are waiting to be exported). For now these are only in a ‘rural’ theme, but a cave/mine and a dungeon/crypt theme will come this month.

To place these tiles you may want to set the grid size to 25.6 (a stupid number, but then the grid is the size of the tiles I’ve made) and the snap to 10.

The idea was to export the layout of the tiles without the terrain, so the outside of the tiles are black. With a bit of skill a walkmap can also be painted, but the height of the terrain may need some editing then just to see what you are painting.

A screen with the tiles:

s10.postimg.org/n08z1enw7/tiles_screen.png