Jump to content

Babylon.JS Sandbox now supporting DDS & Targa


davrous
 Share

Recommended Posts

Any thoughts on supporting procedural textures?  If noise could be implemented, then some sort of mapping back to Blender might be achieved.  I have looked at one of the shaders source listings the Blender python API can produce (STUCCI).  Was very large, kind of kitchen sink with like 30 or more functions that never get called.  Not sure if Blender uses them, as it is CPU based.  Maybe it is for that cycles render.

Link to comment
Share on other sites

Just as a follow up, I ran across this GPU shader doc for Blender http://www.blender.org/documentation/blender_python_api_2_70_release/gpu.html .  I decided to print out the glsl for 2 of these that I had made for the Gus, The gingerbreadman tutorial.  I put both the little vertex shader and fragment shader in the same file.

 

Here is the python code (should look familar):

        # Textures
        self.textures = []
        self.shaders  = []
        textures = [mtex for mtex in material.texture_slots if mtex and mtex.texture]
        for mtex in textures:
            if mtex.texture.type == 'IMAGE':
                if mtex.texture.image:
                    if (mtex.use_map_color_diffuse and (mtex.texture_coords != 'REFLECTION')):
                        # Diffuse
                        self.textures.append(Texture("diffuseTexture", mtex.diffuse_color_factor, mtex, filepath))
                    if mtex.use_map_ambient:
                        # Ambient
                        self.textures.append(Texture("ambientTexture", mtex.ambient_factor, mtex, filepath))
                    if mtex.use_map_alpha:
                        # Opacity
                        self.textures.append(Texture("opacityTexture", mtex.alpha_factor, mtex, filepath))
                    if mtex.use_map_color_diffuse and (mtex.texture_coords == 'REFLECTION'):
                        # Reflection
                        self.textures.append(Texture("reflectionTexture", mtex.diffuse_color_factor, mtex, filepath))
                    if mtex.use_map_emit:
                        # Emissive
                        self.textures.append(Texture("emissiveTexture", mtex.emit_factor, mtex, filepath))     
                    if mtex.use_map_normal:
                        # Bump
                        self.textures.append(Texture("bumpTexture", mtex.emit_factor, mtex, filepath))  
#            else:
#                 TowerOfBabel.log('WARNING texture type not currently supported:  ' + mtex.texture.type + ", ignored.")

            else: #type ==  'STUCCI' or 'NOISE'
                shader = gpu.export_shader(scene, material)
#                self.shaders.append(shader["fragment"])
                glsl_handler = open("/home/jeff/Desktop/" + mtex.texture.type + ".glsl", 'w')  
                glsl_handler.write(shader["vertex"])                      
                glsl_handler.write("\n//#############################################################################\n")                      
                glsl_handler.write(shader["fragment"])
                glsl_handler.close()

 

Here is the output.  I cannot do anything with it, but that does not mean some else can't.

 

NOISE.glsl.txt

STUCCI.glsl.txt

Link to comment
Share on other sites

  • 10 months later...

I tacked a question on to this topic / announcement a year ago.  Fast forward a year with Procedural shaders added as of BJS 2.0.

 

Am starting to think that procedural textures from Blender could at least be mapped.  Here is the dropdown types list:

post-8492-0-07740500-1431376581.png

 

I see there is wood, marble, & clouds in BJS.  How well they match up, I do not know. 

 

From the Blender vertex shader, there are these varying var to Fragment:

varying vec3 varposition;varying vec3 varnormal;

in our default vertex shader, there is:

// Outputvarying vec3 vPositionW;#ifdef NORMALvarying vec3 vNormalW;#endif

There are 8 inexplicable uniforms in the fragment shader of the NOISE from above.  Not sure, but if they are passed in, then there must be UI to set there value.

 

Does anyone think this is remotely possible?

Link to comment
Share on other sites

Well, I am finding UI for specific procedural textures.  Working with Wood.  There is:

noise_basis: Sine, Saw, & Tri

wood_type: Bands, Rings, Band Noise, & Ring Noise

 

Several noise settings (available only for types Band Noise & Ring Noise)

noise_type:Soft & Hard

noise_basis: dropdown list with many

noise_scale: number

noise_nabla: number

noise_turbulence: number

post-8492-0-14227900-1431972778.png

If strictly just mapping to BJS wood for now, the only settings are size, ampscale, & woodColor.  As there are no pictures of BJS wood samples that I know of here is a swag:

Type of wood is Bands,

noise_basis is used to set ampscale to 1 of 3 values.

Have no clue what size is

Not sure what color to use.

Link to comment
Share on other sites

As long as a .babylon handles procedural textures, it is already there.  I am not going to edit Fileloader.  I would try to implement in TOB first.  It is faster, and not reliant on FileLoader.  Would put as much as possible in pass 1, so would be cut and paste for the Blender mapping part.

Link to comment
Share on other sites

  • 1 month later...

Well, I have embarked on texture baking for Blender procedural textures.  After some fumbling, I am getting output all the way to a scene.  Have come to the conclusion that the script cannot just render the entire mesh as in the scene.  This takes into account lights & this precludes normal textures, since there is only one image.  Planning to switch to multiple bakes as required.

 

Anyway, working with what I have so far, I found that uv.smart_project gave the best results.  Still you can see "seams" though.post-8492-0-77348500-1435168212.png

 

I was able to minimize by upping my image size.  This caused me to do a whole bunch of formats.  I tried the TARGA format, but it would not load in a scene.  Here is the file:

 

targa.zip

Link to comment
Share on other sites

No actual error in the console.  Scene loads, but missing the mesh, though the shadow of the mesh, not baked, is visible.  All I have to do is switch to jpg or png, and everything is fine.  Targa file displays when I open it with the Linux Image Viewer program. 

 

This is not a big deal for me.  Targa format is the biggest, except for JPEG2000.  Just thought I would give the feedback asked for by the original post.

post-8492-0-30604900-1435189350.png

Link to comment
Share on other sites

Been awol a few days.  Here is the full zip as described.  Note how arc-rotate camera is initialized wrong.  Will look into why, along with changing camera to be separated from renderer, implemented in 2.1.  Would have an issue implementing this in the .babylon version of the exporter, I think.  Does Fileloader work with a rig field?

 

Also, need to upgrade Blender exporter for 2.0 shadows.  In the request site, I asked for a picture of the UI 3DMax used.

http://babylonjs.uservoice.com/forums/267546-general/suggestions/7742544-blender-addon-support-for-variance-shadows

 

 

targa_full_scene.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...