can i tile a material across a terrain elevation?>
if I set repeat to true, and scale uv to 2,2, it only renders it smaller in corner and the rest is black- doesnt repeat as a normal mesh would. Am i missing something?
thanks for any tips!
andy
can i tile a material across a terrain elevation?>Software: Away3D 4.x |
||
alpoman, Jr. Member
Posted: 02 April 2016 03:22 AM Total Posts: 40 can i tile a material across a terrain elevation?> thanks for any tips! andy |
||
Fabrice Closier, Administrator
Posted: 02 April 2016 10:12 AM Total Posts: 1265 [ # 1 ] material.repeat = true; the original mapping must be 0-1 on both u and v axises.
|
||
alpoman, Jr. Member
Posted: 02 April 2016 02:27 PM Total Posts: 40 [ # 2 ] I think I understand what you mean, I just dont know the correct syntax maybe. var tMaterial = new TextureMaterial(Cast.bitmapTexture(Sand2),true,true,true); ReferenceError: Error #1069: Property subgeometry not found on away3d.core.base.Geometry and there is no default value. please a hint? andy
|
||
alpoman, Jr. Member
Posted: 02 April 2016 02:44 PM Total Posts: 40 [ # 3 ] Fabrice, btw, using your program I noticed that a terrain generated using your built in terrain creator, the uvs work perfectly as I’m able to tile it 2,2 correctly. So, I suppose your software is automaticlly selecting it’s subgeometry to tile it correctly to fill the mesh. I wish everything was as e wasy as PREFAB:) I am proceduraly generating my terrain at runtime, so unfortunately I can’t use PREFAB for the terrain, but it is great for my other models and for learning in general - thanks Fabrice, andy
|
||
Fabrice Closier, Administrator
Posted: 02 April 2016 05:13 PM Total Posts: 1265 [ # 4 ] your error is that you try to access a subgeometry by literally calling it subgeometry. the mesh geometry may have more than one subgeometries, therefor they are stored into a subGeometries vector. I wish everything was as easy as PREFAB:)
|
||
alpoman, Jr. Member
Posted: 02 April 2016 05:51 PM Total Posts: 40 [ # 5 ] You are correct, and thank you sooo much, you are brilliant Fabrice!
|
||
Fabrice Closier, Administrator
Posted: 02 April 2016 06:03 PM Total Posts: 1265 [ # 6 ] looking good Can you develop on the way you prebake? you draw based on a “voxel” logic?
|
||
alpoman, Jr. Member
Posted: 02 April 2016 08:36 PM Total Posts: 40 [ # 7 ] Thanks!! ok, here goes, first I made a 3d array editor with differnt blocks, items, and stuff in the game. For the terrain creation, I just use the block data. The editor allows me to make custom areas on a 15x15x11 grid ( hight is 10 blocks high off of base which is 0) I have little subroutines in the editor that can ‘spawn’ random terrain based on placed blocks on the floor to speed up creation of levels. when I save my level, a text file of the data array is written to my server somewhere remote. Then in my away game file, I read that text file from server, parse the 3d array numbers for my blocks and objects. (editor screenshot attached below) then I make this terrain wiith that bitmapdata: Object(root)[“terrain”+(drawlev)] = new Elevation(Object(root)[“terrainMaterial”+(drawlev)], Cast.bitmapData(Object(root)[“myBitmap”+(drawlev)]),1024,500,1024,200,200,255,0,false); note: the graidents of the elevation map I drew also doubles as the base color(which I colorize per level later) this gives a faux lighting on the terrain from black to white, neat effect for no lights, but not totally accurate for realism. and thats the basic terrain mesh, now the prebake. this is the juicy part, which only a few people may be able to follow- _width = stage.stageWidth; cameraController.tiltAngle=90 var _bitmapData:BitmapData=new BitmapData(_width, _height, false, 0xFFFFFF); stage3DProxy.clear(); ///now crop that and make it a 512x512 sqaure function crop( bitmapData:BitmapData, rectangle:Rectangle ):BitmapData { ///now apply this texture back to terrain and remove old data to free mem
Fabrice, if you could streamline a class to do this automatically, people would use it like crazy!!! I’m not much of a programmer, I just fiddle a lot till it works usually, so my code is sloppppy;) the trick is to center the ortho camera over mesh at that height 1088, dont know why that works for a 1024x1024 terrian, but… and then snapshot that with your lights. I did have to play with offsetting the camera a bit to account for my terrain being centered on a 1024x768 screen which isnt square. thats why i use those goofy crop/ rescale functions to spit out the usable 512x512 bitmapdat. Ley me know any thoughts, ideas, or any other questions of details on this, andy
|
||
alpoman, Jr. Member
Posted: 02 April 2016 08:49 PM Total Posts: 40 [ # 8 ] and the final scene. to get the bridges and other non-terrain elements to cast shadows, I change their material to transparent before prebake (keeping shadows) and then put their materials back on after. there has been a lot of talk here about how to render a transparent mesh while still casting/recieving shadows - here it is. omaterial2 = new ColorMaterial(0xFFFFFF,.99); the ket to this working, is the .99 transparency setting, anoy other setting doesnt give complete invisible or perfect shadows.
|
||
Fabrice Closier, Administrator
Posted: 02 April 2016 09:58 PM Total Posts: 1265 [ # 9 ] thats one hell of a job! The reason it works the way you did, is because the map is 0-1 mapped The moment you start to add custom mapping, like after an unwrap, this approach would never work. on your code, you could save processes the map by using a width/height in Prefab 3.0, I’m doing work in this direction, in both gpu and cpu mode. so I dunno if lots of people would be interested, but I know I am
|
||
alpoman, Jr. Member
Posted: 02 April 2016 11:06 PM Total Posts: 40 [ # 10 ] Thanks Fabrice, this is great advice and will help me - I’ll keep working using your optimizations and post back with results. I am interested in your work - and how you are always thinking of making things better, better looking and better working on all machines!!! because if it looks good and runs good on a slow machine, it will be awesome on a fast one, with more everything possible. But I read on your posts that if it can be baked, bake it - makes sense because dynamic lighting is just not fun on mobile, lol - unless your like 3 fps. here is a shot with the terran texture not-faux shaded in advance. it still does the melting side thing that terrains do which you mentioned works for this scene, but with one light, it looks flat without the multi-level faux shading material. So, I’ll play with this, and try your suggestions. Thanks again, Andy
|
||
alpoman, Jr. Member
Posted: 04 April 2016 05:01 PM Total Posts: 40 [ # 11 ] Ok, I went back to my faux shading+ baked lights- it gives the best depth and cartoony look I’m after - and big thanks to Fabrice for the optimization tips (scaling at the exact size for pre-bake, and other multiply jpg trick to reduce alphas) this works great on mobile. Frame rate so high I dont even need to monitor framerate if you know what I mean;) andy
|