Jump to content
  • Advertisement
Sign in to follow this  
george7378

Lighting showoffs!

This topic is 2048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, I just thought I'd show off the lighting abilities in my game now that I've transferred all drawing over to shaders. The lighting can handle Normal mapping, shadow mapping, ambient, emissive, diffuse and specular lighting. I've just got one screenshot which shows those things in action:

 

LEM3D19_zpsd6b30f3a.jpg

LEM3D17_zpsa64b3aa3.jpg

 

Thanks for looking!

Share this post


Link to post
Share on other sites
Advertisement

Not bed as lighting goes. You could use some bloom!! The textures need some work but otherwise this is a very good start!

Share this post


Link to post
Share on other sites

Hey - thanks! I know that the terrain textures need some work - and yes, I'd love to add some bloom! I guess that's doable with HLSL too?

Share this post


Link to post
Share on other sites

Hi. HLSL and cgFX are fully capable of producing a bloom post-processing effect; You only have to check if the hardware you're using is fast enough for this, and if it supports framebuffers.

 

There's an old fixed function trick you can use to improve the detail on the ground (to alleviate that texture stretching visual): using a "detail texture".

 

It's simply a seamless "noise" texture that you apply to the entire terrain with an index above that lunar surface texture you have there now.

This detail texture needs to wrap so it can tile across the entire terrain and not be stretched. It also needs to have a multiply blend mode so it multiplies that lunar surface texture you have right now. Give it a test, you'll see it looks more convincing.

Edited by Kryzon

Share this post


Link to post
Share on other sites

Light bloom would be cool, but it also seems to be a lot of addition for what might not be necessary right now - I'll add it to my list of things to do when I fix some more prominent issues first! I really like the idea of the detail texture - I guess I could do it in HLSL rather than fixed function by sampling a second texture and multiplying the colour by that sampled value? I'll give it a try! I did try to use different textures with different tiling, etc... but it never looked right. Maybe this time it will!

Share this post


Link to post
Share on other sites

OK, so I tried multiplying the base texture by a more detailed sand-like texture, and it looks better close up, but in the distance, I can see lots of evidence of tiling - I made sure to create a seamless image and I wrap it in the texture sampler. Here's what I'm talking about:

 

[attachment=15535:detiltex1.jpg]

 

...and here's what I'm doing in the shader:

 

     float4 baseColour = tex2D(TextureSampler, PSIn.TexCoords);

     float4 detailColour = tex2D(DetailTextureSampler, PSIn.TexCoords*10.5);

     baseColour *= detailColour * 2;    

     Output.Colour = baseColour*(diffuseLightingFactor + xAmbient);

 

I suppose there's something I'm missing!

Share this post


Link to post
Share on other sites

OK, I applied a slightly better texture (an old sand texture converted to greyscale) and I'm beginning to see large improvements:

 

[attachment=15536:LEM 3D 21.jpg]

 

This one doesn't look too bad from a distance either! I'm thinking that it would be a good idea to only apply the detail texture to pixels which are a certain distance from the camera - does anyone know how to find the depth of a pixel in HLSL? I know how to do it by rendering to a shadow map and then sampling from that, but is there a simple way without needing to do this?

 

Thanks!

Share this post


Link to post
Share on other sites

This technique is really making an improvement! It already looks a lot more realistic, after just an hour of messing around!

 

[attachment=15537:LEM 3D 22.jpg]

 

I think this will be great when I properly smooth it out! Thanks!

Share this post


Link to post
Share on other sites

Those last two screenshots look amazing man, great job.

 

 

I'm thinking that it would be a good idea to only apply the detail texture to pixels which are a certain distance from the camera - does anyone know how to find the depth of a pixel in HLSL?

Is there a way you can sample the mipmaps? because they function just like that: different textures sampled based different levels of distance.

If in your app you manually create the mipmaps (instead of letting the API do that, say, with AutoGenMipmaps), then you can manually set different levels of transparency for each mipmap level texture, leaving the last level entirely transparent.

This way the more distant the ground point is, the smoother it'll be.

 

EDIT: This is what Super Mario Sunshine used to control the water specular effect, with manually created mip levels.

Edited by Kryzon

Share this post


Link to post
Share on other sites

Thankyou :) I am amazed at the difference! It makes it look so much more professional. And to think I once didn't like the idea of shaders...

 

I did find a crude way of only drawing the texture to pixels of certain depth. I add this to my VS output structure:

 

float  Depth : TEXCOORD4;

 

..Then in the VS itself:

 

Output.Depth = Output.Position.z;

 

...and finally in the PS:

 

float4 baseColour = tex2D(TextureSampler, PSIn.TexCoords);
if (PSIn.Depth < 40.0f){
float4 detailColour = tex2D(DetailLinearSampler, PSIn.TexCoords*20.5);
baseColour *= detailColour * 2;}

 

It draws the detail texture for pixels within a certain distance of my camera, and since this 'sand' texture is quite subtle, it's not possible to see the boundary between the detail texture and the main texture. It works for now!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!