morrQAQ / ReadUnityShaderBook

UnityShader入门精要读书笔记
1 stars 0 forks source link

12-edge-detection #15

Open morrQAQ opened 1 year ago

morrQAQ commented 1 year ago

各种算子推导

卷积——通俗易懂,看完还是不明白.

但是为什么 要翻转相乘呢?

但是举例子的卷积核,都是对称的,翻转的意义在哪里?仅仅为了延续数学定义吗?那为什么要卷积?

6/28 update 我明白了,其实原文说的很清楚,只不过之前我没理解. 翻转的意义就在于施加约束,而约束本身就是翻转.(t)(n-t) 因为我们的卷积核是9个,所以我们只对像素周围的像素做卷积.这里的约束就是 (-1,1),正方形. 有因为卷积核本来就是对称矩阵,所以在这里翻转和不翻转一样的,但是翻转本身就是有其意义的. 那个摇骰子的例子很容易理解,而且这个过程其实非常像动态规划.

morrQAQ commented 8 months ago

12 章 - 后处理

  1. on render image 什么时候调?

    这个方法通常在相机渲染完成后被调用,但在图像显示到屏幕之前

  2. 我可以理解景深的处理需要关闭深度写入,但是为什么还有后续的渲染阶段?它不是已经是相机到图像显示前的最后一步了吗?按道理来说透明物体早已经渲染完毕然后被后处理抓取了.

    你提出了一个很好的问题。在通常情况下,后处理确实是在渲染管线的最后一步进行,而且在这一步之后通常不会再有其他的渲染阶段。在这种情况下,关闭深度写入似乎就没有意义了,因为后续没有需要使用深度信息的渲染阶段了。

然而,在某些情况下,可能会存在需要在后处理之后再次进行渲染的情况。例如:

透明物体渲染: 如果场景中包含透明物体,它们可能会在后处理之后进行渲染。 在渲染透明物体时,仍然需要正确的深度信息来实现正确的深度测试和排序。 后期效果的特殊需求: 某些后期效果可能需要重新渲染场景的部分或全部内容,例如全屏特效、全局光照等。 这些效果可能需要使用深度信息来实现,因此在后处理期间关闭深度写入可以确保深度信息在需要时仍然是可用的。 综上所述,尽管后处理通常是渲染管线的最后一步,但仍然可能存在需要在后处理之后再次进行渲染的情况。在这种情况下,关闭深度写入可以确保深度信息在需要时仍然是可用的,并保持后续渲染阶段的正确性。 当使用某些特殊的后期效果时,透明物体可能会在后处理之后重新渲染。一个具体的例子是折射效果(Refraction)。

假设你正在实现一个水面的折射效果,其中水面下方有一些透明的物体,例如玻璃瓶或鱼。在这种情况下,后处理阶段需要捕捉到水面下方的景象,然后使用折射的效果将水面上方的景象影射到水面下方。这个过程通常需要在后处理之后重新渲染水面下方的透明物体,以确保折射效果能够正确地应用到它们上面。

具体的实现步骤可能如下: 渲染水面: 首先渲染水面,以及水面下方的场景。这个渲染过程可能包括深度信息的记录和保存。 后处理阶段: 在后处理阶段,应用折射效果。这可能涉及到对捕捉到的水面下方景象进行处理,将其影射到水面上。 透明物体重新渲染: 在应用折射效果之后,透明物体(如玻璃瓶或鱼)可能需要重新渲染,以确保折射效果正确地应用到它们上面。这个过程可能会涉及到重新排序或者合并渲染队列,以确保渲染顺序的正确性。

morrQAQ commented 8 months ago

纹素

ChatGPT The term "texel" (texture element) is used instead of "pixel" (picture element) when referring to elements in a texture because textures and images serve different purposes and are used differently in computer graphics.

Here's why we use "texel" instead of "pixel" for textures:

Purpose: Pixels are the basic units of a raster image, representing the smallest controllable elements of a display. They directly correspond to the elements of the display device. Texels, on the other hand, are elements of a texture, which is a data structure used to store and manage image data. Textures are used in various ways in computer graphics, such as mapping onto surfaces of 3D models or applying as materials in rendering. Abstraction: Textures can have various resolutions and may not directly correspond to the display resolution. They can be larger or smaller than the screen resolution. Texels are an abstraction that represents the discrete elements of a texture, regardless of the resolution or how they are ultimately mapped onto the screen. Mapping and Sampling: When a texture is applied to a 3D model or rendered onto the screen, texels are mapped onto the geometry of the model and sampled to determine the final appearance of each pixel on the screen. Texels are sampled and filtered to generate the final pixel colors on the screen. The process of sampling texels to generate pixel colors involves various techniques such as texture filtering, mipmapping, and anisotropic filtering.