Skip to content
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

Hull heating shader effect #2550

Merged
merged 15 commits into from Jan 5, 2014
Merged

Hull heating shader effect #2550

merged 15 commits into from Jan 5, 2014

Conversation

fluffyfreak
Copy link
Contributor

Description:

Apply a simple heating shader effect based on the hull temperature and direction of travel.

It adds one texture which controls the heat gradient coloring. If you want to make it fade in later than squash the gradient further up and extand the black section towards the middle. Vice versa with the white end if you want it to ramp up earlier.

@shadmar you're a shader Ninja :) any advice on the shader itself?

Testing:

The best way to test is to launch with a powerful ship like the PumpkinSeed and make sure it hasn't got any atmospheric shielding. It's pretty clear when it's getting toasty!

Andy

@robn / @johnbartholomew - this is no longer WIP so is ready for review whenever there's opportunity. Check it out as it's quite a nice effect I think :) Wish I'd done it sooner!

@nozmajner
Copy link
Contributor

Neat!
Could it be possible to have arbitrary parts that start to glow when there's heat? I'm thinking mainly about my grated heat sinks really. :)

@fluffyfreak
Copy link
Contributor Author

@nozmajner Not with this one, this commit is just for heating due to being slammed through an atmosphere.
However that would be fairly easy to do, probably just with a texture which define a heat-map which matched up with the heat sinks on the ships regular texture :)

@fluffyfreak
Copy link
Contributor Author

Instead of having the parameters be a member of each instance of a ship I've just made them a class static. I have to change and set the value for each ship anyway so it makes no discernable difference.

@shadmar
Copy link
Contributor

shadmar commented Nov 14, 2013

Cool, I will look!

@fluffyfreak
Copy link
Contributor Author

Hmm, this still needs some work.
I figured out a few things this morning, like moving the heatGradient setup out of the Loader and into Ship where I'm already playing around with the materials. Now however I appear to be having trouble with the velocity direction calculation. Still working on it :) (since 6am!)

@shadmar
Copy link
Contributor

shadmar commented Nov 15, 2013

I think s_heatGradientParams.heatingNormal = vector3f(GetVelocity().Normalized() in ship.cpp needs some sort of transformation from worldspace to lightspace coordinates so the shader can take velocity vector as a lightsource direction. But I dont know how it should be done.

@fluffyfreak
Copy link
Contributor Author

I'm wondering if I'm actually passing through the direction correctly but I need to figure it out :)

…verse of the ships viewTransform.

Thus getting it into the models local space (I think that's right!).
@fluffyfreak
Copy link
Contributor Author

@shadmar tada! it seems to work for me now :)
I was transforming it incorrectly, now I'm building my own transformation matrix and multiplying it by that.

@shadmar
Copy link
Contributor

shadmar commented Nov 16, 2013

oO, I used 3 hours yesterday scratching my everything, even found my matrices book.

I will have a look :)

@shadmar
Copy link
Contributor

shadmar commented Nov 16, 2013

Nice! works very well, I changed one line to produce the effect earlier abit earlier so atmosphere shielded ships also get a nice effect.

vec4 heatColour = texture2D(heatGradient, vec2(pow(heatDot,0.6), 0.5)); //heat gradient blend

@shadmar
Copy link
Contributor

shadmar commented Nov 16, 2013

Some of this code might be useful and could be recycled for an shield directional impact also later on (both heat and hits)

@fluffyfreak
Copy link
Contributor Author

The shield already has a simple directional hit effect. Open a ship like the deneb (on the Shields branch) in the modelviewer and click the "Hit me!" button to see it in action :)

@fluffyfreak
Copy link
Contributor Author

RE: vec4 heatColour = texture2D(heatGradient, vec2(pow(heatDot,0.6), 0.5)); //heat gradient blend
@shadmar could the same effect be achieved just by editing the heat gradient texture map?
I already scaled the gradient effect to occur "earlier" and mean that the entire top half of the texture effect is pure white. The idea with the atmospheric shielding is that you wouldn't really see it so much but if someone wanted to edit the effect then they can just by changing the texture rather than having to know how to edit the shader.

@shadmar
Copy link
Contributor

shadmar commented Nov 17, 2013

could the same effect be achieved just by editing the heat gradient texture map?
Yeah that would be simpler :)

@jmf
Copy link
Contributor

jmf commented Nov 20, 2013

I just tested the newest version and I took that screenshot:
toasted
The yellow parts look a bit strange, also I think it could be a bit less red but more orange.
In kerbal space program the re-entry is very spectacular, look at this reference:
ksp

@fluffyfreak
Copy link
Contributor Author

Yep and it's pretty looking. Wanna code it? ;)

I kinda know how to do it, but we have the slight problem that you can enter atmosphere facing any orientation. That means the profile from which you extend the heat shock geometry from changes as your orientation does. I don't know how to resolve that.

This is just being a step in the right direction rather than the best-ever-re-entry-effect :)

@fluffyfreak
Copy link
Contributor Author

Actually if you can think of any way to do it then let me know and I'll try to implement it.

@johnbartholomew
Copy link
Contributor

If you want to do it with a mesh like that then it looks very closely related to shadow volumes, so descriptions you can find of how to construct the geometry for a shadow volume should be applicable to this. I've never implemented shadow volumes myself; I'm not sure how difficult it is to generate them robustly.

If we had a worthwhile particle system implementation then we might be able to use that instead, although you still have to decide where to emit the particles... perhaps just put them on the 'leading' end of an ellipsoid around the ship. It wouldn't look the same, but it might look just as good with the right particle sprite(s) and parameters.

@fluffyfreak
Copy link
Contributor Author

@johnbartholomew good point, lets move this to the dev forum though, even if find time to do something for it I don't want it to impact this PR.

@fluffyfreak
Copy link
Contributor Author

Updated to master

@robn robn merged commit ca4e246 into pioneerspacesim:master Jan 5, 2014
@robn
Copy link
Member

robn commented Jan 5, 2014

Good work on this one. Probably not perfect yet but a great start!

Produces some interesting effects with concave surfaces:

snap

@impaktor
Copy link
Member

impaktor commented Jan 5, 2014

Looks very nice. Would be suitable to show off on http://pioneerspacesim.net/

@fluffyfreak
Copy link
Contributor Author

Yeah, it's very much a start rather than an end :)

@fluffyfreak fluffyfreak deleted the toasty branch January 5, 2014 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants