Home Game Development Need assist with mirror reflection rendering – Cocos Creator

Need assist with mirror reflection rendering – Cocos Creator

0
Need assist with mirror reflection rendering – Cocos Creator

[ad_1]

Hi all, I wish to create water reflection in my recreation. I learn few tutorials and understood I would like to make use of second mirrored digital camera and render texture than I’ll render in airplane, however I get hassle with the unsuitable dimension of render texture, or with airplane I don’t know precisely.
Here is what I achieved:
Here is my world with 2 cameras (first foremost, second mirror reflaction)

within the backside is blue airplane what I’m utilizing for render texture, now in play mode I’ll disable haxagons and you’ll see my rendered texture in airplane:

As you see, the rendered texture, smaller than 3D hexagons.
My render texture has 1024×1024 dimension, and airplane scale is (1, 1, 1), so I don’t know what I’m doing unsuitable.

One factor I observed that my foremost digital camera has isWindowSize property true, when my reflection digital camera doesn’t have this one, as a result of it has render texture. I attempted to vary the scale of reflection digital camera and render texture to match foremost’s digital camera width and top within the code, however the dimension nonetheless was unsuitable.

please present each digital camera settings, the digital camera fov and projection should even be aligned

Thanks for reply, I’m utilizing this code in lateUpdate, so they need to be the identical:

I believe the issue is my foremost digital camera isWindowsSized, when my reflation digital camera isn’t:

Reflection digital camera misplaced its isWindowsSize after I connect targetTexture to it.
Also, it may very well be some downside with airplane the place I render the feel. But it has scale(1, 1, 1)

Can you submit the undertaking so we are able to see the reason for the issue?

If it’s a dimension downside, you’ll be able to name the resize perform of renderTexture

If the digital camera has a renderTexture then isWindowsSize might be set to false as a result of it should name the digital camera object’s setFixedSize perform

Thanks for reply, here’s a small undertaking I created, you’ll be able to see unsuitable reflection:

water_reflaction_test.zip (2.6 MB)

I attempted this one to set dimension by my foremost digital camera width and top, however on this case I received very broad view in texture…

I can get appropriate view simply by modifying scale of water airplane, however it’s unsuitable answer I believe, additionally it’s magic numbers:

Adjusting the scaling of the nodes is required as a result of the display screen facet ratio just isn’t 1:1 and the “Reflaction Camera” has an angle with the airplane, so find out how to regulate it?

Suppose the display screen dimension is 640×960:

  1. Keep the width and top of the rendertexture unchanged and regulate the scaling of the “water_plane” node:
    x : z = 1 : (960/640) = 1 : 1.5

(If it doesn’t match very effectively, the reason being that the digital camera has a sure angle with the airplane)

Then regulate the scaling of the node to the suitable worth.

Thanks for assist, I assumed scaling it’s a unsuitable means, as I didn’t see scaling in tutorials about reflection.

Yes, however as a result of the “Reflaction Camera” node has a forty five diploma view and the mannequin of this scene is particular, it causes mapping issues

But find out how to not have 45 diploma? Main digital camera have -45 diploma, so mirror digital camera will need to have 45?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here