Blender - Source Engine (Garry's Mod) - compiled model direct lighting is flickery and wrong
3 replies, posted
Hi, I've never made a model for the source engine before, so I'm probably making a common noob mistake. Nonetheless, I haven't been able to figure out the cause of my issue, even after many different searches on both google and on these forums.
Below is a video showing the entire process of the model being set up for compilation, the model being compiled, and the model being loaded in game.
[video]https://youtu.be/6Ebd0W8Gny8[/video]
In case the video is removed in the future, here are the details:
[HR][/HR]
I used Blender version 2.78a.
I used the Blender Source Tools plugin, version 2.9.1.
The model is 128x128x128 in size, has flat shading, and the normals were automatically calculated by Blender.
The UV mapping was setup so each face would show the entire texture.
I named the mesh "cube_thing," the physics mesh "cube_thing_phys," and the single bone "cube_thing_idle."
[B]In Blender Source Tools plugin settings:[/B]
I set the export format to SMD.
The engine path was set to the bin folder for Garry's Mod.
The target engine was Source.
The entire scene was exported to a folder named "export" on my desktop.
The folder then contains "cube_thing.smd," "cube_thing_phys.smd," and a folder named anims which contains "cube_thing_idle.smd."
I created this QC file for Crowbar to use:
[code]
$modelname "test\cube_thing.mdl"
$body body "cube_thing.smd"
$cdmaterials "test\cube_thing\"
$surfaceprop "metal"
$staticprop
$sequence idle "anims\cube_thing_idle.smd" {
loop
fps 1
}
$collisionmodel "cube_thing_phys.smd" {
$concave
}
[/code]
[B]In Crowbar:[/B]
I created a setup where the location of the gameinfo.txt file was the one for Half Life 2: Episode 2.
I then used the bin folder for Half Life 2 for the locations of studiomdl.exe, hlmv.exe, and vpk.exe.
In the Crowbar GUI, the only (important) checkboxes that were selected were "No P4" and "Verbose."
The output of the compilation is as follows:
[code]
Compiling with Crowbar 0.42.0.0: "C:\Users\Dylan Raub\Desktop\export\cube_thing.qc" ...
Compiling ".\cube_thing.qc" ...
qdir: "c:\users\dylan raub\desktop\export\"
gamedir: "E:\Steam\steamapps\common\Half-Life 2\ep2\"
g_path: "cube_thing.qc"
Building binary model files...
Working on "cube_thing.qc"
SMD MODEL cube_thing.smd
SMD MODEL anims\cube_thing_idle.smd
SMD MODEL cube_thing_phys.smd
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
WARNING: Error with convex elements of cube_thing_phys.smd, building single convex!!!!
Model has 1 convex sub-parts
Collision model completed.
---------------------
writing E:\Steam\steamapps\common\Half-Life 2\ep2\models/test\cube_thing.mdl:
bones 964 bytes (1)
animation x y ips angle
@idle 0.00 0.00 : 1.#J ( 90.00) 0.0
animations 112 bytes (1 anims) (1 frames) [0:01]
sequences 220 bytes (1 seq)
ik/pose 164 bytes
eyeballs 0 bytes (0 eyeballs)
flexes 0 bytes (0 flexes)
textures 72 bytes
keyvalues 0 bytes
bone transforms 0 bytes
bone flex driver 0 bytes
Collision model volume 2097152.50 in^3
collision 0 bytes
total 1740
---------------------
writing E:\Steam\steamapps\common\Half-Life 2\ep2\models/test\cube_thing.vvd:
vertices 1152 bytes (24 vertices)
tangents 384 bytes (24 vertices)
total 1600 bytes
---------------------
Generating optimized mesh "E:\Steam\steamapps\common\Half-Life 2\ep2\models/test\cube_thing.sw.vtx":
body parts: 8 bytes
models: 20 bytes
model LODs: 12 bytes
meshes: 9 bytes
strip groups: 25 bytes
strips: 27 bytes
verts: 216 bytes
indices: 72 bytes
bone changes: 16 bytes
everything: 429 bytes
---------------------
Generating optimized mesh "E:\Steam\steamapps\common\Half-Life 2\ep2\models/test\cube_thing.dx80.vtx":
body parts: 8 bytes
models: 20 bytes
model LODs: 12 bytes
meshes: 9 bytes
strip groups: 25 bytes
strips: 27 bytes
verts: 216 bytes
indices: 72 bytes
bone changes: 16 bytes
everything: 429 bytes
---------------------
Generating optimized mesh "E:\Steam\steamapps\common\Half-Life 2\ep2\models/test\cube_thing.dx90.vtx":
body parts: 8 bytes
models: 20 bytes
model LODs: 12 bytes
meshes: 9 bytes
strip groups: 25 bytes
strips: 27 bytes
verts: 216 bytes
indices: 72 bytes
bone changes: 16 bytes
everything: 429 bytes
Completed "cube_thing.qc"
... Compiling ".\cube_thing.qc" finished. Check above for any errors.
... Compiling with Crowbar 0.42.0.0: "C:\Users\Dylan Raub\Desktop\export\cube_thing.qc" finished.
[/code]
[B]In Garry's Mod:[/B]
I moved the compiled model files into "garrysmod/models/test/".
I then ran Garry's Mod and spawned the model.
The model didn't have an actual material for it, so I used the Material tool ingame to assign the plastic material used for Hunter's PHX building models.
The model did not light up correctly based on where it was located in the world, like how most props would.
Furthermore, the lighting would flicker and change based on the angle I viewed the model from.
[HR][/HR]
Any advice would be wonderful!
[editline]22nd May 2017[/editline]
Metamist informed me that the "WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!" message doesn't happen to him. I redid the model and I still had the same warning message and the same issue, even after removing the "$staticmodel" tag.
This tells me it's probably something I'm doing wrong in Blender.
[editline]22nd May 2017[/editline]
I've attempted the same solution with a sphere and I didn't get the warning message, but the bug still happens ingame. Urgh...
[editline]22nd May 2017[/editline]
I noticed that when multiple props of that model are spawned, they all have the same lighting.
Some stuff I've noticed:
You don't need a bone for that prop just set the idle to your reference model.
The collision model needs to be smoothed just hit smooth on the left panel in object mode while the collision mesh is selected. This will get rid of the 2d error.
Maybe the lighting problems is due to it not having a default texture. Set up a simple material and add $cdmaterial "path" to your .qc file. You have to add a material in blender. For testing only you don't need to set up an actual texture inside blender just make sure the material has the [B]exact[/B] same name as the vtf you'll create. Also remember that the vmf needs to be "VertexLitGeneric"
I don't know about the lighting issue source exactly but the closest I can get is there is something wrong with the origin on your model. Try applying the location scale and rotation before compiling.
As for the 2D geometry, you need a physics mesh separate from the visual one, where all the faces are in the same smithing group, and all separate shapes formed by those faces are concave. To do this, duplicate your object, and set it to smooth shading, export this new object and use it as the physics mesh in the QC file.a
[QUOTE=KingPommes;52261872]Maybe the lighting problems is due to it not having a default texture. Set up a simple material and add $cdmaterial "path" to your .qc file. You have to add a material in blender. For testing only you don't need to set up an actual texture inside blender just make sure the material has the [B]exact[/B] same name as the vtf you'll create. Also remember that the vmf needs to be "VertexLitGeneric"[/QUOTE]
That was the problem and the correct solution! Thank you.
Sorry, you need to Log In to post a reply to this thread.