[Cycles/Material view] Modulo function in material doesn't match cycles. #51434

Closed
opened 2017-05-07 20:59:59 +02:00 by Ray molenkamp · 8 comments
Member

mat_view.jpg

System Information
Win7/x64

Blender Version
Broken: latest master
Worked: probably always has been broken.

Short description of error
the math_modulo shader in gpu_shader_material.glsl has a small bug, it makes up for the sign being wrong, but that is not enough

void math_modulo(float val1, float val2, out float outval)
{
	if (val2 == 0.0)
		outval = 0.0;
	else
		outval = mod(val1, val2);

	/* change sign to match C convention, mod in GLSL will take absolute for negative numbers,
	 * see https://www.opengl.org/sdk/docs/man/html/mod.xhtml */
	outval = (val1 > 0.0) ? outval : -outval;
}

last line should probably be

	outval = (val1 > 0.0) ? outval : -(val2-outval);

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps

mod_breakage.blend

render with cycles, compare with material view... not the same

![mat_view.jpg](https://archive.blender.org/developer/F591418/mat_view.jpg) **System Information** Win7/x64 **Blender Version** Broken: latest master Worked: probably always has been broken. **Short description of error** the math_modulo shader in gpu_shader_material.glsl has a small bug, it makes up for the sign being wrong, but that is not enough ``` void math_modulo(float val1, float val2, out float outval) { if (val2 == 0.0) outval = 0.0; else outval = mod(val1, val2); /* change sign to match C convention, mod in GLSL will take absolute for negative numbers, * see https://www.opengl.org/sdk/docs/man/html/mod.xhtml */ outval = (val1 > 0.0) ? outval : -outval; } ``` last line should probably be ``` outval = (val1 > 0.0) ? outval : -(val2-outval); ``` **Exact steps for others to reproduce the error** Based on a (as simple as possible) attached .blend file with minimum amount of steps [mod_breakage.blend](https://archive.blender.org/developer/F591417/mod_breakage.blend) render with cycles, compare with material view... not the same
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Mike Erwin was assigned by Ray molenkamp 2017-05-07 21:02:03 +02:00
Author
Member

Added subscriber: @MikeErwin

Added subscriber: @MikeErwin
Author
Member

@MikeErwin here's some low hanging fruit, didn't want to commit without you looking at it.

@MikeErwin here's some low hanging fruit, didn't want to commit without you looking at it.

Added subscriber: @candreacchio

Added subscriber: @candreacchio

Patch created at D2661

Patch created at [D2661](https://archive.blender.org/developer/D2661)

This issue was referenced by ffc95a33b6

This issue was referenced by ffc95a33b62821e8eb66cf7003942e37976d20d7

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#51434
No description provided.