-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Branch/terrain #164
base: development
Are you sure you want to change the base?
Branch/terrain #164
Conversation
@rchadwic Would it make sense for us to move the terrain code into its own driver instead of putting it in the threejs driver? |
Well, I'm not sure that would make sense... Unless we create some method for the drivers to share access to the threejs lib? |
We could add three.js as a dependency of the terrain driver in the |
Humm. How would the terrain driver access the root scene node? Is there some shared state between the drivers where the ThreeJS objects could live, so multiple drivers could manipulate them? I agree that the 'load script' bit in there is a bit hacky. We could reform the terrain engine as a Require module pretty easily and make it a dependency of the ThreeJS model driver , but then you are loading a huge chunk of JS even for scenes that don't require it. There must be some way to load large bits of ThreeJS model driver functionality only when a node is created which |
Hmm ... that's a good point. I was thinking that the terrain driver would have the parent node id, but that's not good enough, if it can't get to the parent's So, this might be a moot point, but I was actually thinking of doing the dependencies the other way. The terrain driver could depend on And yes, @BrettASwift, I don't know if you had looked into how to bring modularity to the drivers and/or if you have ideas that we're not thinking about. If so, we'd love to hear them. |
… designed with a different THREE.js fog system, so does not currently read uniforms froms scene.fog in this version of THREE
@rchadwic I've rebased this on the current development. Is it alright with you that I push the rebased branch up or do you have local changes or anything that would make that a problem? I've also added a branch with your code as a driver here: https://github.com/virtual-world-framework/vwf/tree/branch/terrain-driver I need to do more work to it, but it does what it needs to do for now. |
return this.rootnode; | ||
} | ||
this.rootnode = new THREE.Object3D(); | ||
this.inherits = ['vwf/model/threejs/transformable.js']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rchadwic What is vwf/model/threejs/transformable.js? Is that a file of yours that is missing in this branch?
Ah. Yes - that's where I implement all the logic for get/set transform. Not necessary for this, unless you want to be able to move the root node of terrain. I'm not entirely sure how that would interact with the current Three.js driver. |
Pushing up the rebase. |
@rchadwic There are things in here that we really need to be able to configure from the application side, such as the atmosphere/fog. Do you think it would be possible to use the ThreeJS scene fog instead of the built-in atmo/fog? Or, do you think we could make the atmosphere settings visible in the VWF model (attached to the scene or terrain object) without spending too much time on it? If the latter, then I have just one concern and that is that the distant terrain doesn't blend to the atmo/fog color, so we are seeing a bright (almost white, especially with an HDR shader applied) horizon. I'd like to be able to control that better. @eric79 Any thoughts? |
@BrettASwift, my only thought is that I would love to integrate @rchadwic's atmospherics as well (sun, time of day lighting, etc). I imagine that it ties in with the fog, etc in some fashion, so we just want to take that into account. @rchadwic, is that already in this code or is that separate functionality? I would love to see it in here. (and then, we'll probably want to make the sun smaller in the Mars Game ... but that's a topic for later) 😄 |
So - we patched the THREE.js library to have a whole slew of new fog parameters. Our atmosphere system includes modifications to the core Three.js renderer where it sets the uniforms, new properties on the Three.fog object, changes to the Shaderlib fog fragments, and then a custom shader for the sky. Merging that could get pretty ugly. Let me do a quick diff on my three.js file and yours. |
Either way, it would be good to have some consistency there. If we could get all of the assets in our scene to be affected by your atmosphere stuff, then I would be happy with that too. |
It might be easier to revert the atmosphere part of the terrain shader to the original three.js quadratic fog. Would that be acceptable? |
I think so. @eric79 What do you think? At least for the short-term? |
@BrettASwift, I guess I would want to see what it would look like. I know that the current fog looks more earthy than mars-y, but other than that, it sure looks nice. I would say give it a shot (once you feel better), and if you like the result, we can go with that for now. @rchadwic, thanks! |
So, I'm in the process of aligning the fog in the frag shader for the terrain tiles with the default three.js fog system. You want this directly on this branch? |
That would be fine. Thanks, Rob! |
Hey, actually - am I missing something? Where are the fog settings for the scene object defined? |
Ok- done. The fragment shader for the terrain tiles now uses the default threejs fog rendering. Ah shoot - I checked this into branch/terrain-driver. Is that where we're working now? |
@rchadwic I think that will be fine. I believe that @BrettASwift was doing a spike to see if he could achieve your modular driver goodness using the existing driver infrastructure. I think he was coming close to something that he liked at the end of the day (before he took ill with a stomach virus). I believe that his plan was to issue a pull request back to this branch and ask for your opinion on it. If we all like it, then it will get merged into this branch anyway. 😄 Thanks for your help! |
@eric79 Great. That branch seems to work fine to me. I just branched off of it and commited a merged three.js lib that implements our atmospheric rendering for all objects. The trick is to set Scene.fog to |
@rchadwic, sweet! Thanks! |
@rchadwic When I add fog to the scene, the terrain shader fails to initialize and everything breaks. I've been trying to figure it out, but I haven't had any luck. Any ideas? |
It seems it breaks in Chrome, but works in Firefox. |
@rchadwic Is there a trick to get shadows to work on the terrain? I can't seem to get them to show up. Also, it looks like Firefox and Chrome place the terrain at different heights. |
@BrettASwift No, there is no current support in the terrain pixel shader for shadows. I'd love to see that. How are you adding the fog? I tested in chrome by hard coding the scene.fog, and this seemed to work as expected. I have no earthly idea why firefox and chrome would be different. let me take a look |
I was hard coding the fog as well. Chrome Version 34.0.1847.131 m |
@BrettASwift So, in the terrain-driver branch, using Chrome 34.0.1847.131 and Firefox 29 I have identical renders in the /adl/terrain scene. What versions are you running? |
@BrettASwift can you test something? On line 2095 of the THREEjs driver, can you add:
This works for me in the version listed above. |
@rchadwic I was on FF 28, but I updated and it did the same thing. I thought that maybe it was because I adjusted the heightscale, but putting that back to 1 didn't fix it. The fog, implemented as you wrote above, is still breaking in Chrome for me. |
@BrettASwift - Shoot. Not cool if I cannot recreate it. Possibly a shader incompatibility? Do you see anything useful in the console? |
@rchadwic Not really. I looked up the issue earlier and all of the similar problems had something to do with ANGLE and a precision mismatch (highp vs mediump), but when I was debugging, the fragment and vertex shaders seemed to match. Odd that it works fine in FF, but not in Chrome. |
@BrettASwift hummmm. Any additional tips on how I can reproduce? |
@rchadwic I have no clue. I'm just running directly off of the terrain driver branch. I seem to be running the same browser versions as you are. It fails on both ruby and node in Chrome. Unless you have changes that aren't pushed in, I don't know where the difference could be. I've asked @eric79 to see if he can reproduce the issue. Maybe that will provide some insight. |
@BrettASwift Here's a thought - I know I've seen at least one Linux box complain about specific lines in a shader that were fine on Windows. The issue specifically was |
@rchadwic I'm running Windows 7. |
Interesting ... it actually doesn't work for me in Chrome, either. I get an error message:
Could it be related to this? |
@eric79 Yeah - very much. That shader does require the standard derivatives. Can you check that your GPU supports that? |
It seems as if THREE.MeshPhongMaterial uses that as well and that is the only material type we use in VWF, so I'm assuming that isn't the issue. Plus, it worked before this change and it works in Firefox. I can't find anything explicitly stating that it is or isn't supported, but my machine has an nVidia Quadro 4000. |
@rchadwic, it looks like the mars-game team is favoring terrains with more authorial control so we can have more control over narrow flat parts for mazes, etc. So, with that said ... would it be crazy for me to try to pull out bits of the terrain branch into separate modules so we can still use them? I have my eyes on the texture blending, first..... |
@eric79 Hey sorry - somehow I missed this. So - you can use the mix map to control which textures go where, but only down to whatever area is covered by a single pixel. The mix map should fix exactly with the height map. If you need something more specific than that, I think you'd be better off with 3D modeling the exact environment you want. The terrain system is really built for fairly large environments. Can you give me an example of what you are looking for? Maybe I can poke and see if the terrain engine can be configured to get there. |
@rchadwic, no worries! I appreciate your help. Maybe if you take a look at the current Mars Game app, it will help illustrate. See how the textures are way too low res up close? I was hoping to use your texture blending in the mipmaps to allow for much higher resolution textures up close ... but while still allowing our artists to craft the terrains by hand. I believe that what I want is to tile the rgb textures over the whole terrain and blend them in the highest res mipmap. I guess one question is ... how do the mipmaps work in three.js. Will it sample from different mipmaps for one object if the object is horizontal to your line of sight (so part of it is very close and part of it is very far?) |
fd0aa1a
to
9f9d443
Compare
Integrate the terrain engine from the Sandbox fork.
Currently, several properties that should probably be editable are hard coded. See the included example under
public/ADL/terrain/
for parameter reference.bUrl,gUrl,rUrl,baseUrl
- url's to tileable images that splat into themixmap
channelsmixUrl
the mixmap to use to place the splat texture. Tiles exactly once over terraindiffuseUrl
a url of an image that is shows in the far distance. Tiles exactly once over terrainworldLength,worldWidth
- how many meters does the heightmap cover?url
- the heightmap. White is high, black is low.heightScale
white is 100 * heightScale meters high.cubic
- use bicubic instead of bilinear filteraddNoise
add some simplex noise to the heightmapExtents
the total range of the system. When using the heightmap algorithm, best to set to same asworldWidth