Lack of total internal reflection in refract #50549
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#50549
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Blender Version
Broken: 2.78
4bb1e22
Short description of error
Currently, for k values less than 0 in the refract function, a vector of 0,0,0. This should return a reflection. In combination with fixing the Fresnel node with values under 1, this would allow for accurate total internal reflection.
Exact steps for others to reproduce the error
Create icosphere, set shading to smooth, assign refraction BSDF, view from inside sphere.
found at line 193 in stdosl.h
correction should be something like
Changed status to: 'Open'
Added subscriber: @smilebags
Added subscriber: @SteffenD
Added subscribers: @LukasStockner, @Blendify
@LukasStockner said that he would take a look.
I don't really agree that it should return a reflection - after all, it's explicitly called refract, not bounce_off_glass. So, when refracting isn't possible, the function shouldn't attempt to guess what you might want instead.
Another consideration is that you'll probably want to use fresnel weighting between reflection and refraction anyways, and in the case of TIR the refraction weight will be zero.
And even if it was wrong behavior, we can't just change functions that have been in releases in the past since it would mess up shaders that have been written with the old behavior in mind.
If you really want the behavior you're describing, you could just wrap refract() with a helper function that checks the result and returns reflect() instead.
I understand your point of view and agree that this function shouldn't be changed after reading your comment.
Should, then, the Fresnel node be corrected to produce the right value for rays coming out of a material? I feel like the physically correct way of rendering refractive materials (especially when it is computationally not much more expensive) shouldn't require coding for the user.
Currently the Fresnel node doesn't give correct values, and therefore can't be used by its-self to create Total Internal Reflection. All other aspects of this node are physically accurate, and I don't see this change being detrimental to existing materials.
Added subscriber: @brecht
The Fresnel node was primarily intended for mixing diffuse and glossy, since the glass BSDF already includes fresnel. For correct handling of multiple scattering and roughness you also need the Fresnel to be baked into the BSDF anyway, doing it using custom nodes is not physically correct.
The problem is that those two cases require different handling of normals, for glass you want to invert the IOR when exiting the object, for mixing diffuse and glossy you don't want that.
So you'd need to do something like adding an option to the Fresnel node to choose the behavior. But really I would prefer to eventually remove the Refractive BSDF node, since it's not possible to use it in a physically correct way.
Changed status from 'Open' to: 'Resolved'
Thanks for the insight, @brecht, it hadn't occurred to me that it would be used for that, but it makes sense, as its current values mean a diffuse/glossy mix looks the same on both sides.
Okay. I have been playing with adding dispersion to refractive materials, both with node groups and with OSL, and both methods rely on the Refraction BSDF to work. It has been a goal of mine to get glass looking better in cycles (at the expense of samples)
As for Total Internal Reflection, adding a 'refractive' boolean option to the Fresnel node would be sufficient for purely smooth glass, but as you said, won't fix the issue for rough surfaces.
I will close this case as I've realised the issue is not in the refraction, but would like to continue discussing a backwards-compatible solution to this, as I believe it would be a great addition to a reasonably visible problem. I'm happy to help implement the changes.