Jaguar X-Type Version 2.0

Ah, seems the alpha function for reflection can simply be added to your dyn_standard_bump_reflect_spec_f.cg

baseCol.rgb=FresnelMix(baseCol.rgb,envColor.rgb,(Kr>0?Kr:-Kr*baseCol.a),fresnel);

Then set reflection to -1 in the car.shd


Just done a silver car with the above, and everything else looks really bloody nice! It's fast and actually looks like metallic paint :D


Time to update my M3 to this spec I think...!


Thanks

Dave
 
Now shirley it would be best if that definition was in some other shader, rather than in each specific shader, as skyColor doesn't sound to me like something that changes much from material to material?!

Hmmmm

Dave

It is defined elsewhere, in atmosphere.cg, but the missing lightAmbient in the function was added recently. In my opinion the atmosphere.cg function needs work still but that can be addressed later. I wouldn't really hope for custom shaders to work consistently until the core stuff is more finalized and error free. The idea of a universal shader seems to be unlikely with the limit to 64 calculations per fragment shader that a lot of people have, so I think we're stuck with having to fix this sort of thing across a variety of files when errors become apparent. Once one shader is finalized, though, it's relatively simple to move updates to the other shaders. And then finding out which material shaders are common enough to be left in the core distribution. Probably specific stuff of the nature of waving flags could be kept to the car folders.



Maybe something of this nature could work, though -
Code:
#include "atmosphere.cg"
#include "lighting.cg"
#include "fresnel.cg"
#include "dyn_standard.cg"

// Vertex to pixel shader structure
struct v2p
{
float extinction : COLOR;
float2 tc0 : TEXCOORD0;
float3 Direction : TEXCOORD1;
float4 RayleighColor : TEXCOORD2;
float4 MieColor : TEXCOORD3;
float3 Position : TEXCOORD4; // For fragment shader
float3 normal : TEXCOORD5;
// Fresnel in pixel shader
float3 I : TEXCOORD6;
//float fresnel : TEXCOORD6;
float3 R : TEXCOORD7; // Reflection vector
};

void main(
// In
in v2p IN,

// Out
out float4 outColor : COLOR,
// constants [...]
)
{
intermediateColor = standard_v(IN);
skyColor = dyn_sky(IN);
// reflections
// fresnel
outColor = intermediateColor + reflections;
outColor = lerp(outColor,skyColor,bias);
}

Start with a standard_v that computes sky, atmosphere etc. of a basic matte material (ambient/emissive/texture color), then tack on specular and so forth.
Code:
 // dyn_standard.cg
// make all useful constants available here
// include atmosphere.cg, etc.

// Get sky gradient color
public float3 dyn_sky(v2p IN) {
return GetSkyColor(lightDirection,IN.Directi on,IN.RayleighColor,IN.MieColor,atmosRayleigh,atmo sMie,lightColor);
}

// get lit material color
public float4 standard_v(v2p IN) {
  float3 N=normalize(IN.normal);

// Get base texture color
float4 baseCol=tex2D(baseMap,IN.tc0);

// Lighting
float3 ambient,diffuse,specular;
LightingSun(Ke,Ka,Kd,Ks,shininess,lightDirection,l ightColor,lightAmbient,IN.Position,N,eyePosW,
ambient,diffuse,specular);
baseCol.rgb=baseCol*(ambient+Ke)+baseCol*diffuse*l ightColor+specular;
return baseCol;
}
Passing around the entire v2p instead of just the dozen useful components might be a bit wasteful but it simplifies writing this stuff.
 
Yeah, I guess the limitations of older cards do need to be considered, but also I guess making things as elegant as possible is also good for speed.

Good idea on making fairly generic basic shaders with additions.

Anything gets lit to some degree by ambient/diffuse, so they don't really need to be specified for every material/shader... so I guess atmos/sky etc all get done, then ambient/diffuse are considered, and then effects are stuck over per shader?!


Anyway, all this can go in it's own thread like what we had at RSC... :D





This car is really nice. One thing we could do with is flares being controlled or levelled relative to the environment lighting, so they appear less bright on bright tracks... but these look fantastic on an evening or night time track :biggrin:

Having looked at the dampers and Mz they are both good imo. Just the FF strength was too much as Cosmo pointed out for us G25 users... I made that about 40%

The only thing that stands out glaringly is some of the ways the engine/torque stuff has been done vs using the new diff system/losses, but that is an easy tidy up.
And the arb's seem very low. I'm using 35k front 20k rear and the car is much more authentic feeling. Solid and smooth on the airfield course, and on my road course it feels really really good. It has that comfy forgiving edge that means it's actually faster in lots of places than the stiffer sports cars which just skitter around and bite too often over the bumps!


My current fave Racer car... inspiration for my next car :biggrin:

Dave
 
But it's not spam :D

Had a go with these shaders and they copy over to other cars really intuitively. I had to alter the metallic scale because of my texture mapping, so perhaps that factor could be brought out into the car.shd part, but apart from that really nice!


Also after much testing I think most things with this car work really nicely. I made some new genericy damper curves and the car feels much more authentic now!


I'll send them over later for Tiberius to try and if he likes the changes he can release them in any future update plans he has for the car :smile:

Dave
 
  • Tiberius

About the shaders..

I did originally have the body more reflective, I just couldn't get the colour blending right (fresnel needs tweaking maybe?), the highlights on the paint just seemed to be getting too much influence from the sky colour. Strange thing, I'm not totally in love with the shader, but it's a balancing act to get everything (specular, body colour, diffuse) to play nice together and it's really hard to get it right. The best colour I've had with that shader so far is hot pink with gold flakes, but you can't put that sort of colour on a Jag, at least I can't bring myself to :tongue:

Really, I'm hitting problems at the moment with different colours picking up vastly different ambient/diffuse amounts, at the moment every colour really needs custom lighting settings (try and get a decent shader on the TWR paintjob on the XJS, it's just impossible where the green gets virtually no light but the white gets too much). That's alright for the body colours, they need tweaked shaders anyhow just to do the metallic. But I can't have different shaders for both interior and body colours, at least not without copy/pasting the code manually into the shader each time. So if you set an interior colour like the tan to look right, light colours like ivory will just pick up bloom and white out and look really bad, dark colours like charcoal are just way too dark and pick up virtually no light at all :frown:

Maybe having at least the diffuse amount multiplied by inverted baseCol.rgb would even things up a lot, but I'm not even sure that's the right thing to do. Same issue with body shaders, currently we need like diffuse=0.8 to get a dark grey working, on light colours (light silver, white), anything over about diffuse=0.5 is just too bright. So really it's a case of waiting around to see what gets changed/fixed in the next beta, then time to go around fixing things, that's the main reason I'm holding back on fixing the bugs and doing the colourpack, in a couple of weeks it's likely gonna be broken again..

Yep, we need a new thread to sort all this shader stuff out :smile:

About the ARBs, I was expecting people to say they were too stiff, LOL. I kept the old style diff code (wasn't sure if the new ones had been fixed), didn't know you could do power loss through the diff now? Gave it a quick drive tonight, first time I've looked at it since I released it. Yep, it does seem a tad stiff now, like Cosmo said. Dampers are probably overkill, it's still fun on the ring though :tongue:
 
So is there a way I can simplify/replace the shader? Should I change/remove the reference to the atmosphere.cg?

66/64 seems to be so close, yet so far. I was able to get your Cg Early Fall in Norway by removing the waterfall shader. What should I remove/replace?
 
The arb's are probably too soft.

Cosmo and I are tinkering with dampers and finding that they were at least a big blocking point wrt authentic handling. They alone transform the car for the better wrt realism, but still lend the car the true Jag driving qualities :biggrin:


As for the colours and brightnesses. I think the difficulty now is that nothing is really calibrated. Ruud used to default ambient to 0.2 and diffuse to 0.8 on all materials, so naturally, to get a white ball looking white on an overcast day (no diffuse sunlight set in tracks special.ini), we needed to pump the sky ambient by maybe 3-4x more than we wanted.
Now that defaults for ambient/diffuse are 1/1 unless otherwise specified, on most of the older tracks (and with TOD which isn't recalibrated for this yet), most cars are lit badly.


Try these for good sunny summer day values in the tracks special.ini

sun=-5000 10000 -5000
{
intensity=1500
enable=1
ambient=0.4 0.4 0.5 1
diffuse=0.8 0.8 0.8 1
specular=1 1 1 1
global=0 0 0 1
}


I've found those settings with your shader almost perfect really. The issue I then had was the reflections just didn't show up much (probably boosted on other tracks by the really intense sky diffuse/ambient settings of the past)...


Calibrated tracks/shaders is something I have complained about lots, and something I haven't yet got my self round to doing (I have bought the paints, the pads, have the SLR, the chrome balls and matte balls etc)... hopefully my new track will come with what I hope is a solid calibrated (I'll have to prove it to make it clear why I feel it's 'right') scene to then build car shaders to look 'right' on...


Either way, I think your shader is great. On my track with a few tweaks as discussed it works intuitively and nicely. I even added the metallic flake to my TVR colour cars (cascadey type look), and it worked fine! From a reading and making sense of it point of view it is implemented as realistically as we could, to copy real life, so I don't think it could be done better with what we have either :smile:



I'd like to see a version of it as a default in the global shaders folder, but just have some kind of maths noise rather than the texture perhaps, and have it applied in 3d space rather than 2d mapped, with a scale factor, so then you don't even have to have nice texture mapping coords of a constant scale to make it look right...


All good stuff. Also, lastly, it seems to run no slower than a shader without a specular control map, nor does the bump mapping cost much at all, if any! A good sign!



Only negative I have really that I spotted was that on the camera view of the front wheel, the LOD wheel model seems to change and you can see past the wheel front and the tyre side as it gets to say 30mph... looks like the wheel face polys are mis-aligned or something?!

Dave
 
  • Tiberius

So is there a way I can simplify/replace the shader? Should I change/remove the reference to the atmosphere.cg?

Hmm, it's a tough one :frown:

It's probably the body shader you're having trouble with I'd imagine (your Qlog will probably say something about dyn_standard_bump_reflect_spec_f.cg). Just a hunch but one way I can see to take a few commands out of there is to lose the atmosphere colour, that might work for you. You'll lose the fog effect on the car at a distance but it won't affect the quality of the shader.

Try the attachment (just unzip to the x-type/cg folder, let it overwrite the existing shader), let me know if it works. If it doesn't there's a backup of the original, just remove the 'BACKUP' from the front of the filename.

Losing the sky influence seems to be a good way to lose a dozen or so functions (and it seems to take a lot of math in the shader), not the perfect solution but it might work.
 

Attachments

  • x-type_body_shader.rar
    2.7 KB · Views: 215
  • Tiberius

Only negative I have really that I spotted was that on the camera view of the front wheel, the LOD wheel model seems to change and you can see past the wheel front and the tyre side as it gets to say 30mph... looks like the wheel face polys are mis-aligned or something?!

Dave

Yep, noticed it too :). Looks like somehow the wheel centres got moved out a bit, I'll fix it for the update.

Agreed about the dampers, I tried a couple of sets last night and it handles like a completely different car on each of them. It's that and stuff like suspension geometry really, just really difficult to find anything at all :(
 
No dice. The number of instructions went down from 72 to 69, but I still need to get to 64.


Anything else that would look okay when simplified?

0.86 gives me errors with the chrome.
 
  • Tiberius

Hmm, leave it with me and I'll see what I can do, I'm not sure what else I could remove. Really the fog is the only large thing I can take out without altering the shader, it's just a no win situation really I'm afraid.

Yep, the chrome will probably give errors on most of the shaders, as far as I know the lighting has changed since 086 so some parts will be missing.

Can you run the default Lambo? In that case you could find the 'vf_reflect_bump' section at the top of the X-Type's shader and change both the shaders for Racer's stock dyn_standard_reflect_bump ones (_v.cg and _f.cg), that should work.

I'm thinking you might hit the same problem with the interior shaders, although you might be okay, they don't have fresnel or reflections so that would save a few functions.
 
Finally got my GTX 285 that died back from the repair shop and tried your very well modelled Jag.

When entering the last turn on Carlswood my computer hangs up with the car stopping, sound going off and I have to hit Ctrl-Alt-Del to get out of racer.

I'll work on the problem to see what's wrong. Qlog had no entries!
 
  • Tiberius

Finally got my GTX 285 that died back from the repair shop and tried your very well modelled Jag.

When entering the last turn on Carlswood my computer hangs up with the car stopping, sound going off and I have to hit Ctrl-Alt-Del to get out of racer.

I'll work on the problem to see what's wrong. Qlog had no entries!

Hi Boomer. That's weird, haven't noticed any problems here. Is it happening every time or just the once? All I can think are dampers, they do seem to be a bit unstable if the car gets reset on track or anything else which drops it from above ground (not sure why, they're not that stiff).

If you can find out what's causing it I'll try and fix it.
 
Further investigation showed that it could very well be that the GTX 285 was replaced with one that has problems also! I tried a different car and after a couple of laps the same result occured. I do get a bit of image tearing even with the FPS set at 70 max.

I tried installing an updated nVidia driver, ver 6.14.9621 but that didn't fix the problem. I also tried a couple of other driver updates, one took 2.5 hours to download. I then tried running the Microsoft exe to fix any problems with the C++, no change.

I have the ai line turned on in racer.ini and the Jag prevents it from being seen, I commented out a couple of those cg shaders in the cg folder and the ai line appeared intermittantly as a black line, no color.

I did get the blue screen of death a couple of time and there was a reference to the NV4_disp.dll not prfoming correctly. I'll look at that next or...

I'll have to call the GTX maker and see if they have any fixes!
 
  • Tiberius

Poor Tiberius.
Four months modelling, four months sorting out why it's got issues.

LOL. Actually it was more like 2 years, if you don't count the 1 year 8 months between the two versions that it sat on my backup disk doing nothing ;-)

Boomer, I've definitely got the AI line here (I should know, I'm always accidentally hitting F3 instead of the number buttons) - the only graphical glitches I got at all were after the ghost car would appear. Honestly haven't had any issues here, but I've got the feeling that my 9800 might soon die on me too (occasional CTD on Far Cry 2 with driver error), but definitely haven't had that with the X, it was happening to me before I picked up Racer again at Christmas.

If it dies I'll just upgrade it, it's nearly out of guarantee anyway :-/
 
When entering the last turn on Carlswood my computer hangs up with the car stopping, sound going off and I have to hit Ctrl-Alt-Del to get out of racer.

I had that happen once on a non-cg track (Rattlesnake) with a non-cg car, so I think it's a more general bug in current versions. I've only seen it the once though and no Qlog errors so I'm not sure what was up.
 
Ran RegClean and that fixed the blue screen of death, nothing like a glitch in the registry to foul things up! Ran 20 laps at Carlswood without a hitch!

The ATI card I used while my GTX 285 was being replaced was the cause of the registry problem. I still have no ai line with this car and may still have a glitch in the registry. Anyway I'm back in operation.

Noticed one little problem with the Jag driver!
 

Attachments

  • my head is loose.jpg
    my head is loose.jpg
    37.6 KB · Views: 297

Latest News

How long have you been simracing

  • < 1 year

    Votes: 352 15.6%
  • < 2 years

    Votes: 245 10.9%
  • < 3 years

    Votes: 241 10.7%
  • < 4 years

    Votes: 177 7.9%
  • < 5 years

    Votes: 300 13.3%
  • < 10 years

    Votes: 258 11.4%
  • < 15 years

    Votes: 166 7.4%
  • < 20 years

    Votes: 125 5.5%
  • < 25 years

    Votes: 99 4.4%
  • Ok, I am a dinosaur

    Votes: 291 12.9%
Back
Top