Jump to content

  • Log In with Google      Sign In   
  • Create Account


Lighting showoffs!


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 04 May 2013 - 07:25 AM

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!



Sponsor:

#2 riuthamus   Crossbones+   -  Reputation: 4319

Like
1Likes
Like

Posted 04 May 2013 - 12:20 PM

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



#3 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 04 May 2013 - 12:29 PM

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?



#4 Kryzon   Prime Members   -  Reputation: 2495

Like
1Likes
Like

Posted 04 May 2013 - 09:36 PM

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, 04 May 2013 - 09:37 PM.


#5 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 05 May 2013 - 03:59 AM

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!



#6 george7378   Members   -  Reputation: 1132

Like
0Likes
Like

Posted 05 May 2013 - 04:36 AM

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:

 

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!



#7 george7378   Members   -  Reputation: 1132

Like
1Likes
Like

Posted 05 May 2013 - 07:03 AM

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

 

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!



#8 george7378   Members   -  Reputation: 1132

Like
2Likes
Like

Posted 05 May 2013 - 08:55 AM

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

 

LEM 3D 22.jpg

 

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



#9 Kryzon   Prime Members   -  Reputation: 2495

Like
1Likes
Like

Posted 05 May 2013 - 12:07 PM

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, 05 May 2013 - 12:09 PM.


#10 george7378   Members   -  Reputation: 1132

Like
1Likes
Like

Posted 05 May 2013 - 05:33 PM

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!






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS