Difference between revisions of "User:Pirateguybrush"
From Bo3b's School for Shaderhackers
| (8 intermediate revisions by one user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | == '''Lesson 0''' == | |
[[File:Pirateguybrush Lesson 0.jpg|700px]] | [[File:Pirateguybrush Lesson 0.jpg|700px]] | ||
| − | ----------- | + | <br> |
| + | |||
| + | == '''Lesson 1''' == | ||
| + | |||
| + | <nowiki> // 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) | ||
| + | |||
| + | </nowiki> | ||
| + | |||
| + | == '''Lesson 2''' == | ||
| + | Before: | ||
| + | |||
| + | [[File:Pirateguybrush Lesson 2-2.jpg|700px]] | ||
| + | |||
| + | After: | ||
| + | |||
| + | [[File:Pirateguybrush Lesson 2-1.jpg|700px]] | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == '''Lesson 3''' == | ||
| + | |||
| + | <nowiki> | ||
| + | // 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 c220, Const1, Const2, Const3, Const4 | ||
| + | def c200, 0, 1, 0.0625, 0 // x=0 for comparison to Const1 | ||
| + | |||
| + | 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 | ||
| + | // if Const1 = 0 disable effect, else leave it on | ||
| + | mov r30.x, c220.x | ||
| + | mov oC0.xyzw, c1.xywx | ||
| + | if_eq r30.x, c200.x | ||
| + | mov oC0.xyzw, c200.wwww | ||
| + | endif | ||
| + | |||
| + | // approximately 21 instruction slots used (1 texture, 20 arithmetic) | ||
| + | </nowiki> | ||
| + | |||
| + | [[File:Pirateguybrush Lesson 3.jpg|700px]] | ||
| + | |||
| + | <br> | ||
| + | |||
| + | == '''Lesson 4''' == | ||
| + | |||
| + | <nowiki> | ||
| + | [General] | ||
| + | |||
| + | // UseRenderedShaders=true is nearly always useful, because it trims the | ||
| + | // list of shaders seen while hunting down to just those active in the | ||
| + | // current scene. Disable this only if you get crashes during hunting. | ||
| + | UseRenderedShaders=true | ||
| + | |||
| + | // DumpAll will generate ASM text files for every shader seen by the game. | ||
| + | // This is usually worth doing once, but not useful for every run. | ||
| + | DumpAll=false | ||
| + | |||
| + | // Constant registers that will arrive in Vertex and Pixel Shaders, as | ||
| + | // c220. The constants below will be assigned, based on the key preset. | ||
| + | DefVSConst1 = 220 | ||
| + | DefPSConst1 = 220 | ||
| + | |||
| + | // The PresetKeysList specifies which KEYs will be used. | ||
| + | // Multiple keys lists are supported. | ||
| + | PresetsKeysList = 1;2; | ||
| + | |||
| + | // For this single key example, we only need one keylist, KEY1. This specifies | ||
| + | // that the Numpad 0 keyboard key (Key=96) should act as a toggle. And toggle | ||
| + | // between the two Presets of PRES1, PRES2. Which will change the Const1 being | ||
| + | // passed to the shader code from 1.0 to 0.0 as floating point numbers. | ||
| + | // Type=1 is toggle, Type=2 is momentary. | ||
| + | [KEY1] | ||
| + | Key = 96 | ||
| + | Presets = 1;2; | ||
| + | Type = 2 | ||
| + | |||
| + | // Constants that will be sent to every shader through constant register c220. | ||
| + | // The Const1 tells us that we'll need to use c220.x to compare against these | ||
| + | // values. Const2 would be seen as c220.y. | ||
| + | // 0x3f800000 is 1.0 in floating point hex, 0x00000000 is 0.0 in hex | ||
| + | // UseByDef specifies which constant is the default starting value. | ||
| + | [PRES1] | ||
| + | Const1 = 0x3f800000 | ||
| + | [PRES2] | ||
| + | UseByDef=True | ||
| + | Const1 = 0x00000000 | ||
| + | [KEY2] | ||
| + | Key = 81 | ||
| + | Presets = 3;4; | ||
| + | Type = 2 | ||
| + | |||
| + | // Constants that will be sent to every shader through constant register c220. | ||
| + | // The Const1 tells us that we'll need to use c220.x to compare against these | ||
| + | // values. Const2 would be seen as c220.y. | ||
| + | // 0x3f800000 is 1.0 in floating point hex, 0x00000000 is 0.0 in hex | ||
| + | // UseByDef specifies which constant is the default starting value. | ||
| + | [PRES3] | ||
| + | Const2 = 0x3f800000 | ||
| + | [PRES4] | ||
| + | UseByDef=True | ||
| + | Const2 = 0x00000000 | ||
| + | </nowiki> | ||
| + | <br> | ||
Latest revision as of 00:05, 28 October 2014
Contents
Lesson 0
Lesson 1
// 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
Before:
After:
Lesson 3
// 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 c220, Const1, Const2, Const3, Const4
def c200, 0, 1, 0.0625, 0 // x=0 for comparison to Const1
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
// if Const1 = 0 disable effect, else leave it on
mov r30.x, c220.x
mov oC0.xyzw, c1.xywx
if_eq r30.x, c200.x
mov oC0.xyzw, c200.wwww
endif
// approximately 21 instruction slots used (1 texture, 20 arithmetic)
Lesson 4
[General] // UseRenderedShaders=true is nearly always useful, because it trims the // list of shaders seen while hunting down to just those active in the // current scene. Disable this only if you get crashes during hunting. UseRenderedShaders=true // DumpAll will generate ASM text files for every shader seen by the game. // This is usually worth doing once, but not useful for every run. DumpAll=false // Constant registers that will arrive in Vertex and Pixel Shaders, as // c220. The constants below will be assigned, based on the key preset. DefVSConst1 = 220 DefPSConst1 = 220 // The PresetKeysList specifies which KEYs will be used. // Multiple keys lists are supported. PresetsKeysList = 1;2; // For this single key example, we only need one keylist, KEY1. This specifies // that the Numpad 0 keyboard key (Key=96) should act as a toggle. And toggle // between the two Presets of PRES1, PRES2. Which will change the Const1 being // passed to the shader code from 1.0 to 0.0 as floating point numbers. // Type=1 is toggle, Type=2 is momentary. [KEY1] Key = 96 Presets = 1;2; Type = 2 // Constants that will be sent to every shader through constant register c220. // The Const1 tells us that we'll need to use c220.x to compare against these // values. Const2 would be seen as c220.y. // 0x3f800000 is 1.0 in floating point hex, 0x00000000 is 0.0 in hex // UseByDef specifies which constant is the default starting value. [PRES1] Const1 = 0x3f800000 [PRES2] UseByDef=True Const1 = 0x00000000 [KEY2] Key = 81 Presets = 3;4; Type = 2 // Constants that will be sent to every shader through constant register c220. // The Const1 tells us that we'll need to use c220.x to compare against these // values. Const2 would be seen as c220.y. // 0x3f800000 is 1.0 in floating point hex, 0x00000000 is 0.0 in hex // UseByDef specifies which constant is the default starting value. [PRES3] Const2 = 0x3f800000 [PRES4] UseByDef=True Const2 = 0x00000000