Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spherical Harmonics compute optimization #419

Open
GuoLei1990 opened this issue Aug 6, 2021 · 0 comments
Open

Spherical Harmonics compute optimization #419

GuoLei1990 opened this issue Aug 6, 2021 · 0 comments
Assignees
Labels
low priority Low priority issue performance Performance-related features Rendering Rendering related functions
Milestone

Comments

@GuoLei1990
Copy link
Member

GuoLei1990 commented Aug 6, 2021

Our Spherical Harmonics compute in Shader can optimization.

We can check this :http://www.fractalforums.com/programming/shader-function-or-instruction-cost-(performance)/

How to say: many engine get irradiance use the func like this:

mediump vec3 shEvalLinearL0L1(mediump vec4 normal)
{
mediump vec3 x;
// Linear (L1) + constant (L0) polynomial terms
x.r = dot(u_AmbientSHAr, normal);
x.g = dot(u_AmbientSHAg, normal);
x.b = dot(u_AmbientSHAb, normal);
return x;
}

mediump vec3 shEvalLinearL2(mediump vec4 normal)
{
	mediump vec3 x1,x2;
	// 4 of the quadratic (L2) polynomials
	mediump vec4 vB = normal.xyzz * normal.yzzx;
	x1.r = dot(u_AmbientSHBr, vB);
	x1.g = dot(u_AmbientSHBg, vB);
	x1.b = dot(u_AmbientSHBb, vB);

	// Final (5th) quadratic (L2) polynomial
	mediump float vC = normal.x*normal.x - normal.y*normal.y;
	x2 = u_AmbientSHC.rgb * vC;

	return x1 + x2;
}

Because dot cost only 3 cycles in GPU, so is faster, If you do this you must do some modifies before Incoming shader.

@GuoLei1990 GuoLei1990 added performance Performance-related features Rendering Rendering related functions labels Aug 6, 2021
@GuoLei1990 GuoLei1990 added this to the 0.6 milestone Aug 6, 2021
@GuoLei1990 GuoLei1990 added the low priority Low priority issue label Sep 7, 2021
@GuoLei1990 GuoLei1990 modified the milestones: 0.6, 0.7 Nov 9, 2021
@GuoLei1990 GuoLei1990 modified the milestones: 0.7, 0.8, 0.9 Feb 7, 2022
@GuoLei1990 GuoLei1990 modified the milestones: 0.9, 1.0 Oct 11, 2022
@GuoLei1990 GuoLei1990 modified the milestones: 1.0, 1.1 May 18, 2023
@GuoLei1990 GuoLei1990 modified the milestones: 1.1, 1.2 Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Low priority issue performance Performance-related features Rendering Rendering related functions
Projects
None yet
Development

No branches or pull requests

2 participants