Difference between revisions of "User:Bo3b"
From Bo3b's School for Shaderhackers
Line 7: | Line 7: | ||
This is first shader file, Pixel Shader of entire ball. | This is first shader file, Pixel Shader of entire ball. | ||
− | <nowiki>// | + | <nowiki>// Annoying bloom on ball light |
+ | |||
+ | // | ||
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022 | // Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022 | ||
// | // | ||
// Parameters: | // Parameters: | ||
// | // | ||
− | |||
− | |||
// sampler2D Texture2D_0; | // sampler2D Texture2D_0; | ||
− | + | // float UniformPixelScalar_7; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | // float | + | |
− | + | ||
− | + | ||
− | + | ||
// float4 UniformPixelVector_0; | // float4 UniformPixelVector_0; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
// float4 UniformPixelVector_3; | // float4 UniformPixelVector_3; | ||
// float4 UniformPixelVector_4; | // float4 UniformPixelVector_4; | ||
// float4 UniformPixelVector_5; | // float4 UniformPixelVector_5; | ||
// float4 UniformPixelVector_6; | // float4 UniformPixelVector_6; | ||
− | |||
− | |||
− | |||
// | // | ||
// | // | ||
// Registers: | // Registers: | ||
// | // | ||
− | // Name | + | // Name Reg Size |
− | // | + | // -------------------- ----- ---- |
− | // UniformPixelVector_0 | + | // UniformPixelVector_0 c0 1 |
− | // | + | // UniformPixelVector_3 c4 1 |
− | + | // UniformPixelVector_4 c5 1 | |
− | // | + | // UniformPixelVector_5 c6 1 |
− | // | + | // UniformPixelVector_6 c7 1 |
− | // | + | // UniformPixelScalar_7 c8 1 |
− | // | + | // Texture2D_0 s0 1 |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | // Texture2D_0 | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
// | // | ||
ps_3_0 | ps_3_0 | ||
− | def c1, 0 | + | def c1, 0.5, 1, -0.5, 0 |
− | + | def c2, 3, 0, 0, 0 | |
− | + | dcl_texcoord v0.xy | |
− | + | dcl_texcoord1 v1 | |
− | + | dcl_texcoord2 v2.y | |
− | + | dcl_texcoord4 v3.w | |
− | + | ||
− | + | ||
− | def | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
dcl_2d s0 | dcl_2d s0 | ||
− | + | add r0.xy, c1.z, v0 | |
− | + | mov r0.w, c1.w | |
− | + | dp2add r1.x, c5, r0, r0.w | |
− | + | dp2add r1.y, c6, r0, r0.w | |
− | + | add r0.xy, r1, c1.x | |
− | + | texld r0, r0, s0 | |
− | + | mad_sat r0.y, v2.y, -c1.x, c1.y | |
− | + | mul r0.yzw, r0.y, v1.xxyz | |
− | + | mul r0.yzw, r0, v1.w | |
− | + | mul_sat r0.xyz, r0.yzww, r0.x | |
− | + | mul r1.xyz, r0, c4 | |
− | + | mad r0.xyz, c4, -r0, r0 | |
− | + | mad r0.xyz, c8.x, r0, r1 | |
− | + | mul r0.xyz, r0, c4.w | |
− | + | mul r0.xyz, r0, c7 | |
− | + | mov r1.x, c2.x | |
− | + | mad_pp r0.xyz, r0, r1.x, c0 | |
− | + | mul_pp oC0.xyz, r0, v3.w | |
− | add | + | mov oC0.w, c1.w |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | texld | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mul | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mul r0. | + | |
− | + | ||
− | + | ||
− | mul | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mad | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mad r0.xyz, | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mul | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mul | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mad_pp r0 | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | mul_pp | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | // approximately | + | // Disable game-breaking bloom effect |
+ | mov oC0.xyzw, c1.wwww | ||
+ | |||
+ | // approximately 21 instruction slots used (1 texture, 20 arithmetic) | ||
+ | |||
</nowiki> | </nowiki> | ||
+ | |||
+ | == Lesson 2. Amazing right? == | ||
+ | Done! First effect disabled. | ||
+ | |||
+ | Before: | ||
+ | [[File:Before TheBall01 85 - Copy.jpg|700px]] | ||
+ | |||
+ | After: | ||
+ | [[File:After TheBall02 85 - Copy.jpg|700px]] |
Revision as of 04:03, 23 August 2014
Lesson 0. Easy right?
Lesson 1. Scary right?
This is first shader file, Pixel Shader of entire ball.
// Annoying bloom on ball light // // Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022 // // Parameters: // // sampler2D Texture2D_0; // float UniformPixelScalar_7; // float4 UniformPixelVector_0; // float4 UniformPixelVector_3; // float4 UniformPixelVector_4; // float4 UniformPixelVector_5; // float4 UniformPixelVector_6; // // // Registers: // // Name Reg Size // -------------------- ----- ---- // UniformPixelVector_0 c0 1 // UniformPixelVector_3 c4 1 // UniformPixelVector_4 c5 1 // UniformPixelVector_5 c6 1 // UniformPixelVector_6 c7 1 // UniformPixelScalar_7 c8 1 // Texture2D_0 s0 1 // ps_3_0 def c1, 0.5, 1, -0.5, 0 def c2, 3, 0, 0, 0 dcl_texcoord v0.xy dcl_texcoord1 v1 dcl_texcoord2 v2.y dcl_texcoord4 v3.w dcl_2d s0 add r0.xy, c1.z, v0 mov r0.w, c1.w dp2add r1.x, c5, r0, r0.w dp2add r1.y, c6, r0, r0.w add r0.xy, r1, c1.x texld r0, r0, s0 mad_sat r0.y, v2.y, -c1.x, c1.y mul r0.yzw, r0.y, v1.xxyz mul r0.yzw, r0, v1.w mul_sat r0.xyz, r0.yzww, r0.x mul r1.xyz, r0, c4 mad r0.xyz, c4, -r0, r0 mad r0.xyz, c8.x, r0, r1 mul r0.xyz, r0, c4.w mul r0.xyz, r0, c7 mov r1.x, c2.x mad_pp r0.xyz, r0, r1.x, c0 mul_pp oC0.xyz, r0, v3.w mov oC0.w, c1.w // Disable game-breaking bloom effect mov oC0.xyzw, c1.wwww // approximately 21 instruction slots used (1 texture, 20 arithmetic)
Lesson 2. Amazing right?
Done! First effect disabled.