Jump to content
  • Advertisement
Sign in to follow this  

Multiple light sources in shader

This topic is 4642 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

I have to implement multiple lights support in my vertex shader. My problem is that I haven't decided how to pass multiple light information into FX effect file. Is it better to create several global variables like this float4 lightDiffuse1 :LIGHT1DIFFUSE; float4 lightDiffuse2 :LIGHT2DIFFUSE; float4 lightDiffuse3 :LIGHT3DIFFUSE; or maybe there's an option of creating an array (does FX support them?). And which version of vertex shader supports for operator? Thank you

Share this post


Link to post
Share on other sites
Advertisement
Hi there tokaplan,
How are you doing?

The Problem
Rendering multiple lights in a shader.

The Solution
Look at this post about lights in shaders.
Ok, Well I would have a light manager that has the active amount of lights in the scene, each of these lights have a position, direction (if needed), color, and color and other components I am not listing :). I would then in my shader have a pass for each light. Although this might be load intensive it makes switching lights on and off easier. For the number of lights you just render a next pass giving it the next light from your light manager.

I hope this helps a bit.

Take care tokaplan.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!