Menu

LEX File Exchange
EA Support Files
SC4 Wikipedia
Network Addon Mod
Dependencies
Chat

Author Topic: Using Blender (open source modeling program) for content creation.  (Read 19268 times)

0 Members and 1 Guest are viewing this topic.

Offline tomvsotis

Re: Using Blender (open source modeling program) for content creation.
« Reply #20 on: February 01, 2017, 09:44:00 PM »
I've been using Blender and have found it pretty easy to learn once you get the hang of the interface. Getting things from Blender into gmax/BAT is a bit of a pain, though. There are some old tutorials on this site that are of use; so far the big thing I've found is that textures need to be rendered in in Blender's cycles render, not its internal Blender renderer

Offline mgb204

Re: Using Blender (open source modeling program) for content creation.
« Reply #21 on: February 01, 2017, 09:51:21 PM »
Just for clarification, the purpose of this is not simply so we can use Blender, that doesn't actually provide any tangible benefit if we export to SC4 BAT and render models there. Since SC4 BAT aka gMax does not produce renders of a very high standard. That's why most people went to 3DS Max, to achieve better quality renders, whilst retaining compatibility. So the real purpose of this thread is to find a way to render in Blender, retaining the better quality we've all come to expect.

Offline art128

  • ~\.Failed Haibane./~
  • Administrator
  • Forums Legend
  • *
  • Posts: 8240
  • Total likes: 768
  • Reputation: 18
  • 一人ぼっち
  • CL: Chocolarte
Re: Using Blender (open source modeling program) for content creation.
« Reply #22 on: February 02, 2017, 02:18:06 AM »
Eeeh, I believe Blender can render in a quality just as good as 3DSmax's mentalray.
I'll take a quiet life... A handshake of carbon monoxide.

Offline tomvsotis

Re: Using Blender (open source modeling program) for content creation.
« Reply #23 on: February 02, 2017, 08:25:43 AM »
Just for clarification, the purpose of this is not simply so we can use Blender, that doesn't actually provide any tangible benefit if we export to SC4 BAT and render models there. Since SC4 BAT aka gMax does not produce renders of a very high standard. That's why most people went to 3DS Max, to achieve better quality renders, whilst retaining compatibility. So the real purpose of this thread is to find a way to render in Blender, retaining the better quality we've all come to expect.
You can happily render w either of Blender's renderers and then bake those textures into a map you can import into gmax, if that's what you mean?

Offline mgb204

Re: Using Blender (open source modeling program) for content creation.
« Reply #24 on: February 02, 2017, 10:05:09 AM »
You can happily render w either of Blender's renderers and then bake those textures into a map you can import into gmax, if that's what you mean?

Right, but when you import them into gMax, how exactly are you getting them from there into the SC4Model file? If you have to render (Export) in gMax, then you are going to end up with a poorer render from it's engine (not to mention slower).

But if you are saying that gMax can take the renders from another application and somehow use them to build and SC4Model including it's LODs automatically, then in essence that's exactly what we're trying to achieve here. So if that's the case, could you tell us how you do it please? But, I must confess, that's not how gMax works as far as I understand it. Not that I'm an expert in this application by any means.

Offline vester

  • Administrator
  • Forums Legend
  • *
  • Posts: 4839
  • Total likes: 680
  • Reputation: 27
    • My bat cave.
  • CL: Tickets Please
Re: Using Blender (open source modeling program) for content creation.
« Reply #25 on: February 02, 2017, 10:15:08 AM »
That's why most people went to 3DS Max, to achieve better quality renders, whilst retaining compatibility.

Better renders but also faster (if you don't use the more advance materials that comes with 3dsmax)

Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #26 on: February 03, 2017, 05:37:33 PM »
I have some questions;

When you open Gmax or 3DSmax, do you have to set up the environment for SC4 production every time?

When you export the content what format is it in?

What is the next step?

Offline mgb204

Re: Using Blender (open source modeling program) for content creation.
« Reply #27 on: February 03, 2017, 07:44:25 PM »
The short answer is that it exports .bmp pairs, which means a texture and a paired alpha channel, which simply dictates the transparency of the main texture. When converted to FSH, those will be combined together.

And the way 3DSMax works is that the scripts placed in a certain location are loaded automatically upon startup of 3DS Max. But for each scene, you need to initialise it's lighting and camera rig, handled by extra buttons which the script adds to the UI.

SC4BAT is launched separately from gMax, but is basically a plugin/script too. So assuming we had such a script, when ran, it should ideally handle this somehow.



I'm going to make the assumption you weren't looking for the short answer... Warning, wall of text incoming.

First up, if you need a model you can render for testing purposes with gMax, see here. Similar models exist for 3DS Max too, I picked the canal because it's a reasonably simple model.

SC4BAT is a plugin for gMax, so it's that which contains the scripts and settings for exporting SC4 Models. gMax can render stuff, but natively that's fully 3D models.

Exporting is a two-step process, the first just creates something called LODs. A LOD is basically a box that covers the entire area of the model. SC4 Models need three of them, one for Z5, Z4 and Z3, hence they are named LOD3, LOD4 and LOD5 in your scene. The LODs are created, 4 for each zoom level, covering the rotations/viewpoints of the game (z1 and z2 LODs are a very simple box which is auto-generated, but does not exist in the scene). This is the part that 3DS Max users will still do using SC4BAT. Part of the BAT4MAX scripts help to create suitable LODs automatically, but they are imported as .3DS models into SC4BAT. This step also denotes the ID, picked based on a timestamp, which has been great at avoiding conflicts. All of this can be done by making three suitable LODs in Blender and Exporting them as a 3DS file into SC4BAT. Then you end up with an .SC4Model file, which is full of blank textures, but has the LODs, IDs and UV Mapping settings needed for the next step...

Now the part that we are trying to achieve in Blender, let's assume we've got the 20 camera angles/lighting rig all setup correctly. It just needs to render 20 .bmp files. Here's how BAT4MAX's scripts handle that... so it reads the TGI of the model (the IDs for the textures) from the filename of the SC4Model file. I'll walk you through an example:

So if you look through your plugins folder, note how many files will be named such that the TGI or ID is included in the filename. Sometimes they are removed to tidy things up, but in their unmodified state, a typical example would be:

          MGB_RetailBanner_Centra-7ab50e44_e4f71a8f_30000.SC4Model.

All models should have the same Type ID (the First one, Black) and use the same Instance IDs (Third one, Blue). Also note that 30000 is short for 00030000, where preceding 0's exist, it will cut them, but each ID is always 8-digits in length. Now, that means for every new model, only the Group ID (Middle, Red) will be altered, this basically makes the model unique.

<I have to mention it, but sometimes a model will actually use the Instance ID as the unique identifier, not the Group ID. This is pretty rare to see in practise, but I think relates to failing to install a patch for SC4BAT. Rather than muddy the waters, for now, let's assume we just have to deal with the Group ID as the identifier.>

So the Instance IDs all work very logically from here on out. 3XXXX is the ID range for each zoom/rotation, which breaks down as follows:

          0x0003TZRU

T = TimeofDay     Z = Zoom            R = Rotation         U = Unique ID       
0 - Day Render4 - Zoom 50 - South0-F*
8 - Night Render3 - Zoom 41 - West
2 - Zoom 32 - North
1 - Zoom 23 - East
0 - Zoom 1

* = The unique ID is used when a texture needs to be larger than 256x256px as part of the model. In such cases the texture is broken up into smaller segments, each will have it's own unique identifier from 1 to F (1-16). That's also why no model can be so large that it needs more than 16 textures at zoom 5. Because that's a hard limit of the ID system used for them.

Because these are all fixed, the scripts can work out from the ID of the SC4Model file, the exact IDs needed for each texture that's rendered. Although in practise, those are named simply 0000.bmp / 0000-a.bmp (Alpha or Transparency Channel). The scripts create twenty or more folders, which have the actual IDs. Two batch (.BAT) scripts are generated as part of the process to facilitate this. So the scripts just need to know which folder to place each set of .BMP pairs inside. To help you see what's going on here, I've attached a sample output from the 3DSMax scripts (note: this is only the night render, which overwrites the day render). The scripts can handle switching the T ID from 0-8 as necessary. So it only creates one set of folders for both day/night images.

All of this is based off the BAT4MAX process. But the tools used with the scripts are things we can re-use easily. One a render's images are all output, it converts them to FSH based on the folder names (IDs) and replaces the previously blank images with the newly-render model's ones.
« Last Edit: February 03, 2017, 07:58:58 PM by mgb204 »

Offline eggman121

  • NAM Team
  • Forums Parliamentarian
  • *
  • Posts: 1588
  • Total likes: 2812
  • Reputation: 27
  • CL:
    Mr. Smth
Re: Using Blender (open source modeling program) for content creation.
« Reply #28 on: February 03, 2017, 09:16:29 PM »
Thanks for the info Robin, your insight and investigation is absolutely awesome :thumbsup:

I know many hands make light work as a community we can find a solution to make Blender render models. The discussion here is just plain awesome. No doubt we will need to re-train ourselves to use blender but I do feel that we are closing in on a solution for making BATs with blender.

Quality BAT making keeps drawing users back to unleash their artistic and architectural desires and making the tools more readily available will be a boon to the content creators and user base alike. Keep it up everyone!

-eggman121 (Stephen)

Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #29 on: February 03, 2017, 11:12:19 PM »
You assumed correctly. Thank you. I will digest this and very likely have more questions.

Offline woodb3kmaster

  • SC4D Subscriptor
  • Forums Senator
  • *
  • Posts: 981
  • Total likes: 65
  • Reputation: 9
  • My name is Zack.
Re: Using Blender (open source modeling program) for content creation.
« Reply #30 on: February 07, 2017, 10:50:55 PM »
A thought just occurred to me: Assuming we can set up the camera/lighting rigs correctly in Blender (which should be a snap thanks to the data rivit linked to earlier), it should be possible to create the SC4Model file in gmax (as we already do with BAT4Max) and use something like an automatic version of GoFSH to convert the BMP textures to FSH. At that point, it mostly boils down to writing a Python script that splits the textures into 256x256 chunks, if I'm understanding the technical challenges correctly. This is seeming more and more feasible.

Feel brand new. Be inspired.
NYHAVEN - VIEWS FROM WITHIN
Nuclear City - 5/8

Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #31 on: February 08, 2017, 07:25:55 AM »
I have been studying the Blender python api and it seems like setting up the camera and lighting is going to be possible. I have not spent much time looking at the render processes yet, though it also looks promising. I have read a lot of articles and received some good info here, but I am still in the early stages. I have experience with python, but zero with 3D processing, so it will take time. Now I am going to take it one step at a time and just see where it takes me. Can't make any promises, but I am cautiously optimistic.

Offline bombardiere

Re: Using Blender (open source modeling program) for content creation.
« Reply #32 on: February 08, 2017, 09:44:23 AM »
This is interesting to read. Sadly I don't skills in this field so I will remain as an observer. However, I will look forward for what ever progress may yet to come.

I have tested Blender before, but personally I prefer 3DS MAX. May be it is because of my GMAX history but I like how it works. When I look at the Blender, I just get confused. However, It is a big scare that there will be a day when 3DS MAX is not suitable for batting. In every new version they brake something. I have about a year and half left of my 2014 Student licence. After that there may not be a suitable version available for batting. :( So if there can be a Blender script I am willing to learn the Blender.

Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #33 on: February 24, 2017, 07:47:22 AM »
  I have been able to spend some time working on scripts for Blender. So far, just some simple UI stuff, added a panel and created 3 buttons to move things around on the xyz axis. Not very exciting but it helps me get a feel for the syntax and format.

  Unfortunately I am getting bogged down trying to implement the actual procedures pointed out in the info posted here. This stems from my complete lack of knowledge related to using Blender and modelling in general. I find myself spending way to much time trying to learn enough about these things so I can script the procedures. Unfortunately I just don't have enough time, right now, to take this route so I would like to try breaking it into smaller pieces.

  I have extracted some quotes from current posts and pasted them below, along with some thoughts and questions, in the hope of moving this along one step at a time.

 mgb204 - posted
  "What we really need more than anything else is a plugin/script that can render an object created in Blender into the 20 views used by SC4 Models."....

  ...."The key barriers here are working out the following:
    Where to place the "cameras" so that the render appears correctly.
    The specific angle of that camera in relation to SC4s isometric view.
    There will no doubt be a need to set up the lighting too."....

From rivit's linked article:

Az123456    67.5 deg    Range  190m
ViewPoint   m,deg        D deg          E deg           Fx               Fy               Fx
El 456              45 deg       16.32495     59.63881          0.96269       0.75712       0.70711
El 3                 50 deg       14.90920     57.20219          0.95607       0.70648       0.76604
El 2                 55 deg       13.36473     54.16472          0.94960       0.65365       0.81915
El 1                 60 deg       11.70092     50.36073          0.94349       0.59986       0.86603

  It seems, to me, that these all concern the same piece of the puzzle.

  Is this correct?
  If yes:
  Can someone show me exactly where to input rivit's co-ordinates into Blender?
  (Please use screenshots, if possible)
« Last Edit: March 02, 2017, 05:18:23 PM by Handyman »

Offline tigerbuilder

Re: Using Blender (open source modeling program) for content creation.
« Reply #34 on: March 05, 2017, 04:17:44 PM »
I've been reading around on the net on my off time, I thought I'd share some observations I saw that seem interesting areas that could apply here.

The BAT/BAT4max must be a "maxscript" I'm assuming. There is information available about converting from maxscript to python. I thought that was interesting.

The cameras and scenes and all easily scripted. The problem is the transfer of that render to the LOD we need. I haven't seen much about that part.

I thought I would post to maybe stir this up again

Offline rivit

Re: Using Blender (open source modeling program) for content creation.
« Reply #35 on: March 05, 2017, 05:27:19 PM »

That's good news. In the main script (I think BuildingMill.ms) in Gmax, there is code that takes the model as in the scene and rotates it to the correct orientation to export for an S3D the model file in SC4. Otherwise the LODS (which are really just a hat rack to hang the textures off) can be exported as a 3DS.

The rendered projected images need to be broken up into maximal 256x256 pixel blocks and correctly numbered before export. That code too is in one of the scripts.

Now Gmax uses a proprietory dll to get from Render and LOD to numbered S3D and FSH, but we may have the knowledge and code to do this if we can get them out as S3d and say BMP( or PNG) with alpha.

Can Blender accept home grown plugins? i.e. could we code a plugin to do this for us?

Offline eggman121

  • NAM Team
  • Forums Parliamentarian
  • *
  • Posts: 1588
  • Total likes: 2812
  • Reputation: 27
  • CL:
    Mr. Smth
Re: Using Blender (open source modeling program) for content creation.
« Reply #36 on: March 05, 2017, 07:22:45 PM »
Thanks for all the reply's everyone.

Yes I think we are getting closer to a solution for this. Everyone who has contributed in this thread should be commended.

To keep SC4 modding alive I do believe we need too get programs that are at least free licensing but even better open source for the continuation of the making of quality BATs.

I wonder if a tool Like GoFSH could be adapted to take the renders of the model and apply the required FSHs in the BAT?  :-\

That would be a good test stage until we uncover a universal Blender solution.

-eggman121



Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #37 on: March 06, 2017, 07:08:18 AM »
Quote
The BAT/BAT4max must be a "maxscript" I'm assuming. There is information available about converting from maxscript to python. I thought that was interesting.

tigerbuilder, could you post links to the info you referred to?

Offline tigerbuilder

Re: Using Blender (open source modeling program) for content creation.
« Reply #38 on: March 06, 2017, 11:43:04 AM »
This is an example, handyman.

https://sourceforge.net/p/blur-dev/wiki/Py3dsMax/

There was more reading...I was googling things like "maxscript to python converter".

I have zero scripting experience..but I thought, what about the scripts that we already use...could they be used? That led me to looking around on that topic.

Oh by the way...this ST thread came up from 2008...boy it would be nice to have Simfox around.  His answer in this thread basically is where we are still.

http://community.simtropolis.com/forums/topic/22179-blender3d/

Here is something interesting about the rendering to a lod. I'm on a chase for this information.

http://blender.stackexchange.com/questions/46891/how-to-render-an-environment-to-a-cube-map-in-cycles

Cheers, tiger
« Last Edit: March 06, 2017, 04:48:37 PM by tigerbuilder »

Offline Handyman

  • Forums Citizen
  • *
  • Posts: 44
  • Total likes: 25
  • Reputation: 1
  • We are all astronauts living on the same spaceship
Re: Using Blender (open source modeling program) for content creation.
« Reply #39 on: March 06, 2017, 07:27:32 PM »
Thanks for the links tigerbuilder, lots to look at. :thumbsup: