# \[SOLVED\] Issue Rending Two Materials Over Each Other

**URL:** <https://forum.defold.com/t/solved-issue-rending-two-materials-over-each-other/72872>\
**Category:** Questions\
**Created:** [March 15, 2023, 9:50pm UTC](https://forum.defold.com/t/solved-issue-rending-two-materials-over-each-other/72872 "2023-03-15T21:50:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gameoffate2018](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gameoffate2018/32/20065_2.png) [@gameoffate2018](https://forum.defold.com/u/gameoffate2018)\
**Post date:** [March 15, 2023, 9:50pm UTC](https://forum.defold.com/t/solved-issue-rending-two-materials-over-each-other/72872/1 "2023-03-15T21:50:14Z")

</div>

Hello!

I have been playing around with rendering recently and got stuck. I am trying to merge two effects I like to create a unique look for my game.

My goal is to make it feel like you are playing Legend of Zelda, Link to the Past on a CRT television, something like this:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/e/2/e2834037146af4c8927ab8cf750c8ea00b8b167f.jpeg)

What I have been trying so far is rendering one material on top of another.

On the lower level I am trying to render lights as seen in this post/project:

- [Simple 2D Lighting - #15 by britzl](https://forum.defold.com/t/simple-2d-lighting/14545/15)
- [publicexamples/examples/simple\_lights at master · britzl/publicexamples · GitHub](https://github.com/britzl/publicexamples/tree/master/examples/simple_lights)

Then, over that I am trying to render the CRT effect from the horror-lofi project as seen in this post/project:

- [Horri-Fold - a Lo-Fi Horror Shader for Defold](https://forum.defold.com/t/horri-fold-a-lo-fi-horror-shader-for-defold/70090)

I have made some progress, currently both techniques are in the game (hitting tab will swap the render type).

Currently the first effect (Horror-Lofi) only works 50% of the time. Literally restarting the game without changing any code will sometimes cause it to work / not work.

The second effect (lighting) works and I am happy with it.

The third effect (mix of the two) does not work at all. I’ve tried several things such as creating a unique material. Rendering one material over the other. I even tried to write my own render script without much success. As close as I’ve gotten is just one or the other showing up.

Here is my project:  
[post\_processing\_mixed.zip](https://forum.defold.com/uploads/short-url/ka0HKqGXYeXMrfZ8jheBwnfncyo.zip) (531.0 KB)

Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![gameoffate2018](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gameoffate2018/32/20065_2.png) [@gameoffate2018](https://forum.defold.com/u/gameoffate2018)\
**Post date:** [March 16, 2023, 1:55am UTC](https://forum.defold.com/t/solved-issue-rending-two-materials-over-each-other/72872/2 "2023-03-16T01:55:09Z")

</div>

I was able to figure it out!

Turns out I was way over complicating things with my initial approach.

I simplified my solution down to one material (the multiply\_quad). I edited the fragment program and the material to be able to handle both sets of input within one model.

As a result I was able to get the effect just the way I wanted it to be.  
Horror-lofi:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/2/f/2fa681a0d064eb4a852e0c66a096ba2edf6cabae.jpeg)

Lights:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/3/a/3aa7b56ec40d7f1b4e01513d9effcd0de5484ba6.png)

Both:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/8/b/8b5f3096ecde8d33a3766c7fd74edc2ce172f91d.jpeg)

I’m extremely happy with how this turned out. If you’d like to see my solution fully implemented, here is the project for it:  
[post\_processing\_mixed\_fixed.zip](https://forum.defold.com/uploads/short-url/2ixa25PqCl8bZkTFAE81e2eL2jR.zip) (530.4 KB)
