# Multiple GodRays Effects

**URL:** <https://discourse.threejs.org/t/multiple-godrays-effects/25838>\
**Category:** Questions\
**Tags:** effect-composer, post-processing\
**Created:** [April 30, 2021, 12:48pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838 "2021-04-30T12:48:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [April 30, 2021, 12:48pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/1 "2021-04-30T12:48:42Z")

</div>

Hi, my 3d configurator is almost finished but I’m stuck by the maximum effects in an EffectPass : I have 25 GodRays Effect but it looks like the maximum is 15.

The console shows this error :  
`THREE.WebGLProgram: shader error: 0 gl.VALIDATE_STATUS false gl.getProgramInfoLog FRAGMENT shader texture image units count exceeds MAX_TEXTURE_IMAGE_UNITS(16)`

I tried using a 2nd EffectPass in a 2nd Composer but it only renders one composer, and it’s very laggy.

Here is a codepen of my work :

https://codepen.io/orelientanguy/embed/preview/bGgyzNB?height=344&theme-id=dark&default-tab=result

My method may be wrong ? Is it possible to use 1 godrays for more than 1 object ?

---

<div class="post-metadata">

**Author:** ![GlifTek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gliftek/32/13131_2.png) [@GlifTek](https://discourse.threejs.org/u/GlifTek)\
**Post date:** [April 30, 2021, 7:33pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/2 "2021-04-30T19:33:41Z")

</div>

Are the god rays for the light’s? It would be good if users coups zoom out a bit to see them. The car rotates, including them.

---

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [April 30, 2021, 7:54pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/3 "2021-04-30T19:54:44Z")

</div>

The godrays are faking lights, there is no lights coming from the car.  
I intentionally disabled the zoom because there’s not much to see except the car

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [April 30, 2021, 10:49pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/4 "2021-04-30T22:49:39Z")

</div>

Hi @aurelientanguy,  
Have you considered combining all geometries that use the same material, creating 1 mesh from the one merged geometry with a single material and running that one combined object through a single godrays pass? after looking at your scene you could get it down to 4 god Ray passes, one for orange, one for front white, 2 for red and white rear lights…

Just a suggestion but nevertheless it’s looking like great progress youve made!!!

---

<div class="post-metadata">

**Author:** ![GlifTek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gliftek/32/13131_2.png) [@GlifTek](https://discourse.threejs.org/u/GlifTek)\
**Post date:** [April 30, 2021, 10:59pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/5 "2021-04-30T22:59:40Z")

</div>

What I meant was I can’t see the actual rays, I guess because I’m on mobile perhaps.  
I can only get a front view of them, then they go off screen if I want to see them from the side.

---

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [April 30, 2021, 11:22pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/6 "2021-04-30T23:22:03Z")

</div>

Hi @Lawrence3DPK thank you for replying again

Not sure about what you mean, as I’m using each material’s opacity to toggle “lights” on and off.  
I can try your solution to merge objects that lights up together _(like feuderoute1 and feuderoute2 as an example)_ so it would divide the GodRays Effects count by two I guess. But I can’t figure out how to reduce this count to only 4 godrays 🧐

By the way, how would you merge those objects ? maybe something like this ?  
`let feuderoute = new THREE.Mesh(feuderoute1, feuderoute2);`

---

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [April 30, 2021, 11:28pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/7 "2021-04-30T23:28:02Z")

</div>

@GlifTek I think you’re seeing it right, it’s normal that the effect disappear when object is hidden by the car because there’s no real lights, only meshs + godrays effects.

As I see it on my devices it looks the same on mobiles, tablets and laptops. I’m using an iphone 8 with ios 14 and it works on Safari and Chrome.

Maybe just try to rotate your mobile?

**EDIT: just re-enabled zoom, I think it’s better when it’s disabled. Let me know**

---

<div class="post-metadata">

**Author:** ![GlifTek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gliftek/32/13131_2.png) [@GlifTek](https://discourse.threejs.org/u/GlifTek)\
**Post date:** [April 30, 2021, 11:45pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/8 "2021-04-30T23:45:11Z")

</div>

Yea I still can’t zoom back far enough to see them from the side. (Which is the effect you want people to observe)  
I’ll look in desktop.  
Sorry for the fuss.  
Looks awesome regardless!

Edit: yeah sorry my accelerometer in my phone I think broke because of the cold this winter so I couldn’t see the headlight effect sideways.

Tried on a friend’s phone.  
Looks great. Real nice effect!

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [May 1, 2021, 8:00am UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/9 "2021-05-01T08:00:18Z")

</div>

@aurelientanguy

You have to import BufferGeometryutils and use like…

`let g = BufferGeometryUtils.mergeBufferGeometries([geo, gCircle1, gCircle2]);`

Where geo, gCircle and gCircle2 are the geometries you want to merge…

Also not tested but I’m sure you could group any other meshes that need to be seperated and run that group at once through the god rays effect where the rays don’t change meaning you could change the opacity of each childs material in the group, this would bring the god rays effect down to 4, as I say, 1. front white lights, 2.orange lights, 3. rear white lights, 4. Rear red lights…

Hope this helps, give it a try and let me know!

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [May 14, 2021, 10:27am UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/10 "2021-05-14T10:27:04Z")

</div>

Hey @aurelientanguy how’s it going with the project? Did you manage to make sense of the suggestion I made?

---

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [May 18, 2021, 7:50pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/11 "2021-05-18T19:50:39Z")

</div>

@Lawrence3DPK Just sent you a dm

---

<div class="post-metadata">

**Author:** ![aurelientanguy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/aurelientanguy/32/17495_2.png) [@aurelientanguy](https://discourse.threejs.org/u/aurelientanguy)\
**Post date:** [May 27, 2021, 6:44pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/12 "2021-05-27T18:44:49Z")

</div>

**UP**

Im still stuck with this problem, the @Lawrence3DPK’s solution doesn’t work because I only have one geometry and all the meshes are created with it.

**To make my problem more clear :**

- I have 25 meshes, and so 25 godrays effects. An effect pass only accepts 15 effects.
- I’ve tried to create a second effect pass, but the composer only accepts one.
- I’ve tried to create a second composer, but there is only one rendering (always the second composer to be mentionned in my render function)

Here is a codepen of my work so far

https://codepen.io/orelientanguy/embed/preview/bGgyzNB?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=bGgyzNB

---

<div class="post-metadata">

**Author:** ![GlifTek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/gliftek/32/13131_2.png) [@GlifTek](https://discourse.threejs.org/u/GlifTek)\
**Post date:** [May 28, 2021, 12:01am UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/13 "2021-05-28T00:01:27Z")

</div>

Still curious why you have the camera so close.  
I want to see the effect be occluded then reveal. Impossible because of the camera cutoff.

---

<div class="post-metadata">

**Author:** ![Lawrence3DPK](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lawrence3dpk/32/29184_2.png) [@Lawrence3DPK](https://discourse.threejs.org/u/Lawrence3DPK)\
**Post date:** [May 28, 2021, 10:06pm UTC](https://discourse.threejs.org/t/multiple-godrays-effects/25838/14 "2021-05-28T22:06:49Z")

</div>

Yeah it’s a difficult one, I was trying to have a play with the godrays but you’re not using es6 modules (three.module.js) to import, so BufferGeometryUtilis is not behaving as expected, I’ll have another look ASAP for you and see if I can help
