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 sport. 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 improper measurement of render texture, or with airplane I don’t know precisely.
Here is what I achieved:
Here is my world with 2 cameras (first major, 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 may see my rendered texture in airplane:

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

One factor I observed that my major 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 alter the dimensions of reflection digital camera and render texture to match major’s digital camera width and peak within the code, however the measurement nonetheless was improper.

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 feel the issue is my major digital camera isWindowsSized, when my reflation digital camera isn’t:

Reflection digital camera misplaced its isWindowsSize once 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 publish the undertaking so we are able to see the reason for the issue?

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

If the digital camera has a renderTexture then isWindowsSize will probably be set to false as a result of it’s going to name the digital camera object’s setFixedSize operate

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

water_reflaction_test.zip (2.6 MB)

I attempted this one to set measurement by my major digital camera width and peak, however on this case I bought very large view in texture…

I can get appropriate view simply by modifying scale of water airplane, however it’s improper resolution I feel, additionally it’s magic numbers:

Adjusting the scaling of the nodes is required as a result of the display side ratio is just not 1:1 and the “Reflaction Camera” has an angle with the airplane, so learn how to modify it?

Suppose the display measurement is 640×960:

  1. Keep the width and peak of the rendertexture unchanged and modify 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 modify the scaling of the node to the suitable worth.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here