Home Technical Talk

simple 3d painter with shader support

polycounter lvl 20
Offline / Send Message
CrazyButcher polycounter lvl 20
Due to the modo thread, I quickly added a texture painter to luxinia's resource viewer. You can paint into any texture loaded (very basic painting). The main benefit is that you can work with real-time shaders texture matrices in teh materials and so on. Saving to files is supported for TGA and JPG.

painter01.jpg

painter02.jpg

painting into the normalmap
painter03.jpg

more info here http://luxinia.de/forum/viewtopic.php?t=106

I wont have time to do nicer features within the next 2 months, so no time for real improvements. but anyway maybe it's useful already.

Replies

  • EarthQuake
    Ahhhh you crazy german bastard. This looks awesome. How well does it handle seams currently? And also can you handle object space normals too? Great job man
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    the painting is extremley rudimentary, the uv coord is taken from the 3d model, then the brush is blitted in 2d on top of the flat texture (no projective texturing). It doesnt wrap so when you paint at the edges of the texture, it wont influence the opposite edge.

    the shader system allows a some hardcoded options, but also use of custom vertex/pixel shaders, hence no real limits, so yes you can do object space normal maps, too. It's oldschool ascii stuff, like q3 shader stuff, but some day a graphical editor will come, too.

    edit
    some more info,
    the painting currently bleeds over texture seams, hence it makes most sense only for terrain stuff (that is what Eric needed afaik).
    in march I want to redo it a bit, and give more control: like masking uv chunks (you can select connected uv elements and only within them is being painted); projective painting; faster painting; more blendmodes (additive, modulate, not only decal); painting into the 2D image (zoom,pan... of the 2d view); until then this more or less serves as a quick sample/test
  • Eric Chadwick
    This is awesome CB, thanks a ton. Will d/l asap, let you know how it goes.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    I wrote a mini tutorial on how to get the shader done and also some 3dsmax export related stuff

    you will find it here http://luxinia.de/forum/viewtopic.php?p=463#463

    terrainshader03.jpg

    did a testrun with a setup you wanted. (no lightmap applied hence full white).

    To answer the question from the other thread: to get luxinias modelviewer loaded you must start with

    "luxinia.exe -v" (just make a shortcut or so). Best is you throw your stuff into a dummyproject directory (projects/test) and set it as project directory either before the viewer is started or within it

    "luxinia.exe -p projects/test -v" would do it before.

    by the way the sample does not use separated texcoords, but in the shader you could just add "texcoord X;" to a Texture Stage. It's coder's numbering so UVW channel 1 in max is texcoord 0 wink.gif
  • Eric Chadwick
    Awesome. Got it up and running with my model and textures, though the paint is not being applied for some reason. Been sidetracked with something else at the moment. Would it be possible to factor two tangentspace normalmaps into the shader? One for each color map, masked by the same mask as they are?
  • Eric Chadwick
    OK, got it to paint.

    For some reason Texture 3 (the multiplied lightmap) is being flipped on its V axis.
    2007.01.09_luxinia_flipped.jpg
    Fixed this by adding texscale (1,-1,1); to the MTL, then pressing Reset Materials. Nice feature.

    Is there a hotkey to toggle fullscreen? Mouse is stuck within the window (for good reason I see). Maybe a hotkey to toggle mouse focus (we use backspace)?

    The 'B' hotkey for paint mode is great, also being able to use right- and middle-mouse to translate the camera while in Paint mode.

    Definitely a useful tool. Thank you so much for coding it up. Will be donating to your paypal soon CB!
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    no clue why that TGA is flipped, have you tried painting into it, so that the texture preview in the paint shows the texture, would like to know if it is flipped there, too. or if somewhere a -1 texcoord that your -1 takes out again has bugged itself there (which I somewhat doubt), I hope it's just a TGA issue, that stores in a different order or so.

    about the mouse, it's a general problem with the library we use for event handling, friend will fix it some day

    oh yeah a toggle fullscreen button is missing, meanwhile you could do console (F1) and enter "window.fullscreen(true) window.update()" you can also change window resolution that way (once you enter window you will see a list of possible commands to the right). ugly to use console but I forgot about an option for it..

    glad it's useful in its simple state already smile.gif
  • Eric Chadwick
    Oops... your PayPal doesn't allow payments from USA.
    When I choose Land = USA, I get "Geben Sie einen Betrag größer als Null ein."

    I can't read German. smile.gif
  • Fordy
    Offline / Send Message
    Fordy polycounter lvl 18
    I think that means enter an amount larger than 0, or so good old Babel seems to think.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    the normalmapping could work if uvchannel1 is used as base for tangent space creation. I'll update the tutorial with more sample files later. could you please test the TGA issue I asked you on. (just check if its flipped in the paint preview) and sorry for the German, no clue how I can influence what kind of form that button opens, but seems like you figured out wink.gif thanks.
  • Eric Chadwick
    Thanks Fordy, that worked. smile.gif

    Bug 1. Yes, the TGA is flipped (vertically) in the preview window. It is a 24bit uncompressed TGA saved by XNView.



    Another couple bugs, minor things I can work around...

    Bug 2. I've assigned a Multi/Sub-Object material to the terrain. Two IDs, each with an empty diffuse Bitmap, one named terrain.mtl and the other named road.mtl.

    Terrain.mtl is the example you provided, but the 2nd ID's Road.mtl and 1tex.shd I created myself (probably wrong!):

    <font class="small">Code:</font><hr /><pre>
    luxinia_Material_v100

    Shader{
    SHD "1tex.shd";
    }
    Texture:0{
    TEX "road.tga";
    texscale (1,1,1);
    }



    luxinia_Shader_v300

    Technique:VID_ARB_V{
    Texture{
    TEX "Texture:0";
    }
    }

    Technique:VID_DEFAULT{
    Texture{
    TEX "Texture:0";
    }
    }
    </pre><hr />
    I looked for an example shader with a single colormap in it, so I edited \luxinia\projects\demos\shaders\litparticles.shd since it seemed the closest to what I needed.

    Anyhow the problem is, the 2 material IDs come in separated in the viewer. The materials look correct, but mat ID2 (road and coastline) is separated from mat ID1 (land).
    2007.01.09_luxinia_material_ids.jpg


    3rd bug is when I attempt to view a 2x2 TGA. I'm using this image in the road.mtl. As soon as I choose the 2x2 image from the bitmap dropdown list, Luxinia freezes. Divide by zero? laugh.gif
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    ah some quality bug hunting wink.gif

    1) ah good what I expected, some tga format issue, will debug it some day

    2) the shader is okay, however when you just assign a single texture you dont need a material at all, you can just straight assign the jpg whatever as diffuse map in max (just make sure the mapname matches the filename, normally this is done by default on export, but when you already gave the map a name containg a "." it is interpreted as filename)

    the reason they are moved worries me more, I will test it, likely is I screwed something up in the export with multi-materials, as I hardly ever used them. as workaround dont use multi-materials and detach yourself.

    3) edit: fixed it wink.gif

    ---

    a question about the normalmap shader you want (since I need to actually write the vertex/pixel shaders by hand now, I need more info).

    as I mentioned only texcoord 0 will have correct tangentspace. (make sure to check the option on export)

    assuming the following

    texcoord 0 = tiles (color & normal)
    texcoord 1 = mask, emissivemap

    do both tiletexture use the same texture matrix (same scalings) ?
  • Eric Chadwick
    Yeah, both use same scaling.

    If I'm using the material texscale params to tile each colormap (7.5,7.5,1), doesn't that mean I could adjust each of their normalmaps to use the same tilings? How do I tell Luxinia which Max uv channel to use? AFAIK, I'm only using the first one for everything.

    Is is possible your shader might prevent me from using different tiling amts for each normalmap? I'm thinking of other terrain pieces where the two bitmaps are not tiling the same amounts.
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 20
    in the Shader there is a note about using texcoords like

    <font class="small">Code:</font><hr /><pre>
    Texture{
    ..
    texcoord 1; # would use UV channel : 2 of max, default is 0 > 1 in max
    ..
    }
    </pre><hr />

    about the scaling thing, I will just use texture matrix for both tiles individually, but not for emissive and mask, it is msotly an optimization issue. You wont need to specify the scalings for the normalmaps, they will just use the same their colormap had.

    the multi-material thing is definetely broken (even worse for my test), comes from not testing these things too often, as most data is exported from cinema4d by friend.
    dont expect this to be fixed soon by me, as it probably is a larger bughunt.

    ---

    I updated the tutorial on the luxinia forum

    here is a sample shot (put a yellow dot into one tile to show off its different normalmap).
    The shader contains one tweakable for how strong the normals should be.

    terrainshader04.jpg

    the shader now assume uv channel:1 for the tiles
    and channel:2 for the mask/colormap

    ...

    out of curiosity why do you need multiple uv coords ? do you relax the "inner uvs" of a terrain chunk ?
  • Eric Chadwick
    If we had per-map texcoord adjustment, like your shader does, I could remove that extra UV. But we don't yet frown.gif so I'm stuck with this goofy workaround.

    Terrain is divided into tiles. The detail diffusemaps/normalmaps have to tile evenly across the surface, so neighboring tiles will be seamless. The multiply colormap and the mask are not tiled, they fill the whole UV space, but since they have discontinuous color on opposite sides, I have to pad the edges with 4 pixels all around, then shrink their UV set down .98,.98, to prohibit them from sampling their opposite sides. Make sense?

    Our coders are dealing with other, more pressing things these days. Might be a little while before I get more shader support, so I have to make do with what I have.
Sign In or Register to comment.